@rsbuild/plugin-node-polyfill 0.6.14 → 0.7.0-beta.0

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.
@@ -0,0 +1,4 @@
1
+ import type { Rspack } from '@rsbuild/core';
2
+ export declare class ProtocolImportsPlugin {
3
+ apply(compiler: Rspack.Compiler): void;
4
+ }
@@ -1,15 +1,10 @@
1
- import { createRequire } from 'module';
2
- var require = createRequire(import.meta['url']);
3
-
1
+ "use strict";
2
+ var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
7
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
8
- }) : x)(function(x) {
9
- if (typeof require !== "undefined")
10
- return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
8
  var __esm = (fn, res) => function __init() {
14
9
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
10
  };
@@ -17,15 +12,23 @@ var __export = (target, all) => {
17
12
  for (var name in all)
18
13
  __defProp(target, name, { get: all[name], enumerable: true });
19
14
  };
20
-
21
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.2_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
22
- import { fileURLToPath } from "url";
23
- import path from "path";
24
- var init_esm = __esm({
25
- "../../node_modules/.pnpm/@modern-js+module-tools@2.49.2_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
26
- "use strict";
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
20
  }
28
- });
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
30
33
  // src/ProtocolImportsPlugin.ts
31
34
  var ProtocolImportsPlugin_exports = {};
@@ -36,7 +39,6 @@ var ProtocolImportsPlugin;
36
39
  var init_ProtocolImportsPlugin = __esm({
37
40
  "src/ProtocolImportsPlugin.ts"() {
38
41
  "use strict";
39
- init_esm();
40
42
  ProtocolImportsPlugin = class {
41
43
  apply(compiler) {
42
44
  compiler.hooks.normalModuleFactory.tap(
@@ -58,7 +60,11 @@ var init_ProtocolImportsPlugin = __esm({
58
60
  });
59
61
 
60
62
  // src/index.ts
61
- init_esm();
63
+ var src_exports = {};
64
+ __export(src_exports, {
65
+ pluginNodePolyfill: () => pluginNodePolyfill
66
+ });
67
+ module.exports = __toCommonJS(src_exports);
62
68
 
63
69
  // src/libs.ts
64
70
  var libs_exports = {};
@@ -82,10 +88,10 @@ __export(libs_exports, {
82
88
  fs: () => fs,
83
89
  http: () => http,
84
90
  https: () => https,
85
- module: () => module,
91
+ module: () => module2,
86
92
  net: () => net,
87
93
  os: () => os,
88
- path: () => path2,
94
+ path: () => path,
89
95
  process: () => process,
90
96
  punycode: () => punycode,
91
97
  querystring: () => querystring,
@@ -102,55 +108,44 @@ __export(libs_exports, {
102
108
  vm: () => vm,
103
109
  zlib: () => zlib
104
110
  });
105
- init_esm();
106
- var assert = __require.resolve("assert/");
107
- var buffer = __require.resolve("buffer/");
111
+ var assert = require.resolve("assert/");
112
+ var buffer = require.resolve("buffer/");
108
113
  var child_process = null;
109
114
  var cluster = null;
110
- var console = __require.resolve("console-browserify");
111
- var constants = __require.resolve("constants-browserify");
112
- var crypto = __require.resolve("crypto-browserify");
115
+ var console = require.resolve("console-browserify");
116
+ var constants = require.resolve("constants-browserify");
117
+ var crypto = require.resolve("crypto-browserify");
113
118
  var dgram = null;
114
119
  var dns = null;
115
- var domain = __require.resolve("domain-browser");
116
- var events = __require.resolve("events/");
120
+ var domain = require.resolve("domain-browser");
121
+ var events = require.resolve("events/");
117
122
  var fs = null;
118
- var http = __require.resolve("stream-http");
119
- var https = __require.resolve("https-browserify");
120
- var module = null;
123
+ var http = require.resolve("stream-http");
124
+ var https = require.resolve("https-browserify");
125
+ var module2 = null;
121
126
  var net = null;
122
- var os = __require.resolve("os-browserify/browser.js");
123
- var path2 = __require.resolve("path-browserify");
124
- var punycode = __require.resolve("punycode/");
125
- var process = __require.resolve("process/browser.js");
126
- var querystring = __require.resolve("querystring-es3/");
127
+ var os = require.resolve("os-browserify/browser.js");
128
+ var path = require.resolve("path-browserify");
129
+ var punycode = require.resolve("punycode/");
130
+ var process = require.resolve("process/browser.js");
131
+ var querystring = require.resolve("querystring-es3/");
127
132
  var readline = null;
128
133
  var repl = null;
129
- var stream = __require.resolve("stream-browserify");
130
- var _stream_duplex = __require.resolve(
131
- "readable-stream/lib/_stream_duplex.js"
132
- );
133
- var _stream_passthrough = __require.resolve(
134
- "readable-stream/lib/_stream_passthrough.js"
135
- );
136
- var _stream_readable = __require.resolve(
137
- "readable-stream/lib/_stream_readable.js"
138
- );
139
- var _stream_transform = __require.resolve(
140
- "readable-stream/lib/_stream_transform.js"
141
- );
142
- var _stream_writable = __require.resolve(
143
- "readable-stream/lib/_stream_writable.js"
144
- );
145
- var string_decoder = __require.resolve("string_decoder/");
146
- var sys = __require.resolve("util/util.js");
147
- var timers = __require.resolve("timers-browserify");
134
+ var stream = require.resolve("stream-browserify");
135
+ var _stream_duplex = require.resolve("readable-stream/lib/_stream_duplex.js");
136
+ var _stream_passthrough = require.resolve("readable-stream/lib/_stream_passthrough.js");
137
+ var _stream_readable = require.resolve("readable-stream/lib/_stream_readable.js");
138
+ var _stream_transform = require.resolve("readable-stream/lib/_stream_transform.js");
139
+ var _stream_writable = require.resolve("readable-stream/lib/_stream_writable.js");
140
+ var string_decoder = require.resolve("string_decoder/");
141
+ var sys = require.resolve("util/util.js");
142
+ var timers = require.resolve("timers-browserify");
148
143
  var tls = null;
149
- var tty = __require.resolve("tty-browserify");
150
- var url = __require.resolve("url/");
151
- var util = __require.resolve("util/util.js");
152
- var vm = __require.resolve("vm-browserify");
153
- var zlib = __require.resolve("browserify-zlib");
144
+ var tty = require.resolve("tty-browserify");
145
+ var url = require.resolve("url/");
146
+ var util = require.resolve("util/util.js");
147
+ var vm = require.resolve("vm-browserify");
148
+ var zlib = require.resolve("browserify-zlib");
154
149
 
155
150
  // src/index.ts
156
151
  var getResolveFallback = (protocolImports) => {
@@ -196,6 +191,7 @@ function pluginNodePolyfill(options = {}) {
196
191
  }
197
192
  };
198
193
  }
199
- export {
194
+ // Annotate the CommonJS export names for ESM import in node:
195
+ 0 && (module.exports = {
200
196
  pluginNodePolyfill
201
- };
197
+ });
package/dist/index.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
-
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
3
2
  type Globals = {
4
3
  process?: boolean;
5
4
  Buffer?: boolean;
6
5
  };
7
- type PluginNodePolyfillOptions = {
6
+ export type PluginNodePolyfillOptions = {
8
7
  /**
9
8
  * Whether to provide polyfill of globals.
10
9
  * @default
@@ -21,6 +20,5 @@ type PluginNodePolyfillOptions = {
21
20
  */
22
21
  protocolImports?: boolean;
23
22
  };
24
- declare function pluginNodePolyfill(options?: PluginNodePolyfillOptions): RsbuildPlugin;
25
-
26
- export { type PluginNodePolyfillOptions, pluginNodePolyfill };
23
+ export declare function pluginNodePolyfill(options?: PluginNodePolyfillOptions): RsbuildPlugin;
24
+ export {};
package/dist/index.js CHANGED
@@ -1,10 +1,15 @@
1
- "use strict";
2
- var __create = Object.create;
1
+ import { createRequire } from 'module';
2
+ var require = createRequire(import.meta['url']);
3
+
3
4
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
7
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
8
+ }) : x)(function(x) {
9
+ if (typeof require !== "undefined")
10
+ return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
8
13
  var __esm = (fn, res) => function __init() {
9
14
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
15
  };
@@ -12,23 +17,15 @@ var __export = (target, all) => {
12
17
  for (var name in all)
13
18
  __defProp(target, name, { get: all[name], enumerable: true });
14
19
  };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+
21
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
22
+ import { fileURLToPath } from "url";
23
+ import path from "path";
24
+ var init_esm = __esm({
25
+ "../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
26
+ "use strict";
20
27
  }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ });
32
29
 
33
30
  // src/ProtocolImportsPlugin.ts
34
31
  var ProtocolImportsPlugin_exports = {};
@@ -39,6 +36,7 @@ var ProtocolImportsPlugin;
39
36
  var init_ProtocolImportsPlugin = __esm({
40
37
  "src/ProtocolImportsPlugin.ts"() {
41
38
  "use strict";
39
+ init_esm();
42
40
  ProtocolImportsPlugin = class {
43
41
  apply(compiler) {
44
42
  compiler.hooks.normalModuleFactory.tap(
@@ -60,11 +58,7 @@ var init_ProtocolImportsPlugin = __esm({
60
58
  });
61
59
 
62
60
  // src/index.ts
63
- var src_exports = {};
64
- __export(src_exports, {
65
- pluginNodePolyfill: () => pluginNodePolyfill
66
- });
67
- module.exports = __toCommonJS(src_exports);
61
+ init_esm();
68
62
 
69
63
  // src/libs.ts
70
64
  var libs_exports = {};
@@ -88,10 +82,10 @@ __export(libs_exports, {
88
82
  fs: () => fs,
89
83
  http: () => http,
90
84
  https: () => https,
91
- module: () => module2,
85
+ module: () => module,
92
86
  net: () => net,
93
87
  os: () => os,
94
- path: () => path,
88
+ path: () => path2,
95
89
  process: () => process,
96
90
  punycode: () => punycode,
97
91
  querystring: () => querystring,
@@ -108,44 +102,55 @@ __export(libs_exports, {
108
102
  vm: () => vm,
109
103
  zlib: () => zlib
110
104
  });
111
- var assert = require.resolve("assert/");
112
- var buffer = require.resolve("buffer/");
105
+ init_esm();
106
+ var assert = __require.resolve("assert/");
107
+ var buffer = __require.resolve("buffer/");
113
108
  var child_process = null;
114
109
  var cluster = null;
115
- var console = require.resolve("console-browserify");
116
- var constants = require.resolve("constants-browserify");
117
- var crypto = require.resolve("crypto-browserify");
110
+ var console = __require.resolve("console-browserify");
111
+ var constants = __require.resolve("constants-browserify");
112
+ var crypto = __require.resolve("crypto-browserify");
118
113
  var dgram = null;
119
114
  var dns = null;
120
- var domain = require.resolve("domain-browser");
121
- var events = require.resolve("events/");
115
+ var domain = __require.resolve("domain-browser");
116
+ var events = __require.resolve("events/");
122
117
  var fs = null;
123
- var http = require.resolve("stream-http");
124
- var https = require.resolve("https-browserify");
125
- var module2 = null;
118
+ var http = __require.resolve("stream-http");
119
+ var https = __require.resolve("https-browserify");
120
+ var module = null;
126
121
  var net = null;
127
- var os = require.resolve("os-browserify/browser.js");
128
- var path = require.resolve("path-browserify");
129
- var punycode = require.resolve("punycode/");
130
- var process = require.resolve("process/browser.js");
131
- var querystring = require.resolve("querystring-es3/");
122
+ var os = __require.resolve("os-browserify/browser.js");
123
+ var path2 = __require.resolve("path-browserify");
124
+ var punycode = __require.resolve("punycode/");
125
+ var process = __require.resolve("process/browser.js");
126
+ var querystring = __require.resolve("querystring-es3/");
132
127
  var readline = null;
133
128
  var repl = null;
134
- var stream = require.resolve("stream-browserify");
135
- var _stream_duplex = require.resolve("readable-stream/lib/_stream_duplex.js");
136
- var _stream_passthrough = require.resolve("readable-stream/lib/_stream_passthrough.js");
137
- var _stream_readable = require.resolve("readable-stream/lib/_stream_readable.js");
138
- var _stream_transform = require.resolve("readable-stream/lib/_stream_transform.js");
139
- var _stream_writable = require.resolve("readable-stream/lib/_stream_writable.js");
140
- var string_decoder = require.resolve("string_decoder/");
141
- var sys = require.resolve("util/util.js");
142
- var timers = require.resolve("timers-browserify");
129
+ var stream = __require.resolve("stream-browserify");
130
+ var _stream_duplex = __require.resolve(
131
+ "readable-stream/lib/_stream_duplex.js"
132
+ );
133
+ var _stream_passthrough = __require.resolve(
134
+ "readable-stream/lib/_stream_passthrough.js"
135
+ );
136
+ var _stream_readable = __require.resolve(
137
+ "readable-stream/lib/_stream_readable.js"
138
+ );
139
+ var _stream_transform = __require.resolve(
140
+ "readable-stream/lib/_stream_transform.js"
141
+ );
142
+ var _stream_writable = __require.resolve(
143
+ "readable-stream/lib/_stream_writable.js"
144
+ );
145
+ var string_decoder = __require.resolve("string_decoder/");
146
+ var sys = __require.resolve("util/util.js");
147
+ var timers = __require.resolve("timers-browserify");
143
148
  var tls = null;
144
- var tty = require.resolve("tty-browserify");
145
- var url = require.resolve("url/");
146
- var util = require.resolve("util/util.js");
147
- var vm = require.resolve("vm-browserify");
148
- var zlib = require.resolve("browserify-zlib");
149
+ var tty = __require.resolve("tty-browserify");
150
+ var url = __require.resolve("url/");
151
+ var util = __require.resolve("util/util.js");
152
+ var vm = __require.resolve("vm-browserify");
153
+ var zlib = __require.resolve("browserify-zlib");
149
154
 
150
155
  // src/index.ts
151
156
  var getResolveFallback = (protocolImports) => {
@@ -191,7 +196,6 @@ function pluginNodePolyfill(options = {}) {
191
196
  }
192
197
  };
193
198
  }
194
- // Annotate the CommonJS export names for ESM import in node:
195
- 0 && (module.exports = {
199
+ export {
196
200
  pluginNodePolyfill
197
- });
201
+ };
package/dist/libs.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ export declare const assert: string;
2
+ export declare const buffer: string;
3
+ export declare const child_process: null;
4
+ export declare const cluster: null;
5
+ export declare const console: string;
6
+ export declare const constants: string;
7
+ export declare const crypto: string;
8
+ export declare const dgram: null;
9
+ export declare const dns: null;
10
+ export declare const domain: string;
11
+ export declare const events: string;
12
+ export declare const fs: null;
13
+ export declare const http: string;
14
+ export declare const https: string;
15
+ export declare const module: null;
16
+ export declare const net: null;
17
+ export declare const os: string;
18
+ export declare const path: string;
19
+ export declare const punycode: string;
20
+ export declare const process: string;
21
+ export declare const querystring: string;
22
+ export declare const readline: null;
23
+ export declare const repl: null;
24
+ export declare const stream: string;
25
+ export declare const _stream_duplex: string;
26
+ export declare const _stream_passthrough: string;
27
+ export declare const _stream_readable: string;
28
+ export declare const _stream_transform: string;
29
+ export declare const _stream_writable: string;
30
+ export declare const string_decoder: string;
31
+ export declare const sys: string;
32
+ export declare const timers: string;
33
+ export declare const tls: null;
34
+ export declare const tty: string;
35
+ export declare const url: string;
36
+ export declare const util: string;
37
+ export declare const vm: string;
38
+ export declare const zlib: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-node-polyfill",
3
- "version": "0.6.14",
3
+ "version": "0.7.0-beta.0",
4
4
  "description": "Node polyfill plugin for Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -9,15 +9,15 @@
9
9
  "directory": "packages/plugin-node-polyfill"
10
10
  },
11
11
  "license": "MIT",
12
- "type": "commonjs",
12
+ "type": "module",
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
- "import": "./dist/index.mjs",
17
- "default": "./dist/index.js"
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
18
  }
19
19
  },
20
- "main": "./dist/index.js",
20
+ "main": "./dist/index.cjs",
21
21
  "types": "./dist/index.d.ts",
22
22
  "files": [
23
23
  "dist"
@@ -46,14 +46,14 @@
46
46
  "url": "^0.11.3",
47
47
  "util": "^0.12.5",
48
48
  "vm-browserify": "^1.1.2",
49
- "@rsbuild/shared": "0.6.14"
49
+ "@rsbuild/shared": "0.7.0-beta.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "typescript": "^5.4.2",
53
- "@rsbuild/core": "0.6.14"
53
+ "@rsbuild/core": "0.7.0-beta.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@rsbuild/core": "^0.6.14"
56
+ "@rsbuild/core": "^0.7.0-beta.0"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public",