You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow callback to replace polyfill with alternative implementation
add tests for callbacks
update readme to reflect changes, document callback, update footnotes for cypto and fs modules
Copy file name to clipboardExpand all lines: readme.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ rollup({
54
54
-`sourceMap: boolean`: True to get source maps, false otherwise.
55
55
56
56
-`prefixExternals: boolean;`: If a polyfill is skipped using `onPolyfill` callback, include prefix `node:` on the module name, see `onPolyfill`
57
-
-`onPolyfill: (module: string) => boolean;`: Default, allow all. Allow project to opt-out of one or more polyfills, skipped modules are preserved as `import "module"` or `import "node:module"`
57
+
-`onPolyfill: (module: string, implementation: string | undefined) => boolean | string;`: Default, allow all. Allow project to opt-out or replace one or more polyfills, returning false sets modules to resolve as external (e.g. `import "module"` or `import "node:module"`), or return an alternative polyfill implementation as a string value, undefined `implementation` indicates that an empty shim is being used.
58
58
59
59
## Node.js Builtin Support Table
60
60
@@ -90,9 +90,9 @@ The following modules include ES6 specific version which allow you to do named i
90
90
- readline∆
91
91
- repl∆
92
92
- tls∆
93
-
- fs˚
94
-
- crypto˚
95
-
- perf_hooks˚ - **New:* just an empty shim for now, but would love help building a true polyfill!*
93
+
- fs∆
94
+
- crypto∆
95
+
- perf_hooks∆ - **New:* just an empty shim for now, but would love help building a true polyfill!*
96
96
97
97
98
98
† the http and https modules are actually the same and don't differentiate based on protocol
@@ -101,8 +101,8 @@ The following modules include ES6 specific version which allow you to do named i
101
101
102
102
§ vm does not have all corner cases and has less of them in a web worker
103
103
104
-
∆ not shimmed, just returns mock
104
+
∆ not shimmed, just returns mock (module, with no functions)
105
105
106
-
˚ shimmed, but too complex to polyfill fully. Avoid if at all possible. Some bugs and partial support expected.
106
+
~~˚ shimmed, but too complex to polyfill fully. Avoid if at all possible. Some bugs and partial support expected. ~~
107
107
108
108
Not all included modules rollup equally, streams (and by extension anything that requires it like http) are a mess of circular references that are pretty much impossible to tree-shake out, similarly url methods are actually a shortcut to a url object so those methods don't tree shake out very well, punycode, path, querystring, events, util, and process tree shake very well especially if you do named imports.
0 commit comments