@meteorjs/rspack 0.0.65 → 0.0.67

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,34 @@ 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
+ "util",
94
+ "events",
95
+ "path",
96
+ "stream",
97
+ "assert",
98
+ "assert/strict",
99
+ ]);
100
+
90
101
  const names = new Set();
91
102
  for (const m of core) {
92
- names.add(m); // e.g. 'fs'
93
- names.add(`node:${m}`); // e.g. 'node:fs'
103
+ // Add both 'fs' and 'node:fs' variants
104
+ names.add(m);
105
+ names.add(`node:${m}`);
94
106
  }
95
107
  for (const x of extras) names.add(x);
96
108
 
97
- // Map every name to false (causes hard error if imported)
98
- return Object.fromEntries([...names].map((m) => [m, false]));
109
+ // Everything except the allowlist gets mapped to false
110
+ const entries = [...names]
111
+ .filter((m) => !allowlist.has(m.replace(/^node:/, "")))
112
+ .map((m) => [m, false]);
113
+
114
+ return Object.fromEntries(entries);
99
115
  }
100
116
 
101
117
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteorjs/rspack",
3
- "version": "0.0.65",
3
+ "version": "0.0.67",
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 }));