@@ -8,6 +8,7 @@ import json from '@rollup/plugin-json'
8
8
import MagicString from 'magic-string'
9
9
import type { Plugin , RollupOptions } from 'rollup'
10
10
import { defineConfig } from 'rollup'
11
+ import { minify as esbuildMinifyPlugin } from 'rollup-plugin-esbuild'
11
12
import licensePlugin from './rollupLicensePlugin'
12
13
13
14
const pkg = JSON . parse (
@@ -153,13 +154,13 @@ function createNodeConfig(isProduction: boolean) {
153
154
index : path . resolve ( __dirname , 'src/node/index.ts' ) ,
154
155
cli : path . resolve ( __dirname , 'src/node/cli.ts' ) ,
155
156
constants : path . resolve ( __dirname , 'src/node/constants.ts' ) ,
156
- runtime : path . resolve ( __dirname , 'src/node/ssr/runtime/index.ts' ) ,
157
157
} ,
158
158
output : {
159
159
...sharedNodeOptions . output ,
160
160
sourcemap : ! isProduction ,
161
161
} ,
162
162
external : [
163
+ / ^ v i t e \/ / ,
163
164
'fsevents' ,
164
165
'lightningcss' ,
165
166
'rollup/parseAst' ,
@@ -176,6 +177,51 @@ function createNodeConfig(isProduction: boolean) {
176
177
} )
177
178
}
178
179
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
+
179
225
function createCjsConfig ( isProduction : boolean ) {
180
226
return defineConfig ( {
181
227
...sharedNodeOptions ,
@@ -209,6 +255,7 @@ export default (commandLineArgs: any): RollupOptions[] => {
209
255
envConfig ,
210
256
clientConfig ,
211
257
createNodeConfig ( isProduction ) ,
258
+ createRuntimeConfig ( isProduction ) ,
212
259
createCjsConfig ( isProduction ) ,
213
260
] )
214
261
}
0 commit comments