rollup-packages-polyfill-core 0.13.1 → 0.13.2

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.
Files changed (87) hide show
  1. package/LICENSE.md +26 -26
  2. package/dist/es/index.js +81 -0
  3. package/dist/es/modules.js +58 -0
  4. package/dist/es/polyfills.js +3 -0
  5. package/dist/index.d.ts +9 -0
  6. package/dist/index.js +115 -0
  7. package/dist/modules.d.ts +1 -0
  8. package/dist/modules.js +60 -0
  9. package/dist/polyfills.d.ts +53 -0
  10. package/dist/polyfills.js +5 -0
  11. package/package.json +54 -10
  12. package/{ReadMe.md → readme.md} +85 -85
  13. package/browser-test/index.js +0 -20
  14. package/browser-test/main.js +0 -44
  15. package/polyfills/LICENSE-browserify-fs.txt +0 -472
  16. package/polyfills/LICENSE-buffer-es6.txt +0 -69
  17. package/polyfills/LICENSE-crypto-browserify.txt +0 -355
  18. package/polyfills/LICENSE-process-es6.txt +0 -32
  19. package/polyfills/__http-lib/capability.js +0 -52
  20. package/polyfills/__http-lib/request.js +0 -278
  21. package/polyfills/__http-lib/response.js +0 -185
  22. package/polyfills/__http-lib/to-arraybuffer.js +0 -30
  23. package/polyfills/__readable-stream/buffer-list.js +0 -59
  24. package/polyfills/__readable-stream/duplex.js +0 -45
  25. package/polyfills/__readable-stream/passthrough.js +0 -15
  26. package/polyfills/__readable-stream/readable.js +0 -896
  27. package/polyfills/__readable-stream/transform.js +0 -174
  28. package/polyfills/__readable-stream/writable.js +0 -483
  29. package/polyfills/__zlib-lib/LICENSE +0 -21
  30. package/polyfills/__zlib-lib/adler32.js +0 -31
  31. package/polyfills/__zlib-lib/binding.js +0 -290
  32. package/polyfills/__zlib-lib/crc32.js +0 -40
  33. package/polyfills/__zlib-lib/deflate.js +0 -1862
  34. package/polyfills/__zlib-lib/inffast.js +0 -325
  35. package/polyfills/__zlib-lib/inflate.js +0 -1650
  36. package/polyfills/__zlib-lib/inftrees.js +0 -329
  37. package/polyfills/__zlib-lib/messages.js +0 -11
  38. package/polyfills/__zlib-lib/trees.js +0 -1220
  39. package/polyfills/__zlib-lib/utils.js +0 -73
  40. package/polyfills/__zlib-lib/zstream.js +0 -28
  41. package/polyfills/assert.js +0 -488
  42. package/polyfills/buffer-es6.js +0 -1985
  43. package/polyfills/console.js +0 -13
  44. package/polyfills/constants.js +0 -498
  45. package/polyfills/domain.js +0 -100
  46. package/polyfills/empty.js +0 -1
  47. package/polyfills/events.js +0 -481
  48. package/polyfills/global.js +0 -3
  49. package/polyfills/http.js +0 -167
  50. package/polyfills/inherits.js +0 -25
  51. package/polyfills/os.js +0 -126
  52. package/polyfills/path.js +0 -234
  53. package/polyfills/process-es6.js +0 -223
  54. package/polyfills/punycode.js +0 -475
  55. package/polyfills/querystring.js +0 -147
  56. package/polyfills/setimmediate.js +0 -185
  57. package/polyfills/stream.js +0 -110
  58. package/polyfills/string-decoder.js +0 -220
  59. package/polyfills/timers.js +0 -76
  60. package/polyfills/tty.js +0 -20
  61. package/polyfills/url.js +0 -785
  62. package/polyfills/util.js +0 -716
  63. package/polyfills/vm.js +0 -202
  64. package/polyfills/zlib.js +0 -635
  65. package/rollup.config.mjs +0 -18
  66. package/scripts/build-constants.js +0 -18
  67. package/scripts/build-polyfills.js +0 -52
  68. package/scripts/collect-polyfills.js +0 -17
  69. package/src/index.ts +0 -92
  70. package/src/modules.ts +0 -61
  71. package/src/polyfills.ts +0 -1
  72. package/test/examples/assert.js +0 -12
  73. package/test/examples/constants.js +0 -7
  74. package/test/examples/crypto-broken.js +0 -2
  75. package/test/examples/crypto.js +0 -7
  76. package/test/examples/domain.js +0 -33
  77. package/test/examples/events.js +0 -7
  78. package/test/examples/os.js +0 -7
  79. package/test/examples/path.js +0 -11
  80. package/test/examples/stream.js +0 -31
  81. package/test/examples/string-decoder.js +0 -19
  82. package/test/examples/url-file-url-to-path.js +0 -11
  83. package/test/examples/url-format.js +0 -13
  84. package/test/examples/url-parse.js +0 -14
  85. package/test/examples/zlib.js +0 -24
  86. package/test/index.js +0 -77
  87. package/tsconfig.json +0 -14
