@meteorjs/rspack 1.1.0-beta.7 → 1.1.0-beta.9
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.
|
@@ -202,6 +202,12 @@ function disablePlugins(config, matchers) {
|
|
|
202
202
|
return config;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
function outputMeteorRspack(data) {
|
|
206
|
+
const jsonString = JSON.stringify(data);
|
|
207
|
+
const output = `[Meteor-Rspack]${jsonString}[/Meteor-Rspack]`;
|
|
208
|
+
console.log(output);
|
|
209
|
+
}
|
|
210
|
+
|
|
205
211
|
module.exports = {
|
|
206
212
|
compileWithMeteor,
|
|
207
213
|
compileWithRspack,
|
|
@@ -210,4 +216,5 @@ module.exports = {
|
|
|
210
216
|
extendSwcConfig,
|
|
211
217
|
makeWebNodeBuiltinsAlias,
|
|
212
218
|
disablePlugins,
|
|
219
|
+
outputMeteorRspack,
|
|
213
220
|
};
|
package/package.json
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
// a new Rspack compilation happens. The JSON content is configurable
|
|
5
5
|
// via plugin instantiation options.
|
|
6
6
|
|
|
7
|
+
const { outputMeteorRspack } = require('../lib/meteorRspackHelpers');
|
|
8
|
+
|
|
7
9
|
class MeteorRspackOutputPlugin {
|
|
8
10
|
constructor(options = {}) {
|
|
9
11
|
this.pluginName = 'MeteorRspackOutputPlugin';
|
|
10
12
|
this.options = options;
|
|
13
|
+
this.compilationCount = 0;
|
|
11
14
|
// The data to be output as JSON, can be a static object or a function
|
|
12
15
|
this.getData =
|
|
13
16
|
typeof options.getData === 'function'
|
|
@@ -16,25 +19,16 @@ class MeteorRspackOutputPlugin {
|
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
apply(compiler) {
|
|
19
|
-
const { devServer } = compiler.options;
|
|
20
|
-
|
|
21
|
-
let devServerUrl;
|
|
22
|
-
if (devServer) {
|
|
23
|
-
const protocol = devServer.server?.type === "https" ? "https" : "http";
|
|
24
|
-
const host =
|
|
25
|
-
devServer.host && devServer.host !== "0.0.0.0"
|
|
26
|
-
? devServer.host
|
|
27
|
-
: "localhost";
|
|
28
|
-
const port = devServer.port ?? 8080;
|
|
29
|
-
devServerUrl = `${protocol}://${host}:${port}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
22
|
// Hook into the 'done' event which fires after each compilation completes
|
|
33
23
|
compiler.hooks.done.tap(this.pluginName, stats => {
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
this.compilationCount++;
|
|
25
|
+
const data = {
|
|
26
|
+
...(this.getData(stats, {
|
|
27
|
+
compilationCount: this.compilationCount,
|
|
28
|
+
isRebuild: this.compilationCount > 1,
|
|
29
|
+
}) || {}),
|
|
30
|
+
};
|
|
31
|
+
outputMeteorRspack(data);
|
|
38
32
|
});
|
|
39
33
|
}
|
|
40
34
|
}
|
package/rspack.config.js
CHANGED
|
@@ -22,6 +22,7 @@ const {
|
|
|
22
22
|
extendSwcConfig,
|
|
23
23
|
makeWebNodeBuiltinsAlias,
|
|
24
24
|
disablePlugins,
|
|
25
|
+
outputMeteorRspack,
|
|
25
26
|
} = require('./lib/meteorRspackHelpers.js');
|
|
26
27
|
const { prepareMeteorRspackConfig } = require("./lib/meteorRspackConfigFactory");
|
|
27
28
|
|
|
@@ -226,6 +227,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
226
227
|
const isTestLike = !!Meteor.isTestLike;
|
|
227
228
|
const swcExternalHelpers = !!Meteor.swcExternalHelpers;
|
|
228
229
|
const isNative = !!Meteor.isNative;
|
|
230
|
+
const isProfile = !!Meteor.isProfile;
|
|
229
231
|
const mode = isProd ? 'production' : 'development';
|
|
230
232
|
const projectDir = process.cwd();
|
|
231
233
|
const projectConfigPath = Meteor.projectConfigPath || path.resolve(projectDir, 'rspack.config.js');
|
|
@@ -428,7 +430,9 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
428
430
|
: [];
|
|
429
431
|
// Not supported in Meteor yet (Rspack 1.7+ is enabled by default)
|
|
430
432
|
const lazyCompilationConfig = { lazyCompilation: false };
|
|
431
|
-
const loggingConfig =
|
|
433
|
+
const loggingConfig = isProfile
|
|
434
|
+
? {}
|
|
435
|
+
: { stats: 'none', infrastructureLogging: { level: 'none' } };
|
|
432
436
|
|
|
433
437
|
const clientEntry =
|
|
434
438
|
isClient && isTest && isTestEager && isTestFullApp
|
|
@@ -547,6 +551,13 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
547
551
|
writeToDisk: filePath =>
|
|
548
552
|
/\.(html)$/.test(filePath) && !filePath.includes('.hot-update.'),
|
|
549
553
|
},
|
|
554
|
+
onListening(devServer) {
|
|
555
|
+
if (!devServer) return;
|
|
556
|
+
const { host, port } = devServer.options;
|
|
557
|
+
const protocol = devServer.options.server?.type === "https" ? "https" : "http";
|
|
558
|
+
const devServerUrl = `${protocol}://${host || "localhost"}:${port}`;
|
|
559
|
+
outputMeteorRspack({ devServerUrl });
|
|
560
|
+
},
|
|
550
561
|
},
|
|
551
562
|
}),
|
|
552
563
|
...merge(cacheStrategy, { experiments: { css: true } }),
|
|
@@ -821,13 +832,15 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
821
832
|
|
|
822
833
|
// Add MeteorRspackOutputPlugin as the last plugin to output compilation info
|
|
823
834
|
const meteorRspackOutputPlugin = new MeteorRspackOutputPlugin({
|
|
824
|
-
getData: (stats) => ({
|
|
835
|
+
getData: (stats, { isRebuild, compilationCount }) => ({
|
|
825
836
|
name: config.name,
|
|
826
837
|
mode: config.mode,
|
|
827
838
|
hasErrors: stats.hasErrors(),
|
|
828
839
|
hasWarnings: stats.hasWarnings(),
|
|
829
840
|
timestamp: Date.now(),
|
|
830
841
|
statsOverrided,
|
|
842
|
+
compilationCount,
|
|
843
|
+
isRebuild,
|
|
831
844
|
}),
|
|
832
845
|
});
|
|
833
846
|
config.plugins = [meteorRspackOutputPlugin, ...(config.plugins || [])];
|