@modern-js/plugin-module-node-polyfill 0.0.0-next-20240929094052 → 0.0.0-next-20240930063021
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 +1 -2
- package/dist/index.js +5 -5
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -16
- package/package.json +4 -4
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
|
-
declare
|
|
6
|
+
export declare const modules: {
|
|
7
7
|
assert: string;
|
|
8
8
|
buffer: string;
|
|
9
9
|
child_process: null;
|
|
@@ -48,4 +48,3 @@ 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,12 +29,13 @@ 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
|
|
32
|
+
modulePluginNodePolyfill: () => modulePluginNodePolyfill,
|
|
33
|
+
modules: () => modules
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(src_exports);
|
|
35
36
|
var import_path = __toESM(require("path"));
|
|
36
37
|
var import_utils = require("./utils");
|
|
37
|
-
|
|
38
|
+
const modules = {
|
|
38
39
|
assert: require.resolve("assert/"),
|
|
39
40
|
buffer: require.resolve("buffer/"),
|
|
40
41
|
child_process: null,
|
|
@@ -75,8 +76,6 @@ let modules = {
|
|
|
75
76
|
zlib: require.resolve("browserify-zlib")
|
|
76
77
|
};
|
|
77
78
|
const getNodePolyfillHook = (polyfillOption = {}) => {
|
|
78
|
-
const nodeModules = (0, import_utils.addNodePrefix)(modules);
|
|
79
|
-
modules = Object.assign(modules, nodeModules);
|
|
80
79
|
var _polyfillOption_excludes;
|
|
81
80
|
const polyfillModules = {
|
|
82
81
|
...(0, import_utils.excludeObjectKeys)((0, import_utils.addResolveFallback)(modules, polyfillOption.overrides), (_polyfillOption_excludes = polyfillOption.excludes) !== null && _polyfillOption_excludes !== void 0 ? _polyfillOption_excludes : [])
|
|
@@ -133,5 +132,6 @@ const modulePluginNodePolyfill = (polyfillOption = {}) => ({
|
|
|
133
132
|
// Annotate the CommonJS export names for ESM import in node:
|
|
134
133
|
0 && (module.exports = {
|
|
135
134
|
getNodePolyfillHook,
|
|
136
|
-
modulePluginNodePolyfill
|
|
135
|
+
modulePluginNodePolyfill,
|
|
136
|
+
modules
|
|
137
137
|
});
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
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,7 +28,6 @@ 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,
|
|
32
31
|
addResolveFallback: () => addResolveFallback,
|
|
33
32
|
excludeObjectKeys: () => excludeObjectKeys
|
|
34
33
|
});
|
|
@@ -64,23 +63,8 @@ function addResolveFallback(object, overrides = {}) {
|
|
|
64
63
|
}
|
|
65
64
|
return newObject;
|
|
66
65
|
}
|
|
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
|
-
}
|
|
81
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
82
67
|
0 && (module.exports = {
|
|
83
|
-
addNodePrefix,
|
|
84
68
|
addResolveFallback,
|
|
85
69
|
excludeObjectKeys
|
|
86
70
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/plugin-module-node-polyfill",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240930063021",
|
|
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": "0.0.0-next-
|
|
52
|
-
"@scripts/build": "0.0.0-next-
|
|
51
|
+
"@modern-js/module-tools": "0.0.0-next-20240930063021",
|
|
52
|
+
"@scripts/build": "0.0.0-next-20240930063021"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@modern-js/module-tools": "0.0.0-next-
|
|
55
|
+
"@modern-js/module-tools": "0.0.0-next-20240930063021"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@modern-js/module-tools": {
|