@meteorjs/rspack 1.1.0-beta.1 → 1.1.0-beta.2
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 +14 -11
- package/package.json +1 -1
- package/rspack.config.js +20 -6
package/lib/test.js
CHANGED
|
@@ -13,13 +13,14 @@ const { createIgnoreRegex, createIgnoreGlobConfig } = require("./ignore.js");
|
|
|
13
13
|
* @returns {string} The path to the generated file
|
|
14
14
|
*/
|
|
15
15
|
const generateEagerTestFile = ({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
isAppTest,
|
|
17
|
+
projectDir,
|
|
18
|
+
buildContext,
|
|
19
|
+
ignoreEntries: inIgnoreEntries = [],
|
|
20
|
+
prefix: inPrefix = '',
|
|
21
|
+
extraEntry,
|
|
22
|
+
globalImportPath,
|
|
23
|
+
}) => {
|
|
23
24
|
const distDir = path.resolve(projectDir, ".meteor/local/test");
|
|
24
25
|
if (!fs.existsSync(distDir)) {
|
|
25
26
|
fs.mkdirSync(distDir, { recursive: true });
|
|
@@ -49,7 +50,9 @@ const generateEagerTestFile = ({
|
|
|
49
50
|
? "/\\.app-(?:test|spec)s?\\.[^.]+$/"
|
|
50
51
|
: "/\\.(?:test|spec)s?\\.[^.]+$/";
|
|
51
52
|
|
|
52
|
-
const content =
|
|
53
|
+
const content = `${
|
|
54
|
+
globalImportPath ? `import '${globalImportPath}';\n\n` : ''
|
|
55
|
+
}{
|
|
53
56
|
const ctx = import.meta.webpackContext('/', {
|
|
54
57
|
recursive: true,
|
|
55
58
|
regExp: ${regExp},
|
|
@@ -60,14 +63,14 @@ const generateEagerTestFile = ({
|
|
|
60
63
|
${
|
|
61
64
|
extraEntry
|
|
62
65
|
? `const extra = import.meta.webpackContext('${path.dirname(
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
extraEntry
|
|
67
|
+
)}', {
|
|
65
68
|
recursive: false,
|
|
66
69
|
regExp: ${new RegExp(`${path.basename(extraEntry)}$`).toString()},
|
|
67
70
|
mode: 'eager',
|
|
68
71
|
});
|
|
69
72
|
extra.keys().forEach(extra);`
|
|
70
|
-
:
|
|
73
|
+
: ""
|
|
71
74
|
}
|
|
72
75
|
}`;
|
|
73
76
|
|
package/package.json
CHANGED
package/rspack.config.js
CHANGED
|
@@ -429,7 +429,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
429
429
|
const lazyCompilationConfig = { lazyCompilation: false };
|
|
430
430
|
|
|
431
431
|
const clientEntry =
|
|
432
|
-
isTest && isTestEager && isTestFullApp
|
|
432
|
+
isClient && isTest && isTestEager && isTestFullApp
|
|
433
433
|
? generateEagerTestFile({
|
|
434
434
|
isAppTest: true,
|
|
435
435
|
projectDir,
|
|
@@ -437,8 +437,9 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
437
437
|
ignoreEntries: [...meteorIgnoreEntries, "**/server/**"],
|
|
438
438
|
prefix: "client",
|
|
439
439
|
extraEntry: path.resolve(process.cwd(), Meteor.mainClientEntry),
|
|
440
|
+
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
440
441
|
})
|
|
441
|
-
: isTest && isTestEager
|
|
442
|
+
: isClient && isTest && isTestEager
|
|
442
443
|
? generateEagerTestFile({
|
|
443
444
|
isAppTest: false,
|
|
444
445
|
isClient: true,
|
|
@@ -446,10 +447,16 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
446
447
|
buildContext,
|
|
447
448
|
ignoreEntries: [...meteorIgnoreEntries, "**/server/**"],
|
|
448
449
|
prefix: "client",
|
|
450
|
+
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
449
451
|
})
|
|
450
|
-
: isTest && testEntry
|
|
452
|
+
: isClient && isTest && testEntry
|
|
451
453
|
? path.resolve(process.cwd(), testEntry)
|
|
452
454
|
: path.resolve(process.cwd(), buildContext, entryPath);
|
|
455
|
+
console.log(
|
|
456
|
+
"--> (rspack.config.js-Line: 431)\n clientEntry: ",
|
|
457
|
+
clientEntry,
|
|
458
|
+
entryPath
|
|
459
|
+
);
|
|
453
460
|
const clientNameConfig = `[${(isTest && 'test-') || ''}client-rspack]`;
|
|
454
461
|
// Base client config
|
|
455
462
|
let clientConfig = {
|
|
@@ -548,26 +555,33 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
548
555
|
};
|
|
549
556
|
|
|
550
557
|
const serverEntry =
|
|
551
|
-
isTest && isTestEager && isTestFullApp
|
|
558
|
+
isServer && isTest && isTestEager && isTestFullApp
|
|
552
559
|
? generateEagerTestFile({
|
|
553
560
|
isAppTest: true,
|
|
554
561
|
projectDir,
|
|
555
562
|
buildContext,
|
|
556
563
|
ignoreEntries: [...meteorIgnoreEntries, "**/client/**"],
|
|
557
564
|
prefix: "server",
|
|
565
|
+
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
558
566
|
})
|
|
559
|
-
: isTest && isTestEager
|
|
567
|
+
: isServer && isTest && isTestEager
|
|
560
568
|
? generateEagerTestFile({
|
|
561
569
|
isAppTest: false,
|
|
562
570
|
projectDir,
|
|
563
571
|
buildContext,
|
|
564
572
|
ignoreEntries: [...meteorIgnoreEntries, "**/client/**"],
|
|
565
573
|
prefix: "server",
|
|
574
|
+
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
566
575
|
})
|
|
567
|
-
: isTest && testEntry
|
|
576
|
+
: isServer && isTest && testEntry
|
|
568
577
|
? path.resolve(process.cwd(), testEntry)
|
|
569
578
|
: path.resolve(projectDir, buildContext, entryPath);
|
|
570
579
|
const serverNameConfig = `[${(isTest && 'test-') || ''}server-rspack]`;
|
|
580
|
+
console.log(
|
|
581
|
+
"--> (rspack.config.js-Line: 576)\n serverEntry: ",
|
|
582
|
+
serverEntry,
|
|
583
|
+
entryPath
|
|
584
|
+
);
|
|
571
585
|
// Base server config
|
|
572
586
|
let serverConfig = {
|
|
573
587
|
name: serverNameConfig,
|