@meteorjs/rspack 0.0.7 → 0.0.9
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 +39 -26
package/package.json
CHANGED
package/rspack.config.js
CHANGED
|
@@ -43,7 +43,7 @@ function createCacheStrategy(mode) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// SWC loader rule (JSX/JS)
|
|
46
|
-
function createSwcConfig({ isRun, isTypescriptEnabled, isJsxEnabled, isTsxEnabled }) {
|
|
46
|
+
function createSwcConfig({ isRun, isTypescriptEnabled, isJsxEnabled, isTsxEnabled, externalHelpers }) {
|
|
47
47
|
const defaultConfig = {
|
|
48
48
|
jsc: {
|
|
49
49
|
baseUrl: process.cwd(),
|
|
@@ -60,6 +60,7 @@ function createSwcConfig({ isRun, isTypescriptEnabled, isJsxEnabled, isTsxEnable
|
|
|
60
60
|
refresh: isRun,
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
|
+
externalHelpers,
|
|
63
64
|
},
|
|
64
65
|
};
|
|
65
66
|
const customConfig = getMeteorAppSwcConfig() || {};
|
|
@@ -116,6 +117,8 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
116
117
|
const isClient = Meteor.isClient;
|
|
117
118
|
const isRun = Meteor.isRun;
|
|
118
119
|
const isReactEnabled = Meteor.isReactEnabled;
|
|
120
|
+
const isTestModule = Meteor.isTestModule;
|
|
121
|
+
const swcExternalHelpers = Meteor.swcExternalHelpers;
|
|
119
122
|
const mode = isProd ? 'production' : 'development';
|
|
120
123
|
|
|
121
124
|
const isTypescriptEnabled = Meteor.isTypescriptEnabled || false;
|
|
@@ -141,7 +144,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
141
144
|
|
|
142
145
|
// Determine output directories
|
|
143
146
|
const clientOutputDir = path.resolve(process.cwd(), 'public');
|
|
144
|
-
const serverOutputDir = path.resolve(process.cwd(), '
|
|
147
|
+
const serverOutputDir = path.resolve(process.cwd(), 'private');
|
|
145
148
|
|
|
146
149
|
// Determine context for bundles and assets
|
|
147
150
|
const buildContext = Meteor.buildContext || '_build';
|
|
@@ -158,6 +161,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
158
161
|
isTypescriptEnabled,
|
|
159
162
|
isJsxEnabled,
|
|
160
163
|
isTsxEnabled,
|
|
164
|
+
externalHelpers: swcExternalHelpers,
|
|
161
165
|
});
|
|
162
166
|
const externals = [
|
|
163
167
|
/^meteor.*/,
|
|
@@ -185,9 +189,26 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
185
189
|
|
|
186
190
|
const reactRefreshModule = isReactEnabled ? safeRequire('@rspack/plugin-react-refresh') : null;
|
|
187
191
|
|
|
192
|
+
const requireExternalsPlugin = new RequireExternalsPlugin({
|
|
193
|
+
filePath: path.join(buildContext, runPath),
|
|
194
|
+
...(Meteor.isBlazeEnabled && {
|
|
195
|
+
externals: /\.html$/,
|
|
196
|
+
externalMap: (module) => {
|
|
197
|
+
const { request, context } = module;
|
|
198
|
+
if (request.endsWith('.html')) {
|
|
199
|
+
const relContext = path.relative(process.cwd(), context);
|
|
200
|
+
const { name } = path.parse(request);
|
|
201
|
+
return `./${relContext}/template.${name}.js`;
|
|
202
|
+
}
|
|
203
|
+
return request;
|
|
204
|
+
},
|
|
205
|
+
}),
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const clientNameConfig = `[${isTest && 'test-' || ''}${isTestModule && 'module' || 'client'}-rspack]`;
|
|
188
209
|
// Base client config
|
|
189
210
|
let clientConfig = {
|
|
190
|
-
name:
|
|
211
|
+
name: clientNameConfig,
|
|
191
212
|
target: 'web',
|
|
192
213
|
mode,
|
|
193
214
|
entry: path.resolve(process.cwd(), buildContext, entryPath),
|
|
@@ -221,28 +242,12 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
221
242
|
resolve: { extensions, alias },
|
|
222
243
|
externals,
|
|
223
244
|
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
|
-
: []),
|
|
245
|
+
...[
|
|
246
|
+
...(isReactEnabled && reactRefreshModule
|
|
247
|
+
? [new reactRefreshModule()]
|
|
248
|
+
: []),
|
|
249
|
+
requireExternalsPlugin,
|
|
250
|
+
].filter(Boolean),
|
|
246
251
|
new DefinePlugin({
|
|
247
252
|
'Meteor.isClient': JSON.stringify(true),
|
|
248
253
|
'Meteor.isServer': JSON.stringify(false),
|
|
@@ -271,9 +276,10 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
271
276
|
}),
|
|
272
277
|
};
|
|
273
278
|
|
|
279
|
+
const serverNameConfig = `[${isTest && 'test-' || ''}${isTestModule && 'module' || 'server'}-rspack]`;
|
|
274
280
|
// Base server config
|
|
275
281
|
let serverConfig = {
|
|
276
|
-
name:
|
|
282
|
+
name: serverNameConfig,
|
|
277
283
|
target: 'node',
|
|
278
284
|
mode,
|
|
279
285
|
entry: path.resolve(process.cwd(), buildContext, entryPath),
|
|
@@ -287,6 +293,12 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
287
293
|
optimization: { usedExports: true },
|
|
288
294
|
module: {
|
|
289
295
|
rules: [swcConfigRule, ...extraRules],
|
|
296
|
+
parser: {
|
|
297
|
+
javascript: {
|
|
298
|
+
// Dynamic imports on the server are treated as bundled in the same chunk
|
|
299
|
+
dynamicImportMode: 'eager',
|
|
300
|
+
},
|
|
301
|
+
},
|
|
290
302
|
},
|
|
291
303
|
resolve: {
|
|
292
304
|
extensions,
|
|
@@ -307,6 +319,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
307
319
|
banner: bannerOutput,
|
|
308
320
|
entryOnly: true,
|
|
309
321
|
}),
|
|
322
|
+
isTestModule && requireExternalsPlugin,
|
|
310
323
|
],
|
|
311
324
|
watchOptions,
|
|
312
325
|
devtool: isRun ? 'source-map' : 'hidden-source-map',
|