@meteorjs/rspack 0.0.64 → 0.0.65
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/lib/test.js +8 -4
- package/package.json +1 -1
- package/rspack.config.js +42 -15
package/lib/test.js
CHANGED
|
@@ -8,14 +8,15 @@ const { createIgnoreRegex, createIgnoreGlobConfig } = require("./ignore.js");
|
|
|
8
8
|
* @param {boolean} options.isAppTest - Whether this is an app test
|
|
9
9
|
* @param {string} options.projectDir - The project directory
|
|
10
10
|
* @param {string} options.buildContext - The build context
|
|
11
|
-
* @param {string[]} options.
|
|
11
|
+
* @param {string[]} options.ignoreEntries - Array of ignore patterns
|
|
12
12
|
* @returns {string} The path to the generated file
|
|
13
13
|
*/
|
|
14
14
|
const generateEagerTestFile = ({
|
|
15
15
|
isAppTest,
|
|
16
16
|
projectDir,
|
|
17
17
|
buildContext,
|
|
18
|
-
|
|
18
|
+
ignoreEntries: inIgnoreEntries = [],
|
|
19
|
+
prefix: inPrefix = '',
|
|
19
20
|
}) => {
|
|
20
21
|
const distDir = path.resolve(projectDir, ".meteor/local/test");
|
|
21
22
|
if (!fs.existsSync(distDir)) {
|
|
@@ -29,7 +30,7 @@ const generateEagerTestFile = ({
|
|
|
29
30
|
"**/public/**",
|
|
30
31
|
"**/private/**",
|
|
31
32
|
`**/${buildContext}/**`,
|
|
32
|
-
...
|
|
33
|
+
...inIgnoreEntries,
|
|
33
34
|
];
|
|
34
35
|
|
|
35
36
|
// Create regex from ignore entries
|
|
@@ -37,7 +38,10 @@ const generateEagerTestFile = ({
|
|
|
37
38
|
createIgnoreGlobConfig(ignoreEntries)
|
|
38
39
|
);
|
|
39
40
|
|
|
40
|
-
const
|
|
41
|
+
const prefix = inPrefix && `${inPrefix}-` || '';
|
|
42
|
+
const filename = isAppTest
|
|
43
|
+
? `${prefix}eager-app-tests.mjs`
|
|
44
|
+
: `${prefix}eager-tests.mjs`;
|
|
41
45
|
const filePath = path.resolve(distDir, filename);
|
|
42
46
|
const regExp = isAppTest
|
|
43
47
|
? "/\\.app-(?:test|spec)s?\\.[^.]+$/"
|
package/package.json
CHANGED
package/rspack.config.js
CHANGED
|
@@ -136,7 +136,7 @@ function createSwcConfig({
|
|
|
136
136
|
return {
|
|
137
137
|
test: /\.(?:[mc]?js|jsx|[mc]?ts|tsx)$/i,
|
|
138
138
|
exclude: /node_modules|\.meteor\/local/,
|
|
139
|
-
loader:
|
|
139
|
+
loader: "builtin:swc-loader",
|
|
140
140
|
options: swcConfig,
|
|
141
141
|
};
|
|
142
142
|
}
|
|
@@ -217,6 +217,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
217
217
|
const isTestModule = !!Meteor.isTestModule;
|
|
218
218
|
const isTestEager = !!Meteor.isTestEager;
|
|
219
219
|
const isTestFullApp = !!Meteor.isTestFullApp;
|
|
220
|
+
const isTestLike = !!Meteor.isTestLike;
|
|
220
221
|
const swcExternalHelpers = !!Meteor.swcExternalHelpers;
|
|
221
222
|
const isNative = !!Meteor.isNative;
|
|
222
223
|
const mode = isProd ? 'production' : 'development';
|
|
@@ -405,15 +406,33 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
405
406
|
]
|
|
406
407
|
: [];
|
|
407
408
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
409
|
+
|
|
410
|
+
const clientEntry =
|
|
411
|
+
isTest && isTestEager && isTestFullApp
|
|
412
|
+
? generateEagerTestFile({
|
|
413
|
+
isAppTest: true,
|
|
414
|
+
projectDir,
|
|
415
|
+
buildContext,
|
|
416
|
+
ignoreEntries: [...meteorIgnoreEntries, '**/server/**'],
|
|
417
|
+
prefix: 'client',
|
|
418
|
+
})
|
|
419
|
+
: isTest && isTestEager
|
|
420
|
+
? generateEagerTestFile({
|
|
421
|
+
isAppTest: false,
|
|
422
|
+
isClient: true,
|
|
423
|
+
projectDir,
|
|
424
|
+
buildContext,
|
|
425
|
+
ignoreEntries: [...meteorIgnoreEntries, '**/server/**'],
|
|
426
|
+
prefix: 'client',
|
|
427
|
+
})
|
|
428
|
+
: path.resolve(process.cwd(), buildContext, entryPath);
|
|
429
|
+
const clientNameConfig = `[${(isTest && 'test-') || ''}client-rspack]`;
|
|
411
430
|
// Base client config
|
|
412
431
|
let clientConfig = {
|
|
413
432
|
name: clientNameConfig,
|
|
414
433
|
target: 'web',
|
|
415
434
|
mode,
|
|
416
|
-
entry:
|
|
435
|
+
entry: clientEntry,
|
|
417
436
|
output: {
|
|
418
437
|
path: clientOutputDir,
|
|
419
438
|
filename: (_module) => {
|
|
@@ -458,6 +477,15 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
458
477
|
: []),
|
|
459
478
|
...extraRules,
|
|
460
479
|
],
|
|
480
|
+
...(Meteor.isTest && {
|
|
481
|
+
parser: {
|
|
482
|
+
javascript: {
|
|
483
|
+
dynamicImportMode: 'eager',
|
|
484
|
+
dynamicImportPrefetch: true,
|
|
485
|
+
dynamicImportPreload: true
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
}),
|
|
461
489
|
},
|
|
462
490
|
resolve: { extensions, alias, fallback },
|
|
463
491
|
externals,
|
|
@@ -471,8 +499,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
471
499
|
new DefinePlugin({
|
|
472
500
|
'Meteor.isClient': JSON.stringify(true),
|
|
473
501
|
'Meteor.isServer': JSON.stringify(false),
|
|
474
|
-
'Meteor.isTest': JSON.stringify(
|
|
475
|
-
'Meteor.isAppTest': JSON.stringify(
|
|
502
|
+
'Meteor.isTest': JSON.stringify(isTestLike && !isTestFullApp),
|
|
503
|
+
'Meteor.isAppTest': JSON.stringify(isTestLike && isTestFullApp),
|
|
476
504
|
'Meteor.isDevelopment': JSON.stringify(isDev),
|
|
477
505
|
'Meteor.isProduction': JSON.stringify(isProd),
|
|
478
506
|
}),
|
|
@@ -502,26 +530,25 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
502
530
|
...merge(cacheStrategy, { experiments: { css: true } })
|
|
503
531
|
};
|
|
504
532
|
|
|
505
|
-
|
|
506
533
|
const serverEntry =
|
|
507
534
|
isTest && isTestEager && isTestFullApp
|
|
508
535
|
? generateEagerTestFile({
|
|
509
536
|
isAppTest: true,
|
|
510
537
|
projectDir,
|
|
511
538
|
buildContext,
|
|
512
|
-
|
|
539
|
+
ignoreEntries: [...meteorIgnoreEntries, '**/client/**'],
|
|
540
|
+
prefix: 'server',
|
|
513
541
|
})
|
|
514
542
|
: isTest && isTestEager
|
|
515
543
|
? generateEagerTestFile({
|
|
516
544
|
isAppTest: false,
|
|
517
545
|
projectDir,
|
|
518
546
|
buildContext,
|
|
519
|
-
|
|
547
|
+
ignoreEntries: [...meteorIgnoreEntries, '**/client/**'],
|
|
548
|
+
prefix: 'server',
|
|
520
549
|
})
|
|
521
550
|
: path.resolve(projectDir, buildContext, entryPath);
|
|
522
|
-
const serverNameConfig = `[${(isTest && 'test-') || ''}
|
|
523
|
-
(isTestModule && 'module') || 'server'
|
|
524
|
-
}-rspack]`;
|
|
551
|
+
const serverNameConfig = `[${(isTest && 'test-') || ''}server-rspack]`;
|
|
525
552
|
// Base server config
|
|
526
553
|
let serverConfig = {
|
|
527
554
|
name: serverNameConfig,
|
|
@@ -569,8 +596,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
569
596
|
: {
|
|
570
597
|
'Meteor.isClient': JSON.stringify(false),
|
|
571
598
|
'Meteor.isServer': JSON.stringify(true),
|
|
572
|
-
'Meteor.isTest': JSON.stringify(
|
|
573
|
-
'Meteor.isAppTest': JSON.stringify(
|
|
599
|
+
'Meteor.isTest': JSON.stringify(isTestLike && !isTestFullApp),
|
|
600
|
+
'Meteor.isAppTest': JSON.stringify(isTestLike && isTestFullApp),
|
|
574
601
|
'Meteor.isDevelopment': JSON.stringify(isDev),
|
|
575
602
|
'Meteor.isProduction': JSON.stringify(isProd),
|
|
576
603
|
},
|