@meteorjs/rspack 1.1.0-beta.36 → 1.1.0-beta.37
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 +55 -8
package/package.json
CHANGED
package/rspack.config.js
CHANGED
|
@@ -562,6 +562,43 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
562
562
|
? path.resolve(process.cwd(), testEntry)
|
|
563
563
|
: path.resolve(process.cwd(), buildContext, entryPath);
|
|
564
564
|
const clientNameConfig = `[${(isTest && "test-") || ""}client-rspack]`;
|
|
565
|
+
|
|
566
|
+
// Default onListening provided by meteor-rspack. Kept as a named
|
|
567
|
+
// reference so we can detect a user-supplied override after merge
|
|
568
|
+
// and compose (run default first, then user's).
|
|
569
|
+
const meteorDefaultOnListening = function (devServer) {
|
|
570
|
+
if (!devServer) return;
|
|
571
|
+
const { host, port } = devServer.options;
|
|
572
|
+
const protocol =
|
|
573
|
+
devServer.options.server?.type === "https" ? "https" : "http";
|
|
574
|
+
const devServerUrl = `${protocol}://${host || "localhost"}:${port}`;
|
|
575
|
+
outputMeteorRspack({ devServerUrl });
|
|
576
|
+
|
|
577
|
+
// Windows-only: webpack-dev-server tracks accepted sockets
|
|
578
|
+
// but doesn't attach 'error'. On Windows, teardown of a
|
|
579
|
+
// closed proxy connection sends RST, producing an unhandled
|
|
580
|
+
// ECONNRESET that crashes the dev server. Unix peers send
|
|
581
|
+
// FIN and never hit this.
|
|
582
|
+
if (process.platform === "win32") {
|
|
583
|
+
const server = devServer.server;
|
|
584
|
+
if (!server || server.__meteorRspackErrorGuard) return;
|
|
585
|
+
server.__meteorRspackErrorGuard = true;
|
|
586
|
+
|
|
587
|
+
server.on("connection", (socket) => {
|
|
588
|
+
if (!socket || socket.__meteorRspackGuarded) return;
|
|
589
|
+
socket.__meteorRspackGuarded = true;
|
|
590
|
+
socket.on("error", (err) => {
|
|
591
|
+
if (err && err.code === "ECONNRESET") return;
|
|
592
|
+
console.warn(
|
|
593
|
+
`[meteor-rspack] dev server socket error: ${
|
|
594
|
+
err && (err.code || err.message)
|
|
595
|
+
}`
|
|
596
|
+
);
|
|
597
|
+
});
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
|
|
565
602
|
// Base client config
|
|
566
603
|
let clientConfig = {
|
|
567
604
|
name: clientNameConfig,
|
|
@@ -656,14 +693,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
656
693
|
devMiddleware: {
|
|
657
694
|
writeToDisk: createPersistCallback({ once: ['sw.js'], always: ['.html'] }),
|
|
658
695
|
},
|
|
659
|
-
onListening
|
|
660
|
-
if (!devServer) return;
|
|
661
|
-
const { host, port } = devServer.options;
|
|
662
|
-
const protocol =
|
|
663
|
-
devServer.options.server?.type === "https" ? "https" : "http";
|
|
664
|
-
const devServerUrl = `${protocol}://${host || "localhost"}:${port}`;
|
|
665
|
-
outputMeteorRspack({ devServerUrl });
|
|
666
|
-
},
|
|
696
|
+
onListening: meteorDefaultOnListening,
|
|
667
697
|
},
|
|
668
698
|
}),
|
|
669
699
|
...merge(cacheStrategy, { experiments: { css: true } }),
|
|
@@ -843,6 +873,23 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
843
873
|
}
|
|
844
874
|
}
|
|
845
875
|
|
|
876
|
+
// If the user or an override replaced devServer.onListening, compose
|
|
877
|
+
// so our default runs first (attaches the Windows socket guard and
|
|
878
|
+
// reports the dev server URL) and the user's hook runs second.
|
|
879
|
+
if (isClient && config.devServer) {
|
|
880
|
+
const finalOnListening = config.devServer.onListening;
|
|
881
|
+
if (
|
|
882
|
+
typeof finalOnListening === "function" &&
|
|
883
|
+
finalOnListening !== meteorDefaultOnListening
|
|
884
|
+
) {
|
|
885
|
+
const userOnListening = finalOnListening;
|
|
886
|
+
config.devServer.onListening = function (devServer) {
|
|
887
|
+
meteorDefaultOnListening(devServer);
|
|
888
|
+
userOnListening(devServer);
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
846
893
|
const shouldDisablePlugins = config?.disablePlugins != null;
|
|
847
894
|
if (shouldDisablePlugins) {
|
|
848
895
|
config = disablePlugins(config, config.disablePlugins);
|