@rsbuild/plugin-node-polyfill 1.0.0-alpha.0 → 1.0.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
3
+ Copyright (c) 2024 Rspack Contrib
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,19 +1,158 @@
1
- <p align="center">
2
- <a href="https://rsbuild.dev" target="blank"><img src="https://github.com/web-infra-dev/rsbuild/assets/7237365/84abc13e-b620-468f-a90b-dbf28e7e9427" alt="Rsbuild Logo" /></a>
1
+ # @rsbuild/plugin-node-polyfill
2
+
3
+ @rsbuild/plugin-node-polyfill is a Rsbuild plugin to do something.
4
+
5
+ <p>
6
+ <a href="https://npmjs.com/package/@rsbuild/plugin-node-polyfill">
7
+ <img src="https://img.shields.io/npm/v/@rsbuild/plugin-node-polyfill?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
8
+ </a>
9
+ <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
3
10
  </p>
4
11
 
5
- # Rsbuild
12
+ ## Usage
13
+
14
+ Install:
15
+
16
+ ```bash
17
+ npm add @rsbuild/plugin-node-polyfill -D
18
+ ```
19
+
20
+ Add plugin to your `rsbuild.config.ts`:
21
+
22
+ ```ts
23
+ // rsbuild.config.ts
24
+ import { pluginNodePolyfill } from "@rsbuild/plugin-node-polyfill";
25
+
26
+ export default {
27
+ plugins: [pluginNodePolyfill()],
28
+ };
29
+ ```
30
+
31
+ ## Node Polyfills
32
+
33
+ ### Globals
34
+
35
+ - `Buffer`
36
+ - `process`
37
+
38
+ When you use the above global variables in your code, the corresponding polyfill will be automatically injected.
39
+
40
+ For instance, the following code would inject the `Buffer` polyfill:
41
+
42
+ ```ts
43
+ const bufferData = Buffer.from("abc");
44
+ ```
45
+
46
+ You can disable this behavior through the `globals` option of the plugin:
47
+
48
+ ```ts
49
+ pluginNodePolyfill({
50
+ globals: {
51
+ Buffer: false,
52
+ process: false,
53
+ },
54
+ });
55
+ ```
56
+
57
+ ### Modules
58
+
59
+ - `assert`
60
+ - `buffer`
61
+ - `console`
62
+ - `constants`
63
+ - `crypto`
64
+ - `domain`
65
+ - `events`
66
+ - `http`
67
+ - `https`
68
+ - `os`
69
+ - `path`
70
+ - `punycode`
71
+ - `process`
72
+ - `querystring`
73
+ - `stream`
74
+ - `_stream_duplex`
75
+ - `_stream_passthrough`
76
+ - `_stream_readable`
77
+ - `_stream_transform`
78
+ - `_stream_writable`
79
+ - `string_decoder`
80
+ - `sys`
81
+ - `timers`
82
+ - `tty`
83
+ - `url`
84
+ - `util`
85
+ - `vm`
86
+ - `zlib`
87
+
88
+ When the above module is referenced in code via import / require syntax, the corresponding polyfill will be injected.
89
+
90
+ ```ts
91
+ import { Buffer } from "buffer";
92
+
93
+ const bufferData = Buffer.from("abc");
94
+ ```
95
+
96
+ ### Fallbacks
97
+
98
+ - `child_process`
99
+ - `cluster`
100
+ - `dgram`
101
+ - `dns`
102
+ - `fs`
103
+ - `module`
104
+ - `net`
105
+ - `readline`
106
+ - `repl`
107
+ - `tls`
108
+
109
+ Currently there is no polyfill for the above modules on the browser side, so when you import the above modules, it will automatically fallback to an empty object.
110
+
111
+ ```ts
112
+ import fs from "fs";
113
+
114
+ console.log(fs); // -> {}
115
+ ```
116
+
117
+ ## Options
118
+
119
+ ### globals
120
+
121
+ Used to specify whether to inject polyfills for global variables.
122
+
123
+ - **Type:**
124
+
125
+ ```ts
126
+ type Globals = {
127
+ process?: boolean;
128
+ Buffer?: boolean;
129
+ };
130
+ ```
131
+
132
+ - **Default:**
133
+
134
+ ```ts
135
+ const defaultGlobals = {
136
+ Buffer: true,
137
+ process: true,
138
+ };
139
+ ```
6
140
 
