@meteorjs/rspack 0.1.6 → 0.2.51
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/index.d.ts +6 -1
- package/lib/test.js +17 -2
- package/package.json +1 -1
- package/plugins/RequireExtenalsPlugin.js +11 -6
- package/rspack.config.js +4 -2
package/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ type MeteorEnv = Record<string, any> & {
|
|
|
43
43
|
* @param options - Optional configuration options
|
|
44
44
|
* @returns A config object with module rules configuration
|
|
45
45
|
*/
|
|
46
|
-
compileWithRspack: (deps: RuleSetConditions) => Record<string, object>;
|
|
46
|
+
compileWithRspack: (deps: RuleSetConditions, options?: SwcLoaderOptions) => Record<string, object>;
|
|
47
47
|
/**
|
|
48
48
|
* Enable or disable Rspack cache config.
|
|
49
49
|
* @param enabled - Whether to enable caching
|
|
@@ -61,6 +61,11 @@ type MeteorEnv = Record<string, any> & {
|
|
|
61
61
|
* @returns A config object with SWC loader config
|
|
62
62
|
*/
|
|
63
63
|
extendSwcConfig: (swcConfig: SwcLoaderOptions) => Record<string, object>;
|
|
64
|
+
/**
|
|
65
|
+
* Extend Rspack configs.
|
|
66
|
+
* @returns A config object with merged configs
|
|
67
|
+
*/
|
|
68
|
+
extendConfig: (...configs: Record<string, object>[]) => Record<string, object>;
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
export type ConfigFactory = (
|
package/lib/test.js
CHANGED
|
@@ -9,6 +9,7 @@ const { createIgnoreRegex, createIgnoreGlobConfig } = require("./ignore.js");
|
|
|
9
9
|
* @param {string} options.projectDir - The project directory
|
|
10
10
|
* @param {string} options.buildContext - The build context
|
|
11
11
|
* @param {string[]} options.ignoreEntries - Array of ignore patterns
|
|
12
|
+
* @param {string} options.extraEntry - Extra entry to load
|
|
12
13
|
* @returns {string} The path to the generated file
|
|
13
14
|
*/
|
|
14
15
|
const generateEagerTestFile = ({
|
|
@@ -17,6 +18,7 @@ const generateEagerTestFile = ({
|
|
|
17
18
|
buildContext,
|
|
18
19
|
ignoreEntries: inIgnoreEntries = [],
|
|
19
20
|
prefix: inPrefix = '',
|
|
21
|
+
extraEntry,
|
|
20
22
|
}) => {
|
|
21
23
|
const distDir = path.resolve(projectDir, ".meteor/local/test");
|
|
22
24
|
if (!fs.existsSync(distDir)) {
|
|
@@ -38,7 +40,7 @@ const generateEagerTestFile = ({
|
|
|
38
40
|
createIgnoreGlobConfig(ignoreEntries)
|
|
39
41
|
);
|
|
40
42
|
|
|
41
|
-
const prefix = inPrefix && `${inPrefix}-` ||
|
|
43
|
+
const prefix = (inPrefix && `${inPrefix}-`) || "";
|
|
42
44
|
const filename = isAppTest
|
|
43
45
|
? `${prefix}eager-app-tests.mjs`
|
|
44
46
|
: `${prefix}eager-tests.mjs`;
|
|
@@ -47,7 +49,8 @@ const generateEagerTestFile = ({
|
|
|
47
49
|
? "/\\.app-(?:test|spec)s?\\.[^.]+$/"
|
|
48
50
|
: "/\\.(?:test|spec)s?\\.[^.]+$/";
|
|
49
51
|
|
|
50
|
-
const content = `
|
|
52
|
+
const content = `${extraEntry ? `import path from 'path';` : ''}
|
|
53
|
+
{
|
|
51
54
|
const ctx = import.meta.webpackContext('/', {
|
|
52
55
|
recursive: true,
|
|
53
56
|
regExp: ${regExp},
|
|
@@ -55,6 +58,18 @@ const generateEagerTestFile = ({
|
|
|
55
58
|
mode: 'eager',
|
|
56
59
|
});
|
|
57
60
|
ctx.keys().forEach(ctx);
|
|
61
|
+
${
|
|
62
|
+
extraEntry
|
|
63
|
+
? `const extra = import.meta.webpackContext('${path.dirname(
|
|
64
|
+
extraEntry
|
|
65
|
+
)}', {
|
|
66
|
+
recursive: false,
|
|
67
|
+
regExp: new RegExp(\`^\\\\./${path.basename(extraEntry)}$\`),
|
|
68
|
+
mode: 'eager',
|
|
69
|
+
});
|
|
70
|
+
extra.keys().forEach(extra);`
|
|
71
|
+
: ''
|
|
72
|
+
}
|
|
58
73
|
}`;
|
|
59
74
|
|
|
60
75
|
fs.writeFileSync(filePath, content);
|
package/package.json
CHANGED
|
@@ -443,13 +443,18 @@ class RequireExternalsPlugin {
|
|
|
443
443
|
|
|
444
444
|
_ensureGlobalThisModule() {
|
|
445
445
|
const block = [
|
|
446
|
-
`/* Polyfill globalThis.module &
|
|
447
|
-
`if (typeof globalThis
|
|
448
|
-
` globalThis.module
|
|
446
|
+
`/* Polyfill globalThis.module, exports & module for legacy */`,
|
|
447
|
+
`if (typeof globalThis !== 'undefined') {`,
|
|
448
|
+
` if (typeof globalThis.module === 'undefined') {`,
|
|
449
|
+
` globalThis.module = { exports: {} };`,
|
|
450
|
+
` }`,
|
|
451
|
+
` if (typeof globalThis.exports === 'undefined') {`,
|
|
452
|
+
` globalThis.exports = globalThis.module.exports;`,
|
|
453
|
+
` }`,
|
|
454
|
+
`}`,
|
|
455
|
+
`if (typeof window.module === 'undefined') {`,
|
|
456
|
+
` window.module = { exports: {} };`,
|
|
449
457
|
`}`,
|
|
450
|
-
`if (typeof globalThis.exports === 'undefined') {`,
|
|
451
|
-
` globalThis.exports = globalThis.module.exports;`,
|
|
452
|
-
`}`
|
|
453
458
|
].join('\n') + '\n';
|
|
454
459
|
|
|
455
460
|
let content = '';
|
package/rspack.config.js
CHANGED
|
@@ -274,9 +274,9 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
274
274
|
|
|
275
275
|
// Expose Meteor's helpers to expand Rspack configs
|
|
276
276
|
Meteor.compileWithMeteor = deps => compileWithMeteor(deps);
|
|
277
|
-
Meteor.compileWithRspack = deps =>
|
|
277
|
+
Meteor.compileWithRspack = (deps, options = {}) =>
|
|
278
278
|
compileWithRspack(deps, {
|
|
279
|
-
options: Meteor.swcConfigOptions,
|
|
279
|
+
options: mergeSplitOverlap(Meteor.swcConfigOptions, options),
|
|
280
280
|
});
|
|
281
281
|
Meteor.setCache = enabled =>
|
|
282
282
|
setCache(
|
|
@@ -285,6 +285,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
285
285
|
);
|
|
286
286
|
Meteor.splitVendorChunk = () => splitVendorChunk();
|
|
287
287
|
Meteor.extendSwcConfig = (customSwcConfig) => extendSwcConfig(customSwcConfig);
|
|
288
|
+
Meteor.extendConfig = (...configs) => mergeSplitOverlap(...configs);
|
|
288
289
|
|
|
289
290
|
// Add HtmlRspackPlugin function to Meteor
|
|
290
291
|
Meteor.HtmlRspackPlugin = (options = {}) => {
|
|
@@ -420,6 +421,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
420
421
|
buildContext,
|
|
421
422
|
ignoreEntries: [...meteorIgnoreEntries, "**/server/**"],
|
|
422
423
|
prefix: "client",
|
|
424
|
+
extraEntry: path.resolve(process.cwd(), Meteor.mainClientEntry),
|
|
423
425
|
})
|
|
424
426
|
: isTest && isTestEager
|
|
425
427
|
? generateEagerTestFile({
|