@@ -94,6 +94,7 @@ function createSharedNodePlugins({
94
94
// Since ws is not that perf critical for us, just ignore these deps.
95
95
ignore : [ 'bufferutil' , 'utf-8-validate' ] ,
96
96
sourceMap : false ,
97
+ strictRequires : 'auto' ,
97
98
} ) ,
98
99
json ( ) ,
99
100
]
@@ -108,13 +109,10 @@ const nodeConfig = defineConfig({
108
109
} ,
109
110
external : [
110
111
/ ^ v i t e \/ / ,
111
- 'lightningcss' ,
112
112
'rollup/parseAst' ,
113
- // postcss-load-config
114
- 'yaml' ,
115
- 'jiti' ,
116
- / ^ t s x ( \/ | $ ) / ,
113
+ / ^ t s x \/ / ,
117
114
...Object . keys ( pkg . dependencies ) ,
115
+ ...Object . keys ( pkg . peerDependencies ) ,
118
116
] ,
119
117
plugins : [
120
118
// Some deps have try...catch require of optional deps, but rollup will
@@ -197,14 +195,10 @@ const cjsConfig = defineConfig({
197
195
publicUtils : path . resolve ( __dirname , 'src/node/publicUtils.ts' ) ,
198
196
} ,
199
197
output : {
200
- dir : './dist' ,
198
+ ... sharedNodeOptions . output ,
201
199
entryFileNames : `node-cjs/[name].cjs` ,
202
200
chunkFileNames : 'node-cjs/chunks/dep-[hash].js' ,
203
- exports : 'named' ,
204
201
format : 'cjs' ,
205
- externalLiveBindings : false ,
206
- freeze : false ,
207
- sourcemap : false ,
208
202
} ,
209
203
external : Object . keys ( pkg . dependencies ) ,
210
204
plugins : [ ...createSharedNodePlugins ( { } ) , bundleSizeLimit ( 175 ) ] ,
@@ -297,14 +291,15 @@ function cjsPatchPlugin(): Plugin {
297
291
const cjsPatch = `
298
292
import { createRequire as __cjs_createRequire } from 'node:module';
299
293
300
- const require = __cjs_createRequire(import.meta.url);
301
- const __require = require;
294
+ const __require = __cjs_createRequire(import.meta.url);
302
295
` . trimStart ( )
303
296
304
297
return {
305
298
name : 'cjs-chunk-patch' ,
306
299
renderChunk ( code , chunk ) {
307
300
if ( ! chunk . fileName . includes ( 'chunks/dep-' ) ) return
301
+ if ( ! code . includes ( '__require' ) ) return
302
+
308
303
const match = / ^ (?: i m p o r t [ \s \S ] * ?; \s * ) + / . exec ( code )
309
304
const index = match ? match . index ! + match [ 0 ] . length : 0
310
305
const s = new MagicString ( code )
0 commit comments