@meteorjs/rspack 2.0.0 → 3.0.0-beta.0
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 +4 -3
- package/rspack.config.js +63 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meteorjs/rspack",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
4
4
|
"description": "Configuration logic for using Rspack in Meteor projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
"semver": "^7.7.4"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@rspack/cli": ">=
|
|
24
|
-
"@rspack/core": ">=
|
|
23
|
+
"@rspack/cli": ">=2.0.0",
|
|
24
|
+
"@rspack/core": ">=2.0.0",
|
|
25
|
+
"@rspack/dev-server": ">=2.0.0",
|
|
25
26
|
"@swc/core": ">=1.3.0"
|
|
26
27
|
}
|
|
27
28
|
}
|
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,
|
|
@@ -610,11 +647,13 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
610
647
|
},
|
|
611
648
|
]
|
|
612
649
|
: []),
|
|
650
|
+
{ test: /\.css$/, type: "css/auto" },
|
|
613
651
|
...extraRules,
|
|
614
652
|
],
|
|
615
653
|
},
|
|
616
654
|
resolve: { extensions, alias, fallback },
|
|
617
655
|
externals,
|
|
656
|
+
externalsType: "commonjs2",
|
|
618
657
|
plugins: [
|
|
619
658
|
...[
|
|
620
659
|
...(isReactEnabled && reactRefreshModule && isDevEnvironment
|
|
@@ -654,19 +693,15 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
654
693
|
...(Meteor.isBlazeEnabled && { hot: false }),
|
|
655
694
|
port: devServerPort,
|
|
656
695
|
devMiddleware: {
|
|
657
|
-
writeToDisk: createPersistCallback({
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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 });
|
|
696
|
+
writeToDisk: createPersistCallback({
|
|
697
|
+
once: ["sw.js"],
|
|
698
|
+
always: [".html"],
|
|
699
|
+
}),
|
|
666
700
|
},
|
|
701
|
+
onListening: meteorDefaultOnListening,
|
|
667
702
|
},
|
|
668
703
|
}),
|
|
669
|
-
...
|
|
704
|
+
...cacheStrategy,
|
|
670
705
|
...lazyCompilationConfig,
|
|
671
706
|
...loggingConfig,
|
|
672
707
|
};
|
|
@@ -746,6 +781,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
746
781
|
conditionNames: ["import", "require", "node", "default"],
|
|
747
782
|
},
|
|
748
783
|
externals,
|
|
784
|
+
externalsType: "commonjs2",
|
|
749
785
|
externalsPresets: { node: true },
|
|
750
786
|
plugins: [
|
|
751
787
|
new DefinePlugin(
|
|
@@ -843,6 +879,23 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
|
|
843
879
|
}
|
|
844
880
|
}
|
|
845
881
|
|
|
882
|
+
// If the user or an override replaced devServer.onListening, compose
|
|
883
|
+
// so our default runs first (attaches the Windows socket guard and
|
|
884
|
+
// reports the dev server URL) and the user's hook runs second.
|
|
885
|
+
if (isClient && config.devServer) {
|
|
886
|
+
const finalOnListening = config.devServer.onListening;
|
|
887
|
+
if (
|
|
888
|
+
typeof finalOnListening === "function" &&
|
|
889
|
+
finalOnListening !== meteorDefaultOnListening
|
|
890
|
+
) {
|
|
891
|
+
const userOnListening = finalOnListening;
|
|
892
|
+
config.devServer.onListening = function (devServer) {
|
|
893
|
+
meteorDefaultOnListening(devServer);
|
|
894
|
+
userOnListening(devServer);
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
|
|
846
899
|
const shouldDisablePlugins = config?.disablePlugins != null;
|
|
847
900
|
if (shouldDisablePlugins) {
|
|
848
901
|
config = disablePlugins(config, config.disablePlugins);
|