package/package.json CHANGED
@@ -1,10 +1,54 @@
1
- {
2
- "name": "rollup-packages-polyfill-core",
3
- "version": "0.13.1",
4
- "main": "index.js",
5
- "scripts": {
6
- "start": "node index.js"
7
- },
8
- "author": "Ryan",
9
- "license": "MIT"
10
- }
1
+ {
2
+ "name": "rollup-packages-polyfill-core",
3
+ "version": "0.13.2",
4
+ "main": "dist/index.js",
5
+ "module": "dist/es/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "pretest": "npm run build",
9
+ "test": "mocha",
10
+ "prebuild": "rm -rf dist && mkdir dist",
11
+ "build": "npm run build:constants && npm run build:polyfills && npm run collect:polyfills && npm run build:bundlers",
12
+ "build:bundlers": "tsc -p . && rollup -c",
13
+ "build:polyfills": "node scripts/build-polyfills.js",
14
+ "build:constants": "node scripts/build-constants.js",
15
+ "collect:polyfills": "node scripts/collect-polyfills.js",
16
+ "release": "np --no-yarn --no-release-draft",
17
+ "browser-test": "serve browser-test/dist",
18
+ "prebrowser-test": "npm run build && node ./browser-test/index.js"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "keywords": [
24
+ "rollup-plugin"
25
+ ],
26
+ "author": "",
27
+ "license": "MIT",
28
+ "dependencies": {
29
+ "@rollup/plugin-inject": "^5.0.4"
30
+ },
31
+ "peerDependencies": {
32
+ "rollup": "^1.20.0 || ^2.0.0 || ^3.0.0 || ^4.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@rollup/plugin-commonjs": "^25.0.5",
36
+ "@rollup/plugin-json": "^6.0.1",
37
+ "@rollup/plugin-node-resolve": "^15.2.3",
38
+ "browserify-fs": "^1.0.0",
39
+ "buffer-es6": "^4.9.3",
40
+ "crypto-browserify": "^3.11.0",
41
+ "debug": "^4.1.1",
42
+ "glob": "^7.1.6",
43
+ "mocha": "^10.2.0",
44
+ "np": "^8.0.4",
45
+ "process-es6": "^0.11.6",
46
+ "rollup": "^4.0.2",
47
+ "serve": "^11.3.2",
48
+ "typescript": "^5.2.2"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "https://github.com/FredKSchott/rollup-plugin-polyfill-node"
53
+ }
54
+ }
@@ -1,85 +1,85 @@
1
- rollup-packages-polyfill-core
2
- ===
3
-
4
- 🔩 A modern Node.js polyfill for your Rollup bundle.
5
-
6
- > This repo is an updated, maintained fork of https://github.com/ionic-team/rollup-plugin-node-polyfills to support better Node.js polyfills in Snowpack and all other Rollup projects. See this thread for discussion on moving this plugin into the official Rollup org: https://github.com/rollup/plugins/pull/51#issuecomment-747489334
7
- >
8
- > **This repo is completely community-maintained.** If you have an issue and know JavaScript, help out and submit a PR. This may be the only way to get your issue resolved!
9
-
10
-
11
- ## Quickstart
12
-
13
- ```
14
- npm install --save-dev rollup-packages-polyfill-core
15
- ```
16
-
17
- ```js
18
- import nodePolyfills from 'rollup-packages-polyfill-core';
19
- rollup({
20
- entry: 'main.js',
21
- plugins: [
22
- nodePolyfills( /* options */ )
23
- ]
24
- })
25
- ```
26
-
27
- ## Options
28
-
29
- *All options are optional.*
30
-
31
- - `include: Array<string | RegExp> | string | RegExp | null;`: Defaults to transforming Node.js builtins in all `node_modules/**/*.js` files only. Pass in `null` to transform all files, including all files including any source files.
32
- - `exclude: Array<string | RegExp> | string | RegExp | null;`: Exclude files from transformation.
33
- - `sourceMap: boolean`: True to get source maps, false otherwise.
34
-
35
-
36
- ## Node.js Builtin Support Table
37
-
38
- The following modules include ES6 specific version which allow you to do named imports in addition to the default import and should work fine if you only use this plugin.
39
-
40
- - process*
41
- - events
42
- - stream*
43
- - util*
44
- - path
45
- - buffer*
46
- - querystring
47
- - url*
48
- - string_decoder*
49
- - punycode
50
- - http*†
51
- - https*†
52
- - os*
53
- - assert*
54
- - constants
55
- - timers*
56
- - console*‡
57
- - vm*§
58
- - zlib*
59
- - tty
60
- - domain
61
- - dns∆
62
- - dgram∆
63
- - child_process∆
64
- - cluster∆
65
- - module∆
66
- - net∆
67
- - readline∆
68
- - repl∆
69
- - tls∆
70
- - fs˚
71
- - crypto˚
72
- - perf_hooks˚ - **New:* just an empty shim for now, but would love help building a true polyfill!*
73
-
74
-
75
- † the http and https modules are actually the same and don't differentiate based on protocol
76
-
77
- ‡ default export only, because it's console, seriously just use the global
78
-
79
- § vm does not have all corner cases and has less of them in a web worker
80
-
81
- ∆ not shimmed, just returns mock
82
-
83
- ˚ shimmed, but too complex to polyfill fully. Avoid if at all possible. Some bugs and partial support expected.
84
-
85
- 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.
1
+ rollup-plugin-polyfill-node
2
+ ===
3
+
4
+ 🔩 A modern Node.js polyfill for your Rollup bundle.
5
+
6
+ > This repo is an updated, maintained fork of https://github.com/ionic-team/rollup-plugin-node-polyfills to support better Node.js polyfills in Snowpack and all other Rollup projects. See this thread for discussion on moving this plugin into the official Rollup org: https://github.com/rollup/plugins/pull/51#issuecomment-747489334
7
+ >
8
+ > **This repo is completely community-maintained.** If you have an issue and know JavaScript, help out and submit a PR. This may be the only way to get your issue resolved!
9
+
10
+
11
+ ## Quickstart
12
+
13
+ ```
14
+ npm install --save-dev rollup-plugin-polyfill-node
15
+ ```
16
+
17
+ ```js
18
+ import nodePolyfills from 'rollup-plugin-polyfill-node';
19
+ rollup({
20
+ entry: 'main.js',
21
+ plugins: [
22
+ nodePolyfills( /* options */ )
23
+ ]
24
+ })
25
+ ```
26
+
27
+ ## Options
28
+
29
+ *All options are optional.*
30
+
31
+ - `include: Array<string | RegExp> | string | RegExp | null;`: Defaults to transforming Node.js builtins in all `node_modules/**/*.js` files only. Pass in `null` to transform all files, including all files including any source files.
32
+ - `exclude: Array<string | RegExp> | string | RegExp | null;`: Exclude files from transformation.
33
+ - `sourceMap: boolean`: True to get source maps, false otherwise.
34
+
35
+
36
+ ## Node.js Builtin Support Table
37
+
38
+ The following modules include ES6 specific version which allow you to do named imports in addition to the default import and should work fine if you only use this plugin.
39
+
40
+ - process*
41
+ - events
42
+ - stream*
43
+ - util*
44
+ - path
45
+ - buffer*
46
+ - querystring
47
+ - url*
48
+ - string_decoder*
49
+ - punycode
50
+ - http*†
51
+ - https*†
52
+ - os*
53
+ - assert*
54
+ - constants
55
+ - timers*
56
+ - console*‡
57
+ - vm*§
58
+ - zlib*
59
+ - tty
60
+ - domain
61
+ - dns∆
62
+ - dgram∆
63
+ - child_process∆
64
+ - cluster∆
65
+ - module∆
66
+ - net∆
67
+ - readline∆
68
+ - repl∆
69
+ - tls∆
70
+ - fs˚
71
+ - crypto˚
72
+ - perf_hooks˚ - **New:* just an empty shim for now, but would love help building a true polyfill!*
73
+
74
+
75
+ † the http and https modules are actually the same and don't differentiate based on protocol
76
+
77
+ ‡ default export only, because it's console, seriously just use the global
78
+
79
+ § vm does not have all corner cases and has less of them in a web worker
80
+
81
+ ∆ not shimmed, just returns mock
82
+
83
+ ˚ shimmed, but too complex to polyfill fully. Avoid if at all possible. Some bugs and partial support expected.
84
+
85
+ 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.
@@ -1,20 +0,0 @@
1
- var rollup = require( 'rollup' );
2
- var nodePolyfills = require('..');
3
- rollup.rollup({
4
- input: 'browser-test/main.js',
5
- plugins: [
6
- nodePolyfills(),
7
- ]
8
- }).then( function ( bundle ) {
9
- return bundle.write({
10
- format: 'iife',
11
- file: 'browser-test/dist/bundle.js'
12
- });
13
- }).then(function () {
14
- console.log('done');
15
- process.exit();
16
- }).catch(function (e) {
17
- console.log('oh noes!');
18
- console.log(e);
19
- process.exit(1);
20
- });
@@ -1,44 +0,0 @@
1
- import {get} from 'http';
2
- import {createContext, runInContext} from 'vm';
3
- import {equal, deepEqual} from 'assert';
4
-
5
- get('foo.json', function (res) {
6
- console.log('status', res.statusCode);
7
- var data = '';
8
- res.on('data', function (d) {
9
- data += d.toString();
10
- }).on('error', function (e) {
11
- console.log('error', e);
12
- }).on('end', function () {
13
- console.log(data);
14
- if (global.document) {
15
- afterMain();
16
- } else {
17
- afterWorker();
18
- }
19
- });
20
- })
21
- function afterMain() {
22
- var context = createContext();
23
-
24
- runInContext('var x = 1', context);
25
- deepEqual(context, { x: 1 });
26
-
27
- runInContext('var y = 2;', context);
28
- var x = runInContext('++x', context);
29
- equal(x, 2);
30
- equal(context.x, 2);
31
- equal(context.x, context.y);
32
- console.log('ok main');
33
- }
34
- function afterWorker() {
35
- var context = createContext({x: 0});
36
-
37
- runInContext('x++', context);
38
- deepEqual(context, { x: 1 });
39
-
40
- var x = runInContext('++x', context);
41
- equal(x, 2);
42
- equal(context.x, 2);
43
- console.log('ok worker');
44
- }