@meteorjs/rspack 0.0.48 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rspack.config.js +31 -7
package/package.json
CHANGED
package/rspack.config.js
CHANGED
|
@@ -109,9 +109,9 @@ const defaultWatchOptions = {
|
|
|
109
109
|
/**
|
|
110
110
|
* @param {{ isClient: boolean; isServer: boolean; isDevelopment?: boolean; isProduction?: boolean; isTest?: boolean }} Meteor
|
|
111
111
|
* @param {{ mode?: string; clientEntry?: string; serverEntry?: string; clientOutputFolder?: string; serverOutputFolder?: string; chunksContext?: string; assetsContext?: string; serverAssetsContext?: string }} argv
|
|
112
|
-
* @returns {import('@rspack/cli').Configuration[]}
|
|
112
|
+
* @returns {Promise<import('@rspack/cli').Configuration[]>}
|
|
113
113
|
*/
|
|
114
|
-
module.exports = function (inMeteor = {}, argv = {}) {
|
|
114
|
+
module.exports = async function (inMeteor = {}, argv = {}) {
|
|
115
115
|
// Transform Meteor env properties to proper boolean values
|
|
116
116
|
const Meteor = { ...inMeteor };
|
|
117
117
|
// Convert string boolean values to actual booleans
|
|
@@ -137,6 +137,7 @@ module.exports = function (inMeteor = {}, argv = {}) {
|
|
|
137
137
|
const swcExternalHelpers = !!Meteor.swcExternalHelpers;
|
|
138
138
|
const isNative = !!Meteor.isNative;
|
|
139
139
|
const mode = isProd ? 'production' : 'development';
|
|
140
|
+
const projectConfigPath = Meteor.projectConfigPath || path.resolve(process.cwd(), 'rspack.config.js');
|
|
140
141
|
|
|
141
142
|
const isTypescriptEnabled = Meteor.isTypescriptEnabled || false;
|
|
142
143
|
const isJsxEnabled =
|
|
@@ -202,7 +203,7 @@ module.exports = function (inMeteor = {}, argv = {}) {
|
|
|
202
203
|
isTestEager && {
|
|
203
204
|
ignored: [
|
|
204
205
|
...defaultWatchOptions.ignored,
|
|
205
|
-
|
|
206
|
+
`**/${buildContext}/**`,
|
|
206
207
|
'**/.meteor/local/**',
|
|
207
208
|
'**/node_modules/**',
|
|
208
209
|
],
|
|
@@ -435,13 +436,36 @@ module.exports = function (inMeteor = {}, argv = {}) {
|
|
|
435
436
|
};
|
|
436
437
|
|
|
437
438
|
// Load and apply project-level overrides for the selected build
|
|
438
|
-
const projectConfigPath = path.resolve(process.cwd(), 'rspack.config.js');
|
|
439
|
-
|
|
440
439
|
// Check if we're in a Meteor package directory by looking at the path
|
|
441
440
|
const isMeteorPackageConfig = process.cwd().includes('/packages/rspack');
|
|
442
441
|
if (fs.existsSync(projectConfigPath) && !isMeteorPackageConfig) {
|
|
443
|
-
|
|
444
|
-
|
|
442
|
+
// Check if there's a .mjs or .cjs version of the config file
|
|
443
|
+
const mjsConfigPath = projectConfigPath.replace(/\.js$/, '.mjs');
|
|
444
|
+
const cjsConfigPath = projectConfigPath.replace(/\.js$/, '.cjs');
|
|
445
|
+
|
|
446
|
+
let configPath = projectConfigPath;
|
|
447
|
+
if (fs.existsSync(mjsConfigPath)) {
|
|
448
|
+
configPath = mjsConfigPath;
|
|
449
|
+
} else if (fs.existsSync(cjsConfigPath)) {
|
|
450
|
+
configPath = cjsConfigPath;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Use require for CommonJS modules and dynamic import for ES modules
|
|
454
|
+
let projectConfig;
|
|
455
|
+
try {
|
|
456
|
+
if (path.extname(configPath) === '.mjs') {
|
|
457
|
+
// For ESM modules, we need to use dynamic import
|
|
458
|
+
const fileUrl = `file://${configPath}`;
|
|
459
|
+
const module = await import(fileUrl);
|
|
460
|
+
projectConfig = module.default || module;
|
|
461
|
+
} else {
|
|
462
|
+
// For CommonJS modules, we can use require
|
|
463
|
+
projectConfig = require(configPath)?.default || require(configPath);
|
|
464
|
+
}
|
|
465
|
+
} catch (error) {
|
|
466
|
+
console.error(`Error loading rspack config from ${configPath}:`, error);
|
|
467
|
+
throw error;
|
|
468
|
+
}
|
|
445
469
|
|
|
446
470
|
const userConfig =
|
|
447
471
|
typeof projectConfig === 'function'
|