@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 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 ctx = import.meta.webpackContext('/', {
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().forEach(ctx);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteorjs/rspack",
3
- "version": "1.1.0-beta.2",
3
+ "version": "1.1.0-beta.4",
4
4
  "description": "Configuration logic for using Rspack in Meteor projects",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
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: [...meteorIgnoreEntries, "**/server/**"],
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: [...meteorIgnoreEntries, "**/server/**"],
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: [...meteorIgnoreEntries, "**/client/**"],
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: [...meteorIgnoreEntries, "**/client/**"],
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,