@meteorjs/rspack 1.1.0-beta.2 → 1.1.0-beta.3
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 -4
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,7 +446,8 @@ 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
|
})
|
|
@@ -560,7 +562,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
560
562
|
isAppTest: true,
|
|
561
563
|
projectDir,
|
|
562
564
|
buildContext,
|
|
563
|
-
ignoreEntries: [
|
|
565
|
+
ignoreEntries: ["**/client/**"],
|
|
566
|
+
meteorIgnoreEntries,
|
|
564
567
|
prefix: "server",
|
|
565
568
|
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
566
569
|
})
|
|
@@ -569,7 +572,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
569
572
|
isAppTest: false,
|
|
570
573
|
projectDir,
|
|
571
574
|
buildContext,
|
|
572
|
-
ignoreEntries: [
|
|
575
|
+
ignoreEntries: ["**/client/**"],
|
|
576
|
+
meteorIgnoreEntries,
|
|
573
577
|
prefix: "server",
|
|
574
578
|
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
|
575
579
|
})
|