7
- The Rspack-based build tool. It's fast, out-of-the-box and extensible.
141
+ ### protocolImports
8
142
 
9
- ## Documentation
143
+ Whether to polyfill Node.js builtin modules starting with `node:`.
10
144
 
11
- https://rsbuild.dev/
145
+ - **Type:** `boolean`
146
+ - **Default:** `true`
12
147
 
13
- ## Contributing
148
+ For example, if you disable `protocolImports`, modules such as `node:path`, `node:http`, etc. will not be polyfilled.
14
149
 
15
- Please read the [Contributing Guide](https://github.com/web-infra-dev/rsbuild/blob/main/CONTRIBUTING.md).
150
+ ```ts
151
+ pluginNodePolyfill({
152
+ protocolImports: false,
153
+ });
154
+ ```
16
155
 
17
156
  ## License
18
157
 
19
- Rsbuild is [MIT licensed](https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE).
158
+ [MIT](./LICENSE).
@@ -0,0 +1,23 @@
1
+ import "./chunk-6C3VEZWH.js";
2
+
3
+ // src/ProtocolImportsPlugin.ts
4
+ var ProtocolImportsPlugin = class {
5
+ apply(compiler) {
6
+ compiler.hooks.normalModuleFactory.tap(
7
+ "NormalModuleReplacementPlugin",
8
+ (nmf) => {
9
+ nmf.hooks.beforeResolve.tap(
10
+ "NormalModuleReplacementPlugin",
11
+ (resource) => {
12
+ if (/^node:/.test(resource.request)) {
13
+ resource.request = resource.request.replace(/^node:/, "");
14
+ }
15
+ }
16
+ );
17
+ }
18
+ );
19
+ }
20
+ };
21
+ export {
22
+ ProtocolImportsPlugin
23
+ };
@@ -0,0 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export {
8
+ __export
9
+ };
package/dist/index.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __esm = (fn, res) => function __init() {
9
7
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
@@ -20,16 +18,18 @@ var __copyProps = (to, from, except, desc) => {
20
18
  }
21
19
  return to;
22
20
  };
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
21
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
22
 
23
+ // node_modules/.pnpm/tsup@8.0.2_postcss@8.4.38_typescript@5.5.2/node_modules/tsup/assets/cjs_shims.js
24
+ var getImportMetaUrl, importMetaUrl;
25
+ var init_cjs_shims = __esm({
26
+ "node_modules/.pnpm/tsup@8.0.2_postcss@8.4.38_typescript@5.5.2/node_modules/tsup/assets/cjs_shims.js"() {
27
+ "use strict";
28
+ getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
29
+ importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
30
+ }
31
+ });
32
+
33
33
  // src/ProtocolImportsPlugin.ts
34
34
  var ProtocolImportsPlugin_exports = {};
35
35
  __export(ProtocolImportsPlugin_exports, {
@@ -39,6 +39,7 @@ var ProtocolImportsPlugin;
39
39
  var init_ProtocolImportsPlugin = __esm({
40
40
  "src/ProtocolImportsPlugin.ts"() {
41
41
  "use strict";
42
+ init_cjs_shims();
42
43
  ProtocolImportsPlugin = class {
43
44
  apply(compiler) {
44
45
  compiler.hooks.normalModuleFactory.tap(
@@ -66,6 +67,7 @@ __export(src_exports, {
66
67
  pluginNodePolyfill: () => pluginNodePolyfill
67
68
  });
68
69
  module.exports = __toCommonJS(src_exports);
70
+ init_cjs_shims();
69
71
 
70
72
  // src/libs.ts
71
73
  var libs_exports = {};
@@ -109,44 +111,57 @@ __export(libs_exports, {
109
111
  vm: () => vm,
110
112
  zlib: () => zlib
111
113
  });
112
- var assert = require.resolve("assert/");
113
- var buffer = require.resolve("buffer/");
114
+ init_cjs_shims();
115
+ var import_node_module = require("module");
116
+ var require2 = (0, import_node_module.createRequire)(importMetaUrl);
117
+ var assert = require2.resolve("assert/");
118
+ var buffer = require2.resolve("buffer/");
114
119
  var child_process = null;
115
120
  var cluster = null;
116
- var console = require.resolve("console-browserify");
117
- var constants = require.resolve("constants-browserify");
118
- var crypto = require.resolve("crypto-browserify");
121
+ var console = require2.resolve("console-browserify");
122
+ var constants = require2.resolve("constants-browserify");
123
+ var crypto = require2.resolve("crypto-browserify");
119
124
  var dgram = null;
120
125
  var dns = null;
121
- var domain = require.resolve("domain-browser");
122
- var events = require.resolve("events/");
126
+ var domain = require2.resolve("domain-browser");
127
+ var events = require2.resolve("events/");
123
128
  var fs = null;
124
- var http = require.resolve("stream-http");
125
- var https = require.resolve("https-browserify");
129
+ var http = require2.resolve("stream-http");
130
+ var https = require2.resolve("https-browserify");
126
131
  var module2 = null;
127
132
  var net = null;
128
- var os = require.resolve("os-browserify/browser.js");
129
- var path = require.resolve("path-browserify");
130
- var punycode = require.resolve("punycode/");
131
- var process = require.resolve("process/browser.js");
132
- var querystring = require.resolve("querystring-es3/");
133
+ var os = require2.resolve("os-browserify/browser.js");
134
+ var path = require2.resolve("path-browserify");
135
+ var punycode = require2.resolve("punycode/");
136
+ var process = require2.resolve("process/browser.js");
137
+ var querystring = require2.resolve("querystring-es3/");
133
138
  var readline = null;
134
139
  var repl = null;
135
- var stream = require.resolve("stream-browserify");
136
- var _stream_duplex = require.resolve("readable-stream/lib/_stream_duplex.js");
137
- var _stream_passthrough = require.resolve("readable-stream/lib/_stream_passthrough.js");
138
- var _stream_readable = require.resolve("readable-stream/lib/_stream_readable.js");
139
- var _stream_transform = require.resolve("readable-stream/lib/_stream_transform.js");
140
- var _stream_writable = require.resolve("readable-stream/lib/_stream_writable.js");
141
- var string_decoder = require.resolve("string_decoder/");
142
- var sys = require.resolve("util/util.js");
143
- var timers = require.resolve("timers-browserify");
140
+ var stream = require2.resolve("stream-browserify");
141
+ var _stream_duplex = require2.resolve(
142
+ "readable-stream/lib/_stream_duplex.js"
143
+ );
144
+ var _stream_passthrough = require2.resolve(
145
+ "readable-stream/lib/_stream_passthrough.js"
146
+ );
147
+ var _stream_readable = require2.resolve(
148
+ "readable-stream/lib/_stream_readable.js"
149
+ );
150
+ var _stream_transform = require2.resolve(
151
+ "readable-stream/lib/_stream_transform.js"
152
+ );
153
+ var _stream_writable = require2.resolve(
154
+ "readable-stream/lib/_stream_writable.js"
155
+ );
156
+ var string_decoder = require2.resolve("string_decoder/");
157
+ var sys = require2.resolve("util/util.js");
158
+ var timers = require2.resolve("timers-browserify");
144
159
  var tls = null;
145
- var tty = require.resolve("tty-browserify");
146
- var url = require.resolve("url/");
147
- var util = require.resolve("util/util.js");
148
- var vm = require.resolve("vm-browserify");
149
- var zlib = require.resolve("browserify-zlib");
160
+ var tty = require2.resolve("tty-browserify");
161
+ var url = require2.resolve("url/");
162
+ var util = require2.resolve("util/util.js");
163
+ var vm = require2.resolve("vm-browserify");
164
+ var zlib = require2.resolve("browserify-zlib");
150
165
 
151
166
  // src/index.ts
152
167
  var getResolveFallback = (protocolImports) => {
@@ -0,0 +1,27 @@
1
+ import { RsbuildPlugin } from '@rsbuild/core';
2
+
3
+ type Globals = {
4
+ process?: boolean;
5
+ Buffer?: boolean;
6
+ };
7
+ type PluginNodePolyfillOptions = {
8
+ /**
9
+ * Whether to provide polyfill of globals.
10
+ * @default
11
+ * {
12
+ * Buffer: true,
13
+ * process: true,
14
+ * }
15
+ */
16
+ globals?: Globals;
17
+ /**
18
+ * Whether to polyfill Node.js builtin modules starting with `node:`.
19
+ * @see https://nodejs.org/api/esm.html#node-imports
20
+ * @default true
21
+ */
22
+ protocolImports?: boolean;
23
+ };
24
+ declare const PLUGIN_NODE_POLYFILL_NAME = "rsbuild:node-polyfill";
25
+ declare function pluginNodePolyfill(options?: PluginNodePolyfillOptions): RsbuildPlugin;
26
+
27
+ export { PLUGIN_NODE_POLYFILL_NAME, type PluginNodePolyfillOptions, pluginNodePolyfill };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import type { RsbuildPlugin } from '@rsbuild/core';
1
+ import { RsbuildPlugin } from '@rsbuild/core';
2
+
2
3
  type Globals = {
3
4
  process?: boolean;
4
5
  Buffer?: boolean;
5
6
  };
6
- export type PluginNodePolyfillOptions = {
7
+ type PluginNodePolyfillOptions = {
7
8
  /**
8
9
  * Whether to provide polyfill of globals.
9
10
  * @default
@@ -20,6 +21,7 @@ export type PluginNodePolyfillOptions = {
20
21
  */
21
22
  protocolImports?: boolean;
22
23
  };
23
- export declare const PLUGIN_NODE_POLYFILL_NAME = "rsbuild:node-polyfill";
24
- export declare function pluginNodePolyfill(options?: PluginNodePolyfillOptions): RsbuildPlugin;
25
- export {};
24
+ declare const PLUGIN_NODE_POLYFILL_NAME = "rsbuild:node-polyfill";
25
+ declare function pluginNodePolyfill(options?: PluginNodePolyfillOptions): RsbuildPlugin;
26
+
27
+ export { PLUGIN_NODE_POLYFILL_NAME, type PluginNodePolyfillOptions, pluginNodePolyfill };
package/dist/index.js CHANGED
@@ -1,64 +1,6 @@
1
- import { createRequire } from 'module';
2
- var require = createRequire(import.meta['url']);
3
-
4
- var __defProp = Object.defineProperty;
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
- });
13
- var __esm = (fn, res) => function __init() {
14
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
- };
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
-
21
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.54.5_eslint@9.6.0_typescript@5.5.2/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.54.5_eslint@9.6.0_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js"() {
26
- "use strict";
27
- }
28
- });
29
-
30
- // src/ProtocolImportsPlugin.ts
31
- var ProtocolImportsPlugin_exports = {};
32
- __export(ProtocolImportsPlugin_exports, {
33
- ProtocolImportsPlugin: () => ProtocolImportsPlugin
34
- });
35
- var ProtocolImportsPlugin;
36
- var init_ProtocolImportsPlugin = __esm({
37
- "src/ProtocolImportsPlugin.ts"() {
38
- "use strict";
39
- init_esm();
40
- ProtocolImportsPlugin = class {
41
- apply(compiler) {
42
- compiler.hooks.normalModuleFactory.tap(
43
- "NormalModuleReplacementPlugin",
44
- (nmf) => {
45
- nmf.hooks.beforeResolve.tap(
46
- "NormalModuleReplacementPlugin",
47
- (resource) => {
48
- if (/^node:/.test(resource.request)) {
49
- resource.request = resource.request.replace(/^node:/, "");
50
- }
51
- }
52
- );
53
- }
54
- );
55
- }
56
- };
57
- }
58
- });
59
-
60
- // src/index.ts
61
- init_esm();
1
+ import {
2
+ __export
3
+ } from "./chunk-6C3VEZWH.js";
62
4
 
63
5
  // src/libs.ts
64
6
  var libs_exports = {};
@@ -85,7 +27,7 @@ __export(libs_exports, {
85
27
  module: () => module,
86
28
  net: () => net,
87
29
  os: () => os,
88
- path: () => path2,
30
+ path: () => path,
89
31
  process: () => process,
90
32
  punycode: () => punycode,
91
33
  querystring: () => querystring,
@@ -102,55 +44,56 @@ __export(libs_exports, {
102
44
  vm: () => vm,
103
45
  zlib: () => zlib
104
46
  });
105
- init_esm();
106
- var assert = __require.resolve("assert/");
107
- var buffer = __require.resolve("buffer/");
47
+ import { createRequire } from "node:module";
48
+ var require2 = createRequire(import.meta.url);
49
+ var assert = require2.resolve("assert/");
50
+ var buffer = require2.resolve("buffer/");
108
51
  var child_process = null;
109
52
  var cluster = null;
110
- var console = __require.resolve("console-browserify");
111
- var constants = __require.resolve("constants-browserify");
112
- var crypto = __require.resolve("crypto-browserify");
53
+ var console = require2.resolve("console-browserify");
54
+ var constants = require2.resolve("constants-browserify");
55
+ var crypto = require2.resolve("crypto-browserify");
113
56
  var dgram = null;
114
57
  var dns = null;
115
- var domain = __require.resolve("domain-browser");
116
- var events = __require.resolve("events/");
58
+ var domain = require2.resolve("domain-browser");
59
+ var events = require2.resolve("events/");
117
60
  var fs = null;
118
- var http = __require.resolve("stream-http");
119
- var https = __require.resolve("https-browserify");
61
+ var http = require2.resolve("stream-http");
62
+ var https = require2.resolve("https-browserify");
120
63
  var module = null;
121
64
  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/");
65
+ var os = require2.resolve("os-browserify/browser.js");
66
+ var path = require2.resolve("path-browserify");
67
+ var punycode = require2.resolve("punycode/");
68
+ var process = require2.resolve("process/browser.js");
69
+ var querystring = require2.resolve("querystring-es3/");
127
70
  var readline = null;
128
71
  var repl = null;
129
- var stream = __require.resolve("stream-browserify");
130
- var _stream_duplex = __require.resolve(
72
+ var stream = require2.resolve("stream-browserify");
73
+ var _stream_duplex = require2.resolve(
131
74
  "readable-stream/lib/_stream_duplex.js"
132
75
  );
133
- var _stream_passthrough = __require.resolve(
76
+ var _stream_passthrough = require2.resolve(
134
77
  "readable-stream/lib/_stream_passthrough.js"
135
78
  );
136
- var _stream_readable = __require.resolve(
79
+ var _stream_readable = require2.resolve(
137
80
  "readable-stream/lib/_stream_readable.js"
138
81
  );
139
- var _stream_transform = __require.resolve(
82
+ var _stream_transform = require2.resolve(
140
83
  "readable-stream/lib/_stream_transform.js"
141
84
  );
142
- var _stream_writable = __require.resolve(
85
+ var _stream_writable = require2.resolve(
143
86
  "readable-stream/lib/_stream_writable.js"
144
87
  );
145
- var string_decoder = __require.resolve("string_decoder/");
146
- var sys = __require.resolve("util/util.js");
147
- var timers = __require.resolve("timers-browserify");
88
+ var string_decoder = require2.resolve("string_decoder/");
89
+ var sys = require2.resolve("util/util.js");
90
+ var timers = require2.resolve("timers-browserify");
148
91
  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");
92
+ var tty = require2.resolve("tty-browserify");
93
+ var url = require2.resolve("url/");
94
+ var util = require2.resolve("util/util.js");
95
+ var vm = require2.resolve("vm-browserify");
96
+ var zlib = require2.resolve("browserify-zlib");
154
97
 
155
98
  // src/index.ts
156
99
  var getResolveFallback = (protocolImports) => {
@@ -190,8 +133,8 @@ function pluginNodePolyfill(options = {}) {
190
133
  chain.plugin(CHAIN_ID.PLUGIN.NODE_POLYFILL_PROVIDE).use(bundler.ProvidePlugin, [provideGlobals]);
191
134
  }
192
135
  if (protocolImports) {
193
- const { ProtocolImportsPlugin: ProtocolImportsPlugin2 } = await Promise.resolve().then(() => (init_ProtocolImportsPlugin(), ProtocolImportsPlugin_exports));
194
- chain.plugin("protocol-imports").use(ProtocolImportsPlugin2);
136
+ const { ProtocolImportsPlugin } = await import("./ProtocolImportsPlugin-HUSWFIAE.js");
137
+ chain.plugin("protocol-imports").use(ProtocolImportsPlugin);
195
138
  }
196
139
  });
197
140
  }
package/package.json CHANGED
@@ -1,13 +1,7 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-node-polyfill",
3
- "version": "1.0.0-alpha.0",
4
- "description": "Node polyfill plugin for Rsbuild",
5
- "homepage": "https://rsbuild.dev",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/web-infra-dev/rsbuild",
9
- "directory": "packages/plugin-node-polyfill"
10
- },
3
+ "version": "1.0.1",
4
+ "repository": "https://github.com/rspack-contrib/rsbuild-plugin-template",
11
5
  "license": "MIT",
12
6
  "type": "module",
13
7
  "exports": {
@@ -17,11 +11,20 @@
17
11
  "require": "./dist/index.cjs"
18
12
  }
19
13
  },
20
- "main": "./dist/index.cjs",
14
+ "main": "./dist/index.js",
15
+ "module": "./dist/index.mjs",
21
16
  "types": "./dist/index.d.ts",
22
17
  "files": [
23
18
  "dist"
24
19
  ],
20
+ "simple-git-hooks": {
21
+ "pre-commit": "npx nano-staged"
22
+ },
23
+ "nano-staged": {
24
+ "*.{js,jsx,ts,tsx,mjs,cjs}": [
25
+ "biome check --write --no-errors-on-unmatched"
26
+ ]
27
+ },
25
28
  "dependencies": {
26
29
  "assert": "^2.1.0",
27
30
  "browserify-zlib": "^0.2.0",
@@ -48,19 +51,33 @@
48
51
  "vm-browserify": "^1.1.2"
49
52
  },
50
53
  "devDependencies": {
51
- "typescript": "^5.5.2",
52
- "@rsbuild/core": "1.0.0-alpha.0"
54
+ "@biomejs/biome": "^1.8.3",
55
+ "@playwright/test": "^1.44.1",
56
+ "@rsbuild/core": "^0.7.10",
57
+ "@types/node": "^20.14.1",
58
+ "nano-staged": "^0.8.0",
59
+ "playwright": "^1.44.1",
60
+ "simple-git-hooks": "^2.11.1",
61
+ "tsup": "^8.0.2",
62
+ "typescript": "^5.5.2"
53
63
  },
54
64
  "peerDependencies": {
55
- "@rsbuild/core": "^1.0.0-alpha.0"
65
+ "@rsbuild/core": "0.x || 1.x"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "@rsbuild/core": {
69
+ "optional": true
70
+ }
56
71
  },
57
72
  "publishConfig": {
58
73
  "access": "public",
59
- "provenance": true,
60
74
  "registry": "https://registry.npmjs.org/"
61
75
  },
62
76
  "scripts": {
63
- "build": "modern build",
64
- "dev": "modern build --watch"
77
+ "build": "tsup",
78
+ "dev": "tsup --watch",
79
+ "lint": "biome check .",
80
+ "lint:write": "biome check . --write",
81
+ "test": "playwright test"
65
82
  }
66
83
  }
@@ -1,4 +0,0 @@
1
- import type { Rspack } from '@rsbuild/core';
2
- export declare class ProtocolImportsPlugin {
3
- apply(compiler: Rspack.Compiler): void;
4
- }
package/dist/libs.d.ts DELETED
@@ -1,38 +0,0 @@
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;