@meteorjs/rspack 2.2.0 → 3.0.0-beta.1

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.
@@ -3,7 +3,7 @@
3
3
  * overlapping file extensions in module rules.
4
4
  */
5
5
 
6
- const { mergeWithCustomize } = require('webpack-merge');
6
+ const { mergeWithCustomize } = require('rspack-merge');
7
7
  const isEqual = require('fast-deep-equal');
8
8
 
9
9
  /**
@@ -56,17 +56,12 @@ function compileWithRspack(deps, { options = {} } = {}) {
56
56
  */
57
57
  function setCache(
58
58
  enabled,
59
- cacheConfig = { cache: true, experiments: { cache: true } }
59
+ cacheConfig = { cache: true }
60
60
  ) {
61
61
  return prepareMeteorRspackConfig(
62
62
  enabled
63
63
  ? cacheConfig
64
- : {
65
- cache: false, // disable cache
66
- experiments: {
67
- cache: false, // disable persistent cache (experimental flag)
68
- },
69
- }
64
+ : { cache: false }
70
65
  );
71
66
  }
72
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteorjs/rspack",
3
- "version": "2.2.0",
3
+ "version": "3.0.0-beta.1",
4
4
  "description": "Configuration logic for using Rspack in Meteor projects",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -14,14 +14,15 @@
14
14
  "fast-deep-equal": "^3.1.3",
15
15
  "ignore-loader": "^0.1.2",
16
16
  "isomorphic-timers-promises": "^1.0.1",
17
- "webpack-merge": "^6.0.1"
17
+ "rspack-merge": "^1.0.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "semver": "^7.7.4"
21
21
  },
22
22
  "peerDependencies": {
23
- "@rspack/cli": ">=1.3.0",
24
- "@rspack/core": ">=1.3.0",
23
+ "@rspack/cli": ">=2.2.0",
24
+ "@rspack/core": ">=2.2.0",
25
+ "@rspack/dev-server": ">=2.2.0",
25
26
  "@swc/core": ">=1.3.0",
26
27
  "meteor-node-stubs": ">=1.2.0"
27
28
  },
package/rspack.config.js CHANGED
@@ -2,7 +2,7 @@ const { DefinePlugin, BannerPlugin, NormalModuleReplacementPlugin } = require('@
2
2
  const fs = require('fs');
3
3
  const { inspect } = require('node:util');
4
4
  const path = require('path');
5
- const { merge } = require('webpack-merge');
5
+ const { merge } = require('rspack-merge');
6
6
 
7
7
  const { cleanOmittedPaths, mergeSplitOverlap } = require("./lib/mergeRulesSplitOverlap.js");
8
8
  const { getMeteorAppSwcConfig } = require('./lib/swc.js');
@@ -94,26 +94,22 @@ function createCacheStrategy(
94
94
  ].filter(Boolean);
95
95
 
96
96
  return {
97
- cache: true,
98
- experiments: {
99
- cache: {
100
- version: `cache-${mode}${(side && `-${side}`) || ""}`,
101
- type: "persistent",
102
- storage: {
103
- type: "filesystem",
104
- // Include the mode in the directory (not just the version):
105
- // rspack invalidates a persistent cache on version mismatch, so
106
- // sharing one directory between development and production would
107
- // wipe the cache on every `meteor run` <-> `meteor build` switch
108
- // instead of keeping both warm. See meteor/meteor#14568.
109
- directory: `node_modules/.cache/rspack/${
110
- [buildContext, side, mode].filter(Boolean).join('-') || 'default'
111
- }`,
112
- },
113
- ...(buildDependencies.length > 0 && {
114
- buildDependencies: buildDependencies,
115
- })
97
+ cache: {
98
+ version: `cache-${mode}${(side && `-${side}`) || ""}`,
99
+ type: "persistent",
100
+ storage: {
101
+ type: "filesystem",
102
+ // Rspack invalidates a persistent cache on version mismatch. Keep
103
+ // development and production in separate directories so switching
104
+ // between `meteor run` and `meteor build` leaves both caches warm.
105
+ // See meteor/meteor#14568.
106
+ directory: `node_modules/.cache/rspack/${
107
+ [buildContext, side, mode].filter(Boolean).join('-') || 'default'
108
+ }`,
116
109
  },
110
+ ...(buildDependencies.length > 0 && {
111
+ buildDependencies: buildDependencies,
112
+ })
117
113
  },
118
114
  };
119
115
  }
@@ -468,9 +464,6 @@ module.exports = async function (inMeteor = {}, argv = {}) {
468
464
  ...(isReactEnabled ? [/^react$/, /^react-dom$/] : []),
469
465
  ...(isServer ? [/^bcrypt$/] : []),
470
466
  ];
471
- const alias = {
472
- "/": path.resolve(process.cwd()),
473
- };
474
467
  const fallback = {
475
468
  ...(isClient && makeWebNodeBuiltinsAlias()),
476
469
  };
@@ -491,6 +484,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
491
484
  const reactRefreshModule = isReactEnabled
492
485
  ? safeRequire("@rspack/plugin-react-refresh")
493
486
  : null;
487
+ const ReactRefreshRspackPlugin =
488
+ reactRefreshModule?.ReactRefreshRspackPlugin || reactRefreshModule;
494
489
 
495
490
  const requireExternalsPlugin = new RequireExternalsPlugin({
496
491
  filePath: path.join(buildContext, runPath),
@@ -626,7 +621,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
626
621
  if (isMainChunk) return `../${buildContext}/${outputPath}`;
627
622
  return chunkSuffix;
628
623
  },
629
- libraryTarget: "commonjs2",
624
+ library: { type: "commonjs2" },
630
625
  publicPath: "/",
631
626
  chunkFilename: `${chunksContext}/[id]${isProd ? ".[chunkhash]" : ""}.js`,
632
627
  assetModuleFilename,
@@ -653,15 +648,27 @@ module.exports = async function (inMeteor = {}, argv = {}) {
653
648
  },
654
649
  ]
655
650
  : []),
651
+ { test: /\.css$/, type: "css/auto" },
656
652
  ...extraRules,
657
653
  ],
654
+ parser: {
655
+ javascript: {
656
+ // Relax Rspack 2.0 strict ESM linking; SWC-stripped TS type re-exports otherwise fail the build.
657
+ exportsPresence: "warn",
658
+ },
659
+ },
660
+ },
661
+ resolve: {
662
+ extensions,
663
+ fallback,
664
+ roots: [path.resolve(projectDir)],
658
665
  },
659
- resolve: { extensions, alias, fallback, roots: [path.resolve(projectDir)] },
660
666
  externals,
667
+ externalsType: "commonjs2",
661
668
  plugins: [
662
669
  ...[
663
- ...(isReactEnabled && reactRefreshModule && isDevEnvironment
664
- ? [new reactRefreshModule()]
670
+ ...(isReactEnabled && ReactRefreshRspackPlugin && isDevEnvironment
671
+ ? [new ReactRefreshRspackPlugin()]
665
672
  : []),
666
673
  requireExternalsPlugin,
667
674
  assetExternalsPlugin,
@@ -697,12 +704,15 @@ module.exports = async function (inMeteor = {}, argv = {}) {
697
704
  ...(Meteor.isBlazeEnabled && { hot: false }),
698
705
  port: devServerPort,
699
706
  devMiddleware: {
700
- writeToDisk: createPersistCallback({ once: ['sw.js'], always: ['.html'] }),
707
+ writeToDisk: createPersistCallback({
708
+ once: ["sw.js"],
709
+ always: [".html"],
710
+ }),
701
711
  },
702
712
  onListening: meteorDefaultOnListening,
703
713
  },
704
714
  }),
705
- ...merge(cacheStrategy, { experiments: { css: true } }),
715
+ ...cacheStrategy,
706
716
  ...lazyCompilationConfig,
707
717
  ...loggingConfig,
708
718
  };
@@ -741,7 +751,7 @@ module.exports = async function (inMeteor = {}, argv = {}) {
741
751
  output: {
742
752
  path: serverOutputDir,
743
753
  filename: () => `../${buildContext}/${outputPath}`,
744
- libraryTarget: "commonjs2",
754
+ library: { type: "commonjs2" },
745
755
  chunkFilename: `${chunksContext}/[id]${isProd ? ".[chunkhash]" : ""}.js`,
746
756
  assetModuleFilename,
747
757
  ...(isProd && { clean: { keep: keepOutsideBuild() } }),
@@ -772,17 +782,19 @@ module.exports = async function (inMeteor = {}, argv = {}) {
772
782
  javascript: {
773
783
  // Dynamic imports on the server are treated as bundled in the same chunk
774
784
  dynamicImportMode: "eager",
785
+ // Relax Rspack 2.0 strict ESM linking; SWC-stripped TS type re-exports otherwise fail the build.
786
+ exportsPresence: "warn",
775
787
  },
776
788
  },
777
789
  },
778
790
  resolve: {
779
791
  extensions,
780
- alias,
781
792
  modules: ["node_modules", path.resolve(projectDir)],
782
793
  conditionNames: ["import", "require", "node", "default"],
783
794
  roots: [path.resolve(projectDir)],
784
795
  },
785
796
  externals,
797
+ externalsType: "commonjs2",
786
798
  externalsPresets: { node: true },
787
799
  plugins: [
788
800
  new DefinePlugin(
@@ -832,7 +844,18 @@ module.exports = async function (inMeteor = {}, argv = {}) {
832
844
  devServer: { port: devServerPort },
833
845
  stats: { preset: "normal" },
834
846
  infrastructureLogging: { level: "info" },
835
- ...(isProd && isClient && { output: { module: false } }),
847
+ ...(isProd &&
848
+ isClient && {
849
+ output: {
850
+ // Nx Angular config emits ESM chunks in production by default.
851
+ // Meteor serves and minifies classic browser bundles here.
852
+ module: false,
853
+ scriptType: false,
854
+ chunkFormat: "array-push",
855
+ chunkLoading: "jsonp",
856
+ workerChunkLoading: "import-scripts",
857
+ },
858
+ }),
836
859
  }
837
860
  : {};
838
861