update Meteor Rspack to support cross-os multiline banner output

This commit is contained in:
Nacho Codoñer
2025-09-01 10:05:29 +02:00
parent 68bb2e6fed
commit fb3aeff59a
16 changed files with 37 additions and 23 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@meteorjs/rspack",
"version": "0.0.36",
"version": "0.0.37",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@meteorjs/rspack",
"version": "0.0.36",
"version": "0.0.37",
"license": "ISC",
"dependencies": {
"ignore-loader": "^0.1.2",

View File

@@ -1,6 +1,6 @@
{
"name": "@meteorjs/rspack",
"version": "0.0.36",
"version": "0.0.37",
"description": "Configuration logic for using Rspack in Meteor projects",
"main": "index.js",
"type": "module",

View File

@@ -147,7 +147,7 @@ export default function (inMeteor = {}, argv = {}) {
const runPath = Meteor.runPath;
// Determine banner
const bannerOutput = JSON.parse(Meteor.bannerOutput || '');
const bannerOutput = JSON.parse(Meteor.bannerOutput || process.env.RSPACK_BANNER || '');
// Determine output directories
const clientOutputDir = path.resolve(process.cwd(), 'public');

View File

@@ -5,7 +5,7 @@
export const DEFAULT_RSPACK_VERSION = '1.5.0';
export const DEFAULT_METEOR_RSPACK_VERSION = '0.0.36';
export const DEFAULT_METEOR_RSPACK_VERSION = '0.0.37';
export const DEFAULT_METEOR_RSPACK_REACT_HMR_VERSION = '1.4.3';

View File

@@ -59,11 +59,11 @@ export function getConfigFileName() {
}
/**
* Gets the appropriate Rspack environment variables
* Gets the appropriate Rspack environment variables and command line arguments
* @param {Object} options - Options for environment variables
* @param {boolean} options.isClient - Whether this is for client-side build
* @param {boolean} options.isServer - Whether this is for server-side build
* @returns {string[]} Array of command line arguments for Rspack
* @returns {Object} Object containing params (command line arguments) and envs (environment variables)
*/
export function getRspackEnv({ isClient, isServer, isTest: inIsTest }) {
const RSPACK_BUILD_CONTEXT = require('./constants').RSPACK_BUILD_CONTEXT;
@@ -127,7 +127,6 @@ export function getRspackEnv({ isClient, isServer, isTest: inIsTest }) {
}),
],
['runPath', getBuildFilePath({ ...module, ...env, ...side, ...commandRole }) ],
['bannerOutput', JSON.stringify(getBuildFileContent({ ...module, ...env, ...side, role: FILE_ROLE.output }))],
['buildContext', RSPACK_BUILD_CONTEXT],
['chunksContext', RSPACK_CHUNKS_CONTEXT],
['assetsContext', RSPACK_ASSETS_CONTEXT],
@@ -142,10 +141,19 @@ export function getRspackEnv({ isClient, isServer, isTest: inIsTest }) {
...(isBundleVisualizerEnabled && [['isBundleVisualizerEnabled', isBundleVisualizerEnabled]] || []),
].filter(Boolean);
return pairs.flatMap(([key, val]) => [
// Create environment variables object with bannerOutput
const envs = {
RSPACK_BANNER: JSON.stringify(getBuildFileContent({ ...module, ...env, ...side, role: FILE_ROLE.output }))
};
// Create params from pairs
const params = pairs.flatMap(([key, val]) => [
'--env',
`${key}=${val}`
]);
return { params, envs };
}
/**
@@ -166,11 +174,13 @@ export function startRspackClientServe(options = {}) {
const appDir = getMeteorAppDir();
const configFile = getConfigFileName();
const { command, args } = getNpxCommand(['rspack', 'serve', '--config', configFile, ...getRspackEnv({ isClient: true, isServer: false })]);
const { params, envs } = getRspackEnv({ isClient: true, isServer: false });
const { command, args } = getNpxCommand(['rspack', 'serve', '--config', configFile, ...params]);
const newClientProcess = spawnProcess(
command,
args, {
cwd: appDir,
env: { ...process.env, ...envs },
onStdout: (data) => {
logInfo(`[Rspack Client] ${data}`);
if (onCompile && data.trim().includes("compiled")) {
@@ -219,11 +229,13 @@ export function startRspackServerWatch(options = {}) {
const appDir = getMeteorAppDir();
const configFile = getConfigFileName();
const { command, args } = getNpxCommand(['rspack', 'build', '--watch', '--config', configFile, ...getRspackEnv({ isClient: false, isServer: true })]);
const { params, envs } = getRspackEnv({ isClient: false, isServer: true });
const { command, args } = getNpxCommand(['rspack', 'build', '--watch', '--config', configFile, ...params]);
const newServerProcess = spawnProcess(
command,
args, {
cwd: appDir,
env: { ...process.env, ...envs },
onStdout: (data) => {
logInfo(`[Rspack Server] ${data}`);
if (onCompile && data.trim().includes("compiled")) {
@@ -267,13 +279,14 @@ export async function runRspackBuild({ isClient, isServer, isTest, isTestModule,
const endpoint = isTestModule ? 'Module' : isClient ? 'Client' : 'Server';
// Use a promise to ensure Meteor waits until Rspack finishes
return new Promise((resolve, reject) => {
const { params, envs } = getRspackEnv({ isClient, isServer, isTest, isTestModule });
const rspackArgs = [
'rspack',
'build',
'--config',
configFile,
...(watch && ['--watch']) || [],
...getRspackEnv({ isClient, isServer, isTest, isTestModule }),
...params,
].filter(Boolean);
const { command, args } = getNpxCommand(rspackArgs);
spawnProcess(
@@ -281,6 +294,7 @@ export async function runRspackBuild({ isClient, isServer, isTest, isTestModule,
args,
{
cwd: appDir,
env: { ...process.env, ...envs },
onStdout: (data) => {
logInfo(`[Rspack ${label} ${endpoint}] ${data}`);
if (onCompile && data.trim().includes("compiled")) {

View File

@@ -17,7 +17,7 @@
"vue-router": "^4.2.5"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"@tailwindcss/postcss": "^4.1.12",

View File

@@ -19,7 +19,7 @@
},
"devDependencies": {
"@graphql-tools/webpack-loader": "^7.0.0",
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"@rspack/plugin-react-refresh": "^1.4.3",

View File

@@ -14,7 +14,7 @@
"meteor-node-stubs": "^1.2.12"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"@rspack/plugin-react-refresh": "^1.4.3"

View File

@@ -21,7 +21,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"@rspack/plugin-react-refresh": "^1.4.3",

View File

@@ -12,7 +12,7 @@
"meteor-node-stubs": "^1.2.12"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"chai": "^4.2.0"

View File

@@ -15,7 +15,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"@rspack/plugin-react-refresh": "^1.4.3",

View File

@@ -14,7 +14,7 @@
"picocolors": "^1.1.1"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"babel-loader": "10.0.0",

View File

@@ -13,7 +13,7 @@
"meteor-node-stubs": "^1.2.12"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"postcss-load-config": "^5.1.0",

View File

@@ -16,7 +16,7 @@
"react-dom": "^17.0.2"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"@rspack/plugin-react-refresh": "^1.4.3",

View File

@@ -15,7 +15,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"@rspack/plugin-react-refresh": "^1.4.3",

View File

@@ -17,7 +17,7 @@
"vue-router": "^4.2.5"
},
"devDependencies": {
"@meteorjs/rspack": "^0.0.36",
"@meteorjs/rspack": "^0.0.37",
"@rspack/cli": "^1.4.8",
"@rspack/core": "^1.4.8",
"@tailwindcss/postcss": "^4.1.12",