diff --git a/npm-packages/meteor-rspack/package-lock.json b/npm-packages/meteor-rspack/package-lock.json index 21cb1b9ce4..e764ca30e3 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": "0.0.15", + "version": "0.0.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@meteorjs/rspack", - "version": "0.0.15", + "version": "0.0.17", "license": "ISC", "dependencies": { "ignore-loader": "^0.1.2", diff --git a/npm-packages/meteor-rspack/package.json b/npm-packages/meteor-rspack/package.json index 9221b253e1..eb35105d2f 100644 --- a/npm-packages/meteor-rspack/package.json +++ b/npm-packages/meteor-rspack/package.json @@ -1,6 +1,6 @@ { "name": "@meteorjs/rspack", - "version": "0.0.15", + "version": "0.0.17", "description": "Configuration logic for using Rspack in Meteor projects", "main": "index.js", "type": "module", diff --git a/npm-packages/meteor-rspack/rspack.config.js b/npm-packages/meteor-rspack/rspack.config.js index b84d1c2a10..49f550a17d 100644 --- a/npm-packages/meteor-rspack/rspack.config.js +++ b/npm-packages/meteor-rspack/rspack.config.js @@ -156,7 +156,7 @@ export default function (inMeteor = {}, argv = {}) { // Set watch options const watchOptions = { ...defaultWatchOptions, - ...isTestEager && { + ...isTest && isTestEager && { ignored: [ ...defaultWatchOptions.ignored, '**/_build/**', @@ -296,7 +296,7 @@ export default function (inMeteor = {}, argv = {}) { name: serverNameConfig, target: 'node', mode, - entry: isTestEager + entry: isTest && isTestEager ? "node_modules/@meteorjs/rspack/entries/eager-tests.js" : path.resolve(process.cwd(), buildContext, entryPath), output: { @@ -325,7 +325,7 @@ export default function (inMeteor = {}, argv = {}) { externals, plugins: [ new DefinePlugin( - isTestModule || isTestEager + isTest && (isTestModule || isTestEager) ? { "Meteor.isTest": JSON.stringify(isTest), "Meteor.isDevelopment": JSON.stringify(isDev), diff --git a/packages/rspack/lib/constants.js b/packages/rspack/lib/constants.js index fa3f5796b2..2df8bf4d82 100644 --- a/packages/rspack/lib/constants.js +++ b/packages/rspack/lib/constants.js @@ -5,7 +5,7 @@ export const DEFAULT_RSPACK_VERSION = '1.4.8'; -export const DEFAULT_METEOR_RSPACK_VERSION = '0.0.15'; +export const DEFAULT_METEOR_RSPACK_VERSION = '0.0.17'; export const DEFAULT_METEOR_RSPACK_REACT_HMR_VERSION = '1.4.3'; diff --git a/tools/modern-tests/full-blaze.test.js b/tools/modern-tests/full-blaze.test.js new file mode 100644 index 0000000000..406d626c2c --- /dev/null +++ b/tools/modern-tests/full-blaze.test.js @@ -0,0 +1,62 @@ +import { + waitForMeteorOutput, +} from "./helpers"; +import { testMeteorBundler, testMeteorRspackBundler } from './test-helpers'; + +describe('Full Blaze App Bundling /', () => { + describe('Meteor Bundler /', testMeteorBundler({ + appName: 'full-blaze', + port: 3121 + })); + + describe('Meteor+Rspack Bundler /', testMeteorRspackBundler({ + appName: 'full-blaze', + port: 3122, + filePaths: { + client: 'client/main.js', + server: 'server/main.js', + test: 'imports/api/links/methods.tests.js' + }, + customAssertions: { + afterRun: async ({ result }) => { + await waitForBlazeEnvs(result.outputLines); + }, + afterRunRebuildClient: async ({ allConsoleLogs }) => { + // Check for HMR to not be enabled as incompatible with Blaze + await waitForMeteorOutput(allConsoleLogs, /.*HMR.*Updated modules:.*/, { negate: true }); + }, + afterRunProduction: async ({ result }) => { + await waitForBlazeEnvs(result.outputLines); + }, + 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 }) => { + await waitForBlazeEnvs(result.outputLines); + }, + afterTestOnce: async ({ result }) => { + await waitForBlazeEnvs(result.outputLines); + }, + afterBuild: async ({ result }) => { + await waitForBlazeEnvs(result.outputLines); + }, + } + })); +}); + +/** + * Helper function to wait for Blaze environment output from both Rspack Client and Server + * @param {string[]} outputLines - Array that will be populated with output lines + * @param {Object} options - Options for waiting + * @param {number} options.timeout - Maximum time to wait in milliseconds + * @param {number} options.checkInterval - Interval between checks in milliseconds + * @returns {Promise} - A promise that resolves when blaze envs are enabled + */ +export async function waitForBlazeEnvs(outputLines, options = {}) { + await waitForMeteorOutput( + outputLines, + /.*isBlazeEnabled:.*true.*/, + options + ); +}