From 275ce4dde4e44ca39d78085990afe1685f4828fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 10 Nov 2025 17:23:23 +0100 Subject: [PATCH] test the new rspack.config.override. config to apply overrides against all config --- .../monorepo/app/plugins/CustomConsoleLogPlugin.js | 14 ++++++++++++++ .../apps/monorepo/app/rspack.config.override.cjs | 10 ++++++++++ .../react-router/plugins/CustomConsoleLogPlugin.js | 14 ++++++++++++++ .../apps/react-router/rspack.config.override.js | 10 ++++++++++ tools/modern-tests/monorepo.test.js | 14 +++++++++++++- tools/modern-tests/react-router.test.js | 6 ++++++ 6 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tools/modern-tests/apps/monorepo/app/plugins/CustomConsoleLogPlugin.js create mode 100644 tools/modern-tests/apps/monorepo/app/rspack.config.override.cjs create mode 100644 tools/modern-tests/apps/react-router/plugins/CustomConsoleLogPlugin.js create mode 100644 tools/modern-tests/apps/react-router/rspack.config.override.js diff --git a/tools/modern-tests/apps/monorepo/app/plugins/CustomConsoleLogPlugin.js b/tools/modern-tests/apps/monorepo/app/plugins/CustomConsoleLogPlugin.js new file mode 100644 index 0000000000..0e8abd4037 --- /dev/null +++ b/tools/modern-tests/apps/monorepo/app/plugins/CustomConsoleLogPlugin.js @@ -0,0 +1,14 @@ +// CustomConsoleLogPlugin.js +class CustomConsoleLogPlugin { + apply(compiler) { + compiler.hooks.beforeRun.tap('CustomConsoleLogPlugin', (compilation) => { + console.log('👉 [CustomConsoleLogPlugin] Build is starting...'); + }); + + compiler.hooks.done.tap('CustomConsoleLogPlugin', (stats) => { + console.log('✅ [CustomConsoleLogPlugin] Build finished successfully!'); + }); + } +} + +module.exports = CustomConsoleLogPlugin; diff --git a/tools/modern-tests/apps/monorepo/app/rspack.config.override.cjs b/tools/modern-tests/apps/monorepo/app/rspack.config.override.cjs new file mode 100644 index 0000000000..a4f160b843 --- /dev/null +++ b/tools/modern-tests/apps/monorepo/app/rspack.config.override.cjs @@ -0,0 +1,10 @@ +const { defineConfig } = require("@meteorjs/rspack"); +const CustomConsoleLogPlugin = require('./plugins/CustomConsoleLogPlugin') + +module.exports = defineConfig((Meteor) => { + return { + plugins: [ + new CustomConsoleLogPlugin() + ], + }; +}); diff --git a/tools/modern-tests/apps/react-router/plugins/CustomConsoleLogPlugin.js b/tools/modern-tests/apps/react-router/plugins/CustomConsoleLogPlugin.js new file mode 100644 index 0000000000..0e8abd4037 --- /dev/null +++ b/tools/modern-tests/apps/react-router/plugins/CustomConsoleLogPlugin.js @@ -0,0 +1,14 @@ +// CustomConsoleLogPlugin.js +class CustomConsoleLogPlugin { + apply(compiler) { + compiler.hooks.beforeRun.tap('CustomConsoleLogPlugin', (compilation) => { + console.log('👉 [CustomConsoleLogPlugin] Build is starting...'); + }); + + compiler.hooks.done.tap('CustomConsoleLogPlugin', (stats) => { + console.log('✅ [CustomConsoleLogPlugin] Build finished successfully!'); + }); + } +} + +module.exports = CustomConsoleLogPlugin; diff --git a/tools/modern-tests/apps/react-router/rspack.config.override.js b/tools/modern-tests/apps/react-router/rspack.config.override.js new file mode 100644 index 0000000000..a4f160b843 --- /dev/null +++ b/tools/modern-tests/apps/react-router/rspack.config.override.js @@ -0,0 +1,10 @@ +const { defineConfig } = require("@meteorjs/rspack"); +const CustomConsoleLogPlugin = require('./plugins/CustomConsoleLogPlugin') + +module.exports = defineConfig((Meteor) => { + return { + plugins: [ + new CustomConsoleLogPlugin() + ], + }; +}); diff --git a/tools/modern-tests/monorepo.test.js b/tools/modern-tests/monorepo.test.js index e19f368e81..27ae70ac87 100644 --- a/tools/modern-tests/monorepo.test.js +++ b/tools/modern-tests/monorepo.test.js @@ -23,14 +23,26 @@ describe('Monorepo App Bundling /', () => { ], configFile: 'rspack.config.cjs', customAssertions: { + afterRun: async ({ result }) => { + // Check custom plugin gets loaded from rspack.config.override.cjs file + await waitForMeteorOutput(result.outputLines, /.*CustomConsoleLogPlugin.*/); + }, afterRunRebuildClient: async ({ allConsoleLogs }) => { - // Check for HMR output as enabled by default + // Check custom plugin gets loaded from rspack.config.override.cjs file await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:.*/); }, afterRunProductionRebuildClient: async ({ allConsoleLogs }) => { // Check for HMR to not be enabled in production-like mode await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:*/, { negate: true }); }, + afterTest: async ({ result }) => { + // Check custom plugin gets loaded from rspack.config.override.cjs file + await waitForMeteorOutput(result.outputLines, /.*CustomConsoleLogPlugin.*/); + }, + afterBuild: async ({ result }) => { + // Check custom plugin gets loaded from rspack.config.override.cjs file + await waitForMeteorOutput(result.outputLines, /.*CustomConsoleLogPlugin.*/); + }, } })); }); diff --git a/tools/modern-tests/react-router.test.js b/tools/modern-tests/react-router.test.js index d2c7919ada..db2473bf33 100644 --- a/tools/modern-tests/react-router.test.js +++ b/tools/modern-tests/react-router.test.js @@ -53,6 +53,8 @@ describe('ReactRouter App Bundling /', () => { await waitForMeteorOutput(result.outputLines, /.*custom-package loaded.*/); // resolve.extensions loading await waitForMeteorOutput(result.outputLines, /.*first\.jsx loaded.*/); + // Check custom plugin gets loaded from rspack.config.override.js file + await waitForMeteorOutput(result.outputLines, /.*CustomConsoleLogPlugin.*/); }, afterRunRebuildClient: async ({ allConsoleLogs }) => { // Check for HMR output as enabled by default @@ -81,6 +83,8 @@ describe('ReactRouter App Bundling /', () => { }, afterTest: async ({ result }) => { await waitForReactEnvs(result.outputLines); + // Check custom plugin gets loaded from rspack.config.override.js file + await waitForMeteorOutput(result.outputLines, /.*CustomConsoleLogPlugin.*/); }, afterTestOnce: async ({ result }) => { await waitForReactEnvs(result.outputLines); @@ -88,6 +92,8 @@ describe('ReactRouter App Bundling /', () => { afterBuild: async ({ result }) => { await waitForReactEnvs(result.outputLines, { isTsxEnabled: true }); await waitForMeteorOutput(result.outputLines, /.*babel-plugin-react-compiler.*/); + // Check custom plugin gets loaded from rspack.config.override.js file + await waitForMeteorOutput(result.outputLines, /.*CustomConsoleLogPlugin.*/); }, } }));