@meteorjs/rspack 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rspack.config.js +35 -25
package/package.json
CHANGED
package/rspack.config.js
CHANGED
|
@@ -116,6 +116,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
116
116
|
const isClient = Meteor.isClient;
|
|
117
117
|
const isRun = Meteor.isRun;
|
|
118
118
|
const isReactEnabled = Meteor.isReactEnabled;
|
|
119
|
+
const isTestModule = Meteor.isTestModule;
|
|
119
120
|
const mode = isProd ? 'production' : 'development';
|
|
120
121
|
|
|
121
122
|
const isTypescriptEnabled = Meteor.isTypescriptEnabled || false;
|
|
@@ -141,7 +142,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
141
142
|
|
|
142
143
|
// Determine output directories
|
|
143
144
|
const clientOutputDir = path.resolve(process.cwd(), 'public');
|
|
144
|
-
const serverOutputDir = path.resolve(process.cwd(), '
|
|
145
|
+
const serverOutputDir = path.resolve(process.cwd(), 'private');
|
|
145
146
|
|
|
146
147
|
// Determine context for bundles and assets
|
|
147
148
|
const buildContext = Meteor.buildContext || '_build';
|
|
@@ -185,9 +186,26 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
185
186
|
|
|
186
187
|
const reactRefreshModule = isReactEnabled ? safeRequire('@rspack/plugin-react-refresh') : null;
|
|
187
188
|
|
|
189
|
+
const requireExternalsPlugin = new RequireExternalsPlugin({
|
|
190
|
+
filePath: path.join(buildContext, runPath),
|
|
191
|
+
...(Meteor.isBlazeEnabled && {
|
|
192
|
+
externals: /\.html$/,
|
|
193
|
+
externalMap: (module) => {
|
|
194
|
+
const { request, context } = module;
|
|
195
|
+
if (request.endsWith('.html')) {
|
|
196
|
+
const relContext = path.relative(process.cwd(), context);
|
|
197
|
+
const { name } = path.parse(request);
|
|
198
|
+
return `./${relContext}/template.${name}.js`;
|
|
199
|
+
}
|
|
200
|
+
return request;
|
|
201
|
+
},
|
|
202
|
+
}),
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const clientNameConfig = `[${isTest && 'test-' || ''}${isTestModule && 'module' || 'client'}-rspack]`;
|
|
188
206
|
// Base client config
|
|
189
207
|
let clientConfig = {
|
|
190
|
-
name:
|
|
208
|
+
name: clientNameConfig,
|
|
191
209
|
target: 'web',
|
|
192
210
|
mode,
|
|
193
211
|
entry: path.resolve(process.cwd(), buildContext, entryPath),
|
|
@@ -221,28 +239,12 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
221
239
|
resolve: { extensions, alias },
|
|
222
240
|
externals,
|
|
223
241
|
plugins: [
|
|
224
|
-
...
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
filePath: path.join(buildContext, runPath),
|
|
231
|
-
...(Meteor.isBlazeEnabled && {
|
|
232
|
-
externals: /\.html$/,
|
|
233
|
-
externalMap: (module) => {
|
|
234
|
-
const { request, context } = module;
|
|
235
|
-
if (request.endsWith('.html')) {
|
|
236
|
-
const relContext = path.relative(process.cwd(), context);
|
|
237
|
-
const { name } = path.parse(request);
|
|
238
|
-
return `./${relContext}/template.${name}.js`;
|
|
239
|
-
}
|
|
240
|
-
return request;
|
|
241
|
-
},
|
|
242
|
-
}),
|
|
243
|
-
}),
|
|
244
|
-
].filter(Boolean)
|
|
245
|
-
: []),
|
|
242
|
+
...[
|
|
243
|
+
...(isReactEnabled && reactRefreshModule
|
|
244
|
+
? [new reactRefreshModule()]
|
|
245
|
+
: []),
|
|
246
|
+
requireExternalsPlugin,
|
|
247
|
+
].filter(Boolean),
|
|
246
248
|
new DefinePlugin({
|
|
247
249
|
'Meteor.isClient': JSON.stringify(true),
|
|
248
250
|
'Meteor.isServer': JSON.stringify(false),
|
|
@@ -271,9 +273,10 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
271
273
|
}),
|
|
272
274
|
};
|
|
273
275
|
|
|
276
|
+
const serverNameConfig = `[${isTest && 'test-' || ''}${isTestModule && 'module' || 'server'}-rspack]`;
|
|
274
277
|
// Base server config
|
|
275
278
|
let serverConfig = {
|
|
276
|
-
name:
|
|
279
|
+
name: serverNameConfig,
|
|
277
280
|
target: 'node',
|
|
278
281
|
mode,
|
|
279
282
|
entry: path.resolve(process.cwd(), buildContext, entryPath),
|
|
@@ -287,6 +290,12 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
287
290
|
optimization: { usedExports: true },
|
|
288
291
|
module: {
|
|
289
292
|
rules: [swcConfigRule, ...extraRules],
|
|
293
|
+
parser: {
|
|
294
|
+
javascript: {
|
|
295
|
+
// Dynamic imports on the server are treated as bundled in the same chunk
|
|
296
|
+
dynamicImportMode: 'eager',
|
|
297
|
+
},
|
|
298
|
+
},
|
|
290
299
|
},
|
|
291
300
|
resolve: {
|
|
292
301
|
extensions,
|
|
@@ -307,6 +316,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
307
316
|
banner: bannerOutput,
|
|
308
317
|
entryOnly: true,
|
|
309
318
|
}),
|
|
319
|
+
isTestModule && requireExternalsPlugin,
|
|
310
320
|
],
|
|
311
321
|
watchOptions,
|
|
312
322
|
devtool: isRun ? 'source-map' : 'hidden-source-map',
|