@meteorjs/rspack 1.0.0 → 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 -12
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
|
@@ -230,8 +230,6 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
230
230
|
const projectConfigPath = Meteor.projectConfigPath || path.resolve(projectDir, 'rspack.config.js');
|
|
231
231
|
const configPath = Meteor.configPath;
|
|
232
232
|
const testEntry = Meteor.testEntry;
|
|
233
|
-
const testClientEntry = Meteor.testClientEntry;
|
|
234
|
-
const testServerEntry = Meteor.testServerEntry;
|
|
235
233
|
|
|
236
234
|
const isTypescriptEnabled = Meteor.isTypescriptEnabled || false;
|
|
237
235
|
const isJsxEnabled =
|
|
@@ -431,7 +429,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
431
429
|
const lazyCompilationConfig = { lazyCompilation: false };
|
|
432
430
|
|
|
433
431
|
const clientEntry =
|
|
434
|
-
isTest && isTestEager && isTestFullApp
|
|
432
|
+
isClient && isTest && isTestEager && isTestFullApp
|
|
435
433
|
? generateEagerTestFile({
|
|
436
434
|
isAppTest: true,
|
|
437
435
|
projectDir,
|
|
@@ -439,8 +437,9 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
439
437
|
ignoreEntries: [...meteorIgnoreEntries, "**/server/**"],
|
|
440
438
|
prefix: "client",
|
|
441
439
|
extraEntry: path.resolve(process.cwd(), Meteor.mainClientEntry),
|
|
440
|
+
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
442
441
|
})
|
|
443
|
-
: isTest && isTestEager
|
|
442
|
+
: isClient && isTest && isTestEager
|
|
444
443
|
? generateEagerTestFile({
|
|
445
444
|
isAppTest: false,
|
|
446
445
|
isClient: true,
|
|
@@ -448,12 +447,16 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
448
447
|
buildContext,
|
|
449
448
|
ignoreEntries: [...meteorIgnoreEntries, "**/server/**"],
|
|
450
449
|
prefix: "client",
|
|
450
|
+
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
451
451
|
})
|
|
452
|
-
: isTest && testEntry
|
|
452
|
+
: isClient && isTest && testEntry
|
|
453
453
|
? path.resolve(process.cwd(), testEntry)
|
|
454
|
-
: isTest && testClientEntry
|
|
455
|
-
? path.resolve(process.cwd(), testClientEntry)
|
|
456
454
|
: path.resolve(process.cwd(), buildContext, entryPath);
|
|
455
|
+
console.log(
|
|
456
|
+
"--> (rspack.config.js-Line: 431)\n clientEntry: ",
|
|
457
|
+
clientEntry,
|
|
458
|
+
entryPath
|
|
459
|
+
);
|
|
457
460
|
const clientNameConfig = `[${(isTest && 'test-') || ''}client-rspack]`;
|
|
458
461
|
// Base client config
|
|
459
462
|
let clientConfig = {
|
|
@@ -552,28 +555,33 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
552
555
|
};
|
|
553
556
|
|
|
554
557
|
const serverEntry =
|
|
555
|
-
isTest && isTestEager && isTestFullApp
|
|
558
|
+
isServer && isTest && isTestEager && isTestFullApp
|
|
556
559
|
? generateEagerTestFile({
|
|
557
560
|
isAppTest: true,
|
|
558
561
|
projectDir,
|
|
559
562
|
buildContext,
|
|
560
563
|
ignoreEntries: [...meteorIgnoreEntries, "**/client/**"],
|
|
561
564
|
prefix: "server",
|
|
565
|
+
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
562
566
|
})
|
|
563
|
-
: isTest && isTestEager
|
|
567
|
+
: isServer && isTest && isTestEager
|
|
564
568
|
? generateEagerTestFile({
|
|
565
569
|
isAppTest: false,
|
|
566
570
|
projectDir,
|
|
567
571
|
buildContext,
|
|
568
572
|
ignoreEntries: [...meteorIgnoreEntries, "**/client/**"],
|
|
569
573
|
prefix: "server",
|
|
574
|
+
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
570
575
|
})
|
|
571
|
-
: isTest && testEntry
|
|
576
|
+
: isServer && isTest && testEntry
|
|
572
577
|
? path.resolve(process.cwd(), testEntry)
|
|
573
|
-
: isTest && testServerEntry
|
|
574
|
-
? path.resolve(process.cwd(), testServerEntry)
|
|
575
578
|
: path.resolve(projectDir, buildContext, entryPath);
|
|
576
579
|
const serverNameConfig = `[${(isTest && 'test-') || ''}server-rspack]`;
|
|
580
|
+
console.log(
|
|
581
|
+
"--> (rspack.config.js-Line: 576)\n serverEntry: ",
|
|
582
|
+
serverEntry,
|
|
583
|
+
entryPath
|
|
584
|
+
);
|
|
577
585
|
// Base server config
|
|
578
586
|
let serverConfig = {
|
|
579
587
|
name: serverNameConfig,
|