diff --git a/npm-packages/meteor-rspack/lib/ignore.js b/npm-packages/meteor-rspack/lib/ignore.js index 17058cce19..7abc3ba959 100644 --- a/npm-packages/meteor-rspack/lib/ignore.js +++ b/npm-packages/meteor-rspack/lib/ignore.js @@ -117,7 +117,7 @@ function createIgnoreRegex(globPatterns) { // For absolute paths, we don't want to force the pattern to match from the beginning // but we still want to ensure it matches to the end of the path segment - regexPattern = '(?:^|/)' + regexPattern + '$'; + regexPattern = '(?:^|/)' + regexPattern; return regexPattern; }).filter(pattern => pattern !== null); diff --git a/npm-packages/meteor-rspack/lib/test.js b/npm-packages/meteor-rspack/lib/test.js index e35c7e17dc..6ea5a04cf4 100644 --- a/npm-packages/meteor-rspack/lib/test.js +++ b/npm-packages/meteor-rspack/lib/test.js @@ -9,6 +9,7 @@ const { createIgnoreRegex, createIgnoreGlobConfig } = require("./ignore.js"); * @param {string} options.projectDir - The project directory * @param {string} options.buildContext - The build context * @param {string[]} options.ignoreEntries - Array of ignore patterns + * @param {string[]} options.meteorIgnoreEntries - Array of meteor ignore patterns * @param {string} options.extraEntry - Extra entry to load * @returns {string} The path to the generated file */ @@ -17,6 +18,7 @@ const generateEagerTestFile = ({ projectDir, buildContext, ignoreEntries: inIgnoreEntries = [], + meteorIgnoreEntries: inMeteorIgnoreEntries = [], prefix: inPrefix = '', extraEntry, globalImportPath, @@ -40,6 +42,11 @@ const generateEagerTestFile = ({ const excludeFoldersRegex = createIgnoreRegex( createIgnoreGlobConfig(ignoreEntries) ); + console.log("inMeteorIgnoreEntries", inMeteorIgnoreEntries); + // Create regex from meteor ignore entries + const excludeMeteorIgnoreRegex = inMeteorIgnoreEntries.length > 0 + ? createIgnoreRegex(createIgnoreGlobConfig(inMeteorIgnoreEntries)) + : null; const prefix = (inPrefix && `${inPrefix}-`) || ""; const filename = isAppTest @@ -51,15 +58,27 @@ const generateEagerTestFile = ({ : "/\\.(?:test|spec)s?\\.[^.]+$/"; const content = `${ - globalImportPath ? `import '${globalImportPath}';\n\n` : '' - }{ - const ctx = import.meta.webpackContext('/', { + globalImportPath ? `import '${globalImportPath}';\n\n` : "" + }${ + excludeMeteorIgnoreRegex + ? `const MeteorIgnoreRegex = ${excludeMeteorIgnoreRegex.toString()};` + : "" + } +{ + const ctx = import.meta.webpackContext('${projectDir}', { recursive: true, regExp: ${regExp}, exclude: ${excludeFoldersRegex.toString()}, mode: 'eager', }); - ctx.keys().forEach(ctx); + ctx.keys().filter((k) => { + ${ + excludeMeteorIgnoreRegex + ? `// Only exclude based on *relative* path segments. + return !MeteorIgnoreRegex.test(k);` + : "return true;" + } + }).forEach(ctx); ${ extraEntry ? `const extra = import.meta.webpackContext('${path.dirname( diff --git a/npm-packages/meteor-rspack/package-lock.json b/npm-packages/meteor-rspack/package-lock.json index cf2ece90f6..4b2c4e1836 100644 --- a/npm-packages/meteor-rspack/package-lock.json +++ b/npm-packages/meteor-rspack/package-lock.json @@ -1,12 +1,12 @@ { "name": "@meteorjs/rspack", - "version": "1.1.0-beta.2", + "version": "1.1.0-beta.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@meteorjs/rspack", - "version": "1.1.0-beta.2", + "version": "1.1.0-beta.6", "license": "ISC", "dependencies": { "fast-deep-equal": "^3.1.3", diff --git a/npm-packages/meteor-rspack/package.json b/npm-packages/meteor-rspack/package.json index 1306b93e26..71b4960bb7 100644 --- a/npm-packages/meteor-rspack/package.json +++ b/npm-packages/meteor-rspack/package.json @@ -1,6 +1,6 @@ { "name": "@meteorjs/rspack", - "version": "1.1.0-beta.2", + "version": "1.1.0-beta.6", "description": "Configuration logic for using Rspack in Meteor projects", "main": "index.js", "type": "commonjs", diff --git a/npm-packages/meteor-rspack/rspack.config.js b/npm-packages/meteor-rspack/rspack.config.js index 2c7db4b8f8..4e92ad24d4 100644 --- a/npm-packages/meteor-rspack/rspack.config.js +++ b/npm-packages/meteor-rspack/rspack.config.js @@ -434,7 +434,8 @@ module.exports = async function (inMeteor = {}, argv = {}) { isAppTest: true, projectDir, buildContext, - ignoreEntries: [...meteorIgnoreEntries, "**/server/**"], + ignoreEntries: ["**/server/**"], + meteorIgnoreEntries, prefix: "client", extraEntry: path.resolve(process.cwd(), Meteor.mainClientEntry), globalImportPath: path.resolve(projectDir, buildContext, entryPath), @@ -445,7 +446,8 @@ module.exports = async function (inMeteor = {}, argv = {}) { isClient: true, projectDir, buildContext, - ignoreEntries: [...meteorIgnoreEntries, "**/server/**"], + ignoreEntries: ["**/server/**"], + meteorIgnoreEntries, prefix: "client", globalImportPath: path.resolve(projectDir, buildContext, entryPath), }) @@ -555,7 +557,8 @@ module.exports = async function (inMeteor = {}, argv = {}) { isAppTest: true, projectDir, buildContext, - ignoreEntries: [...meteorIgnoreEntries, "**/client/**"], + ignoreEntries: ["**/client/**"], + meteorIgnoreEntries, prefix: "server", globalImportPath: path.resolve(projectDir, buildContext, entryPath), }) @@ -564,7 +567,8 @@ module.exports = async function (inMeteor = {}, argv = {}) { isAppTest: false, projectDir, buildContext, - ignoreEntries: [...meteorIgnoreEntries, "**/client/**"], + ignoreEntries: ["**/client/**"], + meteorIgnoreEntries, prefix: "server", globalImportPath: path.resolve(projectDir, buildContext, entryPath), }) diff --git a/packages/rspack/lib/constants.js b/packages/rspack/lib/constants.js index 3a16c20419..c9073b740d 100644 --- a/packages/rspack/lib/constants.js +++ b/packages/rspack/lib/constants.js @@ -5,7 +5,7 @@ export const DEFAULT_RSPACK_VERSION = '1.7.1'; -export const DEFAULT_METEOR_RSPACK_VERSION = '1.1.0-beta.2'; +export const DEFAULT_METEOR_RSPACK_VERSION = '1.1.0-beta.6'; export const DEFAULT_METEOR_RSPACK_REACT_HMR_VERSION = '1.4.3'; diff --git a/tools/modern-tests/apps/react-router/.meteorignore b/tools/modern-tests/apps/react-router/.meteorignore new file mode 100644 index 0000000000..269a4e9cc4 --- /dev/null +++ b/tools/modern-tests/apps/react-router/.meteorignore @@ -0,0 +1,16 @@ +# Folder combination patterns +react-router* +tests/ignored/react-router*-ignored +tests/ignored/folder-to-ignored/ +tests/ignored/file-to-ignored.app-test.js +**/glob-ignored/*.app-test.js +tests/ignored/prefix-*-ignored +tests/ignored/*-ignored-suffix + +# File combination patterns +tests/ignored/specific-file-ignored.app-test.js +tests/ignored/*.temp-ignored.app-test.js +**/unit/*.app-test.js +tests/ignored/integration/*-ignored.app-test.js +tests/ignored/test-*-ignored.app-test.js +!important.app-test.js diff --git a/tools/modern-tests/apps/react-router/important.app-test.js b/tools/modern-tests/apps/react-router/important.app-test.js new file mode 100644 index 0000000000..a9cb841908 --- /dev/null +++ b/tools/modern-tests/apps/react-router/important.app-test.js @@ -0,0 +1,7 @@ +import assert from "assert"; + +describe("!important.app-test.js pattern", () => { + it("should run as it's not ignored (negation)", () => { + assert(true, "should run"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/react-router-wxyz-ignored/ignore.app-test.js b/tools/modern-tests/apps/react-router/react-router-wxyz-ignored/ignore.app-test.js new file mode 100644 index 0000000000..bf67b299e7 --- /dev/null +++ b/tools/modern-tests/apps/react-router/react-router-wxyz-ignored/ignore.app-test.js @@ -0,0 +1,5 @@ +describe("react-router*-ignored pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/file-to-ignored.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/file-to-ignored.app-test.js new file mode 100644 index 0000000000..c67d43d5d9 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/file-to-ignored.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/file-to-ignored.app-test.js pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/folder-to-ignored/ignore.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/folder-to-ignored/ignore.app-test.js new file mode 100644 index 0000000000..5878c51755 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/folder-to-ignored/ignore.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/folder-to-ignored/ pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/integration/test-ignored.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/integration/test-ignored.app-test.js new file mode 100644 index 0000000000..6c85dda4f6 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/integration/test-ignored.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/integration/*-ignored.app-test.js pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/prefix-test-ignored/ignore.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/prefix-test-ignored/ignore.app-test.js new file mode 100644 index 0000000000..a8a1c30c5a --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/prefix-test-ignored/ignore.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/prefix-*-ignored pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/react-router-wxyz-ignored/ignore.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/react-router-wxyz-ignored/ignore.app-test.js new file mode 100644 index 0000000000..217570f7b1 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/react-router-wxyz-ignored/ignore.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/react-router*-ignored pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/some-test-ignored-suffix/ignore.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/some-test-ignored-suffix/ignore.app-test.js new file mode 100644 index 0000000000..ad7167d7c5 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/some-test-ignored-suffix/ignore.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/*-ignored-suffix pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/some/nested/glob-ignored/ignore.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/some/nested/glob-ignored/ignore.app-test.js new file mode 100644 index 0000000000..403124d0b5 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/some/nested/glob-ignored/ignore.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/some/nested/glob-ignored/ignore.app-test.js pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/some/unit/test-ignored.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/some/unit/test-ignored.app-test.js new file mode 100644 index 0000000000..3d8cab2346 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/some/unit/test-ignored.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/some/unit/test-ignored.app-test.js pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/specific-file-ignored.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/specific-file-ignored.app-test.js new file mode 100644 index 0000000000..4eda02edf5 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/specific-file-ignored.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/specific-file-ignored.app-test.js pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/test-example-ignored.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/test-example-ignored.app-test.js new file mode 100644 index 0000000000..9fdbbda403 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/test-example-ignored.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/test-*-ignored.app-test.js pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +}); diff --git a/tools/modern-tests/apps/react-router/tests/ignored/test.temp-ignored.app-test.js b/tools/modern-tests/apps/react-router/tests/ignored/test.temp-ignored.app-test.js new file mode 100644 index 0000000000..72d4d3d0e1 --- /dev/null +++ b/tools/modern-tests/apps/react-router/tests/ignored/test.temp-ignored.app-test.js @@ -0,0 +1,5 @@ +describe("tests/ignored/*.temp-ignored.app-test.js pattern", () => { + it("should not run as ignored", () => { + throw new Error("test should be ignored by eager test loading"); + }); +});