@@ -8,6 +8,7 @@ import json from '@rollup/plugin-json'
88import MagicString from 'magic-string'
99import type { Plugin , RollupOptions } from 'rollup'
1010import { defineConfig } from 'rollup'
11+ import { minify as esbuildMinifyPlugin } from 'rollup-plugin-esbuild'
1112import licensePlugin from './rollupLicensePlugin'
1213
1314const pkg = JSON . parse (
@@ -153,13 +154,13 @@ function createNodeConfig(isProduction: boolean) {
153154 index : path . resolve ( __dirname , 'src/node/index.ts' ) ,
154155 cli : path . resolve ( __dirname , 'src/node/cli.ts' ) ,
155156 constants : path . resolve ( __dirname , 'src/node/constants.ts' ) ,
156- runtime : path . resolve ( __dirname , 'src/node/ssr/runtime/index.ts' ) ,
157157 } ,
158158 output : {
159159 ...sharedNodeOptions . output ,
160160 sourcemap : ! isProduction ,
161161 } ,
162162 external : [
163+ / ^ v i t e \/ / ,
163164 'fsevents' ,
164165 'lightningcss' ,
165166 'rollup/parseAst' ,
@@ -176,6 +177,51 @@ function createNodeConfig(isProduction: boolean) {
176177 } )
177178}
178179
180+ function createRuntimeConfig ( isProduction : boolean ) {
181+ return defineConfig ( {
182+ ...sharedNodeOptions ,
183+ input : {
184+ runtime : path . resolve ( __dirname , 'src/runtime/index.ts' ) ,
185+ } ,
186+ output : {
187+ ...sharedNodeOptions . output ,
188+ sourcemap : ! isProduction ,
189+ } ,
190+ external : [
191+ 'fsevents' ,
192+ 'lightningcss' ,
193+ 'rollup/parseAst' ,
194+ ...Object . keys ( pkg . dependencies ) ,
195+ ] ,
196+ plugins : [
197+ ...createNodePlugins (
198+ false ,
199+ ! isProduction ,
200+ // in production we use rollup.dts.config.ts for dts generation
201+ // in development we need to rely on the rollup ts plugin
202+ isProduction ? false : './dist/node' ,
203+ ) ,
204+ esbuildMinifyPlugin ( { minify : false , minifySyntax : true } ) ,
205+ {
206+ name : 'replace bias' ,
207+ transform ( code , id ) {
208+ if ( id . includes ( '@jridgewell+trace-mapping' ) ) {
209+ return {
210+ code : code . replaceAll (
211+ 'bias === LEAST_UPPER_BOUND' ,
212+ 'true' +
213+ `/*${ 'bias === LEAST_UPPER_BOUND' . length - '/**/' . length - 'true' . length } */` ,
214+ ) ,
215+ map : null ,
216+ }
217+ }
218+ } ,
219+ } ,
220+ bundleSizeLimit ( 45 ) ,
221+ ] ,
222+ } )
223+ }
224+
179225function createCjsConfig ( isProduction : boolean ) {
180226 return defineConfig ( {
181227 ...sharedNodeOptions ,
@@ -209,6 +255,7 @@ export default (commandLineArgs: any): RollupOptions[] => {
209255 envConfig ,
210256 clientConfig ,
211257 createNodeConfig ( isProduction ) ,
258+ createRuntimeConfig ( isProduction ) ,
212259 createCjsConfig ( isProduction ) ,
213260 ] )
214261}
0 commit comments