@meteorjs/rspack 0.0.65 → 0.0.66

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.
@@ -84,18 +84,35 @@ function setCache(
84
84
  * - Optional extras let you block non-core modules too
85
85
  */
86
86
  function makeWebNodeBuiltinsAlias(extras = []) {
87
- // Strip potential 'node:' prefixes then add both forms
87
+ // Node core list, normalized (strip `node:` prefix)
88
88
  const core = new Set(builtinModules.map((m) => m.replace(/^node:/, "")));
89
89
 
90
+ // browser-safe allowlist (these we *don't* mark as false)
91
+ const allowlist = new Set([
92
+ "process",
93
+ "buffer",
94
+ "util",
95
+ "events",
96
+ "path",
97
+ "stream",
98
+ "assert",
99
+ "assert/strict",
100
+ ]);
101
+
90
102
  const names = new Set();
91
103
  for (const m of core) {
92
- names.add(m); // e.g. 'fs'
93
- names.add(`node:${m}`); // e.g. 'node:fs'
104
+ // Add both 'fs' and 'node:fs' variants
105
+ names.add(m);
106
+ names.add(`node:${m}`);
94
107
  }
95
108
  for (const x of extras) names.add(x);
96
109
 
97
- // Map every name to false (causes hard error if imported)
98
- return Object.fromEntries([...names].map((m) => [m, false]));
110
+ // Everything except the allowlist gets mapped to false
111
+ const entries = [...names]
112
+ .filter((m) => !allowlist.has(m.replace(/^node:/, "")))
113
+ .map((m) => [m, false]);
114
+
115
+ return Object.fromEntries(entries);
99
116
  }
100
117
 
101
118
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteorjs/rspack",
3
- "version": "0.0.65",
3
+ "version": "0.0.66",
4
4
  "description": "Configuration logic for using Rspack in Meteor projects",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
@@ -9,6 +9,7 @@
9
9
  "dependencies": {
10
10
  "fast-deep-equal": "^3.1.3",
11
11
  "ignore-loader": "^0.1.2",
12
+ "node-polyfill-webpack-plugin": "^4.1.0",
12
13
  "webpack-merge": "^6.0.1"
13
14
  },
14
15
  "peerDependencies": {
package/rspack.config.js CHANGED
@@ -3,6 +3,7 @@ const fs = require('fs');
3
3
  const { inspect } = require('node:util');
4
4
  const path = require('path');
5
5
  const { merge } = require('webpack-merge');
6
+ const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
6
7
 
7
8
  const { cleanOmittedPaths, mergeSplitOverlap } = require("./lib/mergeRulesSplitOverlap.js");
8
9
  const { getMeteorAppSwcConfig } = require('./lib/swc.js');
@@ -477,15 +478,6 @@ module.exports = async function (inMeteor = {}, argv = {}) {
477
478
  : []),
478
479
  ...extraRules,
479
480
  ],
480
- ...(Meteor.isTest && {
481
- parser: {
482
- javascript: {
483
- dynamicImportMode: 'eager',
484
- dynamicImportPrefetch: true,
485
- dynamicImportPreload: true
486
- },
487
- },
488
- }),
489
481
  },
490
482
  resolve: { extensions, alias, fallback },
491
483
  externals,
@@ -703,10 +695,31 @@ module.exports = async function (inMeteor = {}, argv = {}) {
703
695
  }
704
696
  : {};
705
697
 
706
- const config = mergeSplitOverlap(
698
+ // Establish test client overrides to ensure proper running
699
+ const testClientExpandConfig =
700
+ isTest && isClient
701
+ ? {
702
+ module: {
703
+ parser: {
704
+ javascript: {
705
+ dynamicImportMode: "eager",
706
+ dynamicImportPrefetch: true,
707
+ dynamicImportPreload: true,
708
+ },
709
+ },
710
+ },
711
+ optimization: {
712
+ splitChunks: false,
713
+ },
714
+ plugins: [new NodePolyfillPlugin()],
715
+ }
716
+ : {};
717
+
718
+ let config = mergeSplitOverlap(
707
719
  isClient ? clientConfig : serverConfig,
708
720
  angularExpandConfig
709
721
  );
722
+ config = mergeSplitOverlap(config, testClientExpandConfig);
710
723
 
711
724
  if (Meteor.isDebug || Meteor.isVerbose) {
712
725
  console.log('Config:', inspect(config, { depth: null, colors: true }));