@meteorjs/rspack 1.1.0-beta.2 → 1.1.0-beta.4
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 +20 -4
- package/package.json +1 -1
- package/rspack.config.js +8 -14
package/lib/test.js
CHANGED
|
@@ -9,6 +9,7 @@ const { createIgnoreRegex, createIgnoreGlobConfig } = require("./ignore.js");
|
|
|
9
9
|
* @param {string} options.projectDir - The project directory
|
|
10
10
|
* @param {string} options.buildContext - The build context
|
|
11
11
|
* @param {string[]} options.ignoreEntries - Array of ignore patterns
|
|
12
|
+
* @param {string[]} options.meteorIgnoreEntries - Array of meteor ignore patterns
|
|
12
13
|
* @param {string} options.extraEntry - Extra entry to load
|
|
13
14
|
* @returns {string} The path to the generated file
|
|
14
15
|
*/
|
|
@@ -17,6 +18,7 @@ const generateEagerTestFile = ({
|
|
|
17
18
|
projectDir,
|
|
18
19
|
buildContext,
|
|
19
20
|
ignoreEntries: inIgnoreEntries = [],
|
|
21
|
+
meteorIgnoreEntries: inMeteorIgnoreEntries = [],
|
|
20
22
|
prefix: inPrefix = '',
|
|
21
23
|
extraEntry,
|
|
22
24
|
globalImportPath,
|
|
@@ -40,6 +42,10 @@ const generateEagerTestFile = ({
|
|
|
40
42
|
const excludeFoldersRegex = createIgnoreRegex(
|
|
41
43
|
createIgnoreGlobConfig(ignoreEntries)
|
|
42
44
|
);
|
|
45
|
+
// Create regex from meteor ignore entries
|
|
46
|
+
const excludeMeteorIgnoreRegex = createIgnoreRegex(
|
|
47
|
+
createIgnoreGlobConfig(inMeteorIgnoreEntries)
|
|
48
|
+
);
|
|
43
49
|
|
|
44
50
|
const prefix = (inPrefix && `${inPrefix}-`) || "";
|
|
45
51
|
const filename = isAppTest
|
|
@@ -51,15 +57,25 @@ const generateEagerTestFile = ({
|
|
|
51
57
|
: "/\\.(?:test|spec)s?\\.[^.]+$/";
|
|
52
58
|
|
|
53
59
|
const content = `${
|
|
54
|
-
globalImportPath ? `import '${globalImportPath}';\n\n` :
|
|
55
|
-
}
|
|
56
|
-
const
|
|
60
|
+
globalImportPath ? `import '${globalImportPath}';\n\n` : ""
|
|
61
|
+
}
|
|
62
|
+
const MeteorIgnoreRegex = ${excludeMeteorIgnoreRegex.toString()};
|
|
63
|
+
{
|
|
64
|
+
const ctx = import.meta.webpackContext('${projectDir}', {
|
|
57
65
|
recursive: true,
|
|
58
66
|
regExp: ${regExp},
|
|
59
67
|
exclude: ${excludeFoldersRegex.toString()},
|
|
60
68
|
mode: 'eager',
|
|
61
69
|
});
|
|
62
|
-
ctx.keys().
|
|
70
|
+
ctx.keys().filter((k) => {
|
|
71
|
+
// Make the check strictly relative to the context root.
|
|
72
|
+
// If k is absolute and starts with root, strip it; if it's already relative, leave it.
|
|
73
|
+
const rel = k.startsWith('${projectDir}') ? k.slice(${
|
|
74
|
+
projectDir.length
|
|
75
|
+
}) : k.replace(/^\\.\\//, '');
|
|
76
|
+
// Only exclude based on *relative* path segments.
|
|
77
|
+
return !MeteorIgnoreRegex.test(rel);
|
|
78
|
+
}).forEach(ctx);
|
|
63
79
|
${
|
|
64
80
|
extraEntry
|
|
65
81
|
? `const extra = import.meta.webpackContext('${path.dirname(
|
package/package.json
CHANGED
package/rspack.config.js
CHANGED
|
@@ -434,7 +434,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
434
434
|
isAppTest: true,
|
|
435
435
|
projectDir,
|
|
436
436
|
buildContext,
|
|
437
|
-
ignoreEntries: [
|
|
437
|
+
ignoreEntries: ["**/server/**"],
|
|
438
|
+
meteorIgnoreEntries,
|
|
438
439
|
prefix: "client",
|
|
439
440
|
extraEntry: path.resolve(process.cwd(), Meteor.mainClientEntry),
|
|
440
441
|
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
@@ -445,18 +446,14 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
445
446
|
isClient: true,
|
|
446
447
|
projectDir,
|
|
447
448
|
buildContext,
|
|
448
|
-
ignoreEntries: [
|
|
449
|
+
ignoreEntries: ["**/server/**"],
|
|
450
|
+
meteorIgnoreEntries,
|
|
449
451
|
prefix: "client",
|
|
450
452
|
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
451
453
|
})
|
|
452
454
|
: isClient && isTest && testEntry
|
|
453
455
|
? path.resolve(process.cwd(), testEntry)
|
|
454
456
|
: path.resolve(process.cwd(), buildContext, entryPath);
|
|
455
|
-
console.log(
|
|
456
|
-
"--> (rspack.config.js-Line: 431)\n clientEntry: ",
|
|
457
|
-
clientEntry,
|
|
458
|
-
entryPath
|
|
459
|
-
);
|
|
460
457
|
const clientNameConfig = `[${(isTest && 'test-') || ''}client-rspack]`;
|
|
461
458
|
// Base client config
|
|
462
459
|
let clientConfig = {
|
|
@@ -560,7 +557,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
560
557
|
isAppTest: true,
|
|
561
558
|
projectDir,
|
|
562
559
|
buildContext,
|
|
563
|
-
ignoreEntries: [
|
|
560
|
+
ignoreEntries: ["**/client/**"],
|
|
561
|
+
meteorIgnoreEntries,
|
|
564
562
|
prefix: "server",
|
|
565
563
|
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
566
564
|
})
|
|
@@ -569,7 +567,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
569
567
|
isAppTest: false,
|
|
570
568
|
projectDir,
|
|
571
569
|
buildContext,
|
|
572
|
-
ignoreEntries: [
|
|
570
|
+
ignoreEntries: ["**/client/**"],
|
|
571
|
+
meteorIgnoreEntries,
|
|
573
572
|
prefix: "server",
|
|
574
573
|
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
575
574
|
})
|
|
@@ -577,11 +576,6 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
577
576
|
? path.resolve(process.cwd(), testEntry)
|
|
578
577
|
: path.resolve(projectDir, buildContext, entryPath);
|
|
579
578
|
const serverNameConfig = `[${(isTest && 'test-') || ''}server-rspack]`;
|
|
580
|
-
console.log(
|
|
581
|
-
"--> (rspack.config.js-Line: 576)\n serverEntry: ",
|
|
582
|
-
serverEntry,
|
|
583
|
-
entryPath
|
|
584
|
-
);
|
|
585
579
|
// Base server config
|
|
586
580
|
let serverConfig = {
|
|
587
581
|
name: serverNameConfig,
|