test the new rspack.config.override.<ext> config to apply overrides against all config

This commit is contained in:
Nacho Codoñer
2025-11-10 17:23:23 +01:00
parent 755400117c
commit 275ce4dde4
6 changed files with 67 additions and 1 deletions

View File

@@ -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;

View File

@@ -0,0 +1,10 @@
const { defineConfig } = require("@meteorjs/rspack");
const CustomConsoleLogPlugin = require('./plugins/CustomConsoleLogPlugin')
module.exports = defineConfig((Meteor) => {
return {
plugins: [
new CustomConsoleLogPlugin()
],
};
});

View File

@@ -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;

View File

@@ -0,0 +1,10 @@
const { defineConfig } = require("@meteorjs/rspack");
const CustomConsoleLogPlugin = require('./plugins/CustomConsoleLogPlugin')
module.exports = defineConfig((Meteor) => {
return {
plugins: [
new CustomConsoleLogPlugin()
],
};
});

View File

@@ -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.*/);
},
}
}));
});

View File

@@ -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.*/);
},
}
}));