@modern-js/plugin-module-node-polyfill 2.60.2 → 2.60.3

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/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export interface NodePolyfillPluginOptions {
3
3
  excludes?: string[];
4
4
  overrides?: Partial<Record<keyof typeof modules, string>>;
5
5
  }
6
- export declare const modules: {
6
+ declare let modules: {
7
7
  assert: string;
8
8
  buffer: string;
9
9
  child_process: null;
@@ -48,3 +48,4 @@ export declare const getNodePolyfillHook: (polyfillOption?: NodePolyfillPluginOp
48
48
  apply(compiler: ICompiler): void;
49
49
  };
50
50
  export declare const modulePluginNodePolyfill: (polyfillOption?: NodePolyfillPluginOptions) => CliPlugin<ModuleTools>;
51
+ export {};
package/dist/index.js CHANGED
@@ -29,13 +29,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var src_exports = {};
30
30
  __export(src_exports, {
31
31
  getNodePolyfillHook: () => getNodePolyfillHook,
32
- modulePluginNodePolyfill: () => modulePluginNodePolyfill,
33
- modules: () => modules
32
+ modulePluginNodePolyfill: () => modulePluginNodePolyfill
34
33
  });
35
34
  module.exports = __toCommonJS(src_exports);
36
35
  var import_path = __toESM(require("path"));
37
36
  var import_utils = require("./utils");
38
- const modules = {
37
+ let modules = {
39
38
  assert: require.resolve("assert/"),
40
39
  buffer: require.resolve("buffer/"),
41
40
  child_process: null,
@@ -76,6 +75,8 @@ const modules = {
76
75
  zlib: require.resolve("browserify-zlib")
77
76
  };
78
77
  const getNodePolyfillHook = (polyfillOption = {}) => {
78
+ const nodeModules = (0, import_utils.addNodePrefix)(modules);
79
+ modules = Object.assign(modules, nodeModules);
79
80
  var _polyfillOption_excludes;
80
81
  const polyfillModules = {
81
82
  ...(0, import_utils.excludeObjectKeys)((0, import_utils.addResolveFallback)(modules, polyfillOption.overrides), (_polyfillOption_excludes = polyfillOption.excludes) !== null && _polyfillOption_excludes !== void 0 ? _polyfillOption_excludes : [])
@@ -132,6 +133,5 @@ const modulePluginNodePolyfill = (polyfillOption = {}) => ({
132
133
  // Annotate the CommonJS export names for ESM import in node:
133
134
  0 && (module.exports = {
134
135
  getNodePolyfillHook,
135
- modulePluginNodePolyfill,
136
- modules
136
+ modulePluginNodePolyfill
137
137
  });
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare function excludeObjectKeys(object: Record<string, string>, keys: string[]): Record<string, string>;
2
2
  export declare function addResolveFallback(object: Record<string, string | null>, overrides?: Record<string, string>): Record<string, string>;
3
+ export declare function addNodePrefix(modules: Record<string, string | null>): Record<string, string | null>;
package/dist/utils.js CHANGED
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var utils_exports = {};
30
30
  __export(utils_exports, {
31
+ addNodePrefix: () => addNodePrefix,
31
32
  addResolveFallback: () => addResolveFallback,
32
33
  excludeObjectKeys: () => excludeObjectKeys
33
34
  });
@@ -63,8 +64,23 @@ function addResolveFallback(object, overrides = {}) {
63
64
  }
64
65
  return newObject;
65
66
  }
67
+ function addNodePrefix(modules) {
68
+ return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
69
+ if (!key.startsWith("_")) {
70
+ return [
71
+ `node:${key}`,
72
+ value
73
+ ];
74
+ }
75
+ return [
76
+ key,
77
+ value
78
+ ];
79
+ }));
80
+ }
66
81
  // Annotate the CommonJS export names for ESM import in node:
67
82
  0 && (module.exports = {
83
+ addNodePrefix,
68
84
  addResolveFallback,
69
85
  excludeObjectKeys
70
86
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js/plugin-module-node-polyfill",
3
- "version": "2.60.2",
3
+ "version": "2.60.3",
4
4
  "description": "The node polyfill plugin of Modern.js Module",
5
5
  "keywords": [
6
6
  "react",
@@ -48,11 +48,11 @@
48
48
  "devDependencies": {
49
49
  "@types/node": "^14",
50
50
  "typescript": "^5",
51
- "@modern-js/module-tools": "2.60.2",
52
- "@scripts/build": "2.60.2"
51
+ "@modern-js/module-tools": "2.60.3",
52
+ "@scripts/build": "2.60.3"
53
53
  },
54
54
  "peerDependencies": {
55
- "@modern-js/module-tools": "^2.60.2"
55
+ "@modern-js/module-tools": "^2.60.3"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "@modern-js/module-tools": {