rollup-packages-polyfill-core 0.13.1 → 0.13.3

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/LICENSE.md CHANGED
@@ -1,26 +1,26 @@
1
-
2
- The MIT License (MIT)
3
-
4
- Copyright (c) 2020 Fred K. Schott
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
-
8
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
-
10
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
-
12
-
13
- """
14
-
15
- This license applies to parts of rollup-plugin-polyfill-node originating from the
16
- https://github.com/ionic-team/rollup-plugin-node-polyfills repository:
17
-
18
- The MIT License (MIT)
19
-
20
- Copyright (c) 2019 these people
21
-
22
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
23
-
24
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
25
-
26
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2020 Fred K. Schott
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
+
12
+
13
+ """
14
+
15
+ This license applies to parts of rollup-plugin-polyfill-node originating from the
16
+ https://github.com/ionic-team/rollup-plugin-node-polyfills repository:
17
+
18
+ The MIT License (MIT)
19
+
20
+ Copyright (c) 2019 these people
21
+
22
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,81 @@
1
+ import inject from '@rollup/plugin-inject';
2
+ import { getModules } from './modules.js';
3
+ import { resolve, posix } from 'path';
4
+ import { randomBytes } from 'crypto';
5
+ import POLYFILLS from './polyfills.js';
6
+
7
+ // Node import paths use POSIX separators
8
+ const { dirname, relative, join } = posix;
9
+ const PREFIX = `\0polyfill-node.`;
10
+ const PREFIX_LENGTH = PREFIX.length;
11
+ function index (opts = {}) {
12
+ const mods = getModules();
13
+ const injectPlugin = inject({
14
+ include: opts.include === undefined ? ['node_modules/**/*.js'] : opts.include,
15
+ exclude: opts.exclude,
16
+ sourceMap: opts.sourceMap,
17
+ modules: {
18
+ process: PREFIX + "process",
19
+ Buffer: [PREFIX + "buffer", "Buffer"],
20
+ global: PREFIX + 'global',
21
+ __filename: FILENAME_PATH,
22
+ __dirname: DIRNAME_PATH,
23
+ },
24
+ });
25
+ const basedir = opts.baseDir || "/";
26
+ const dirs = new Map();
27
+ return {
28
+ name: "polyfill-node",
29
+ resolveId(importee, importer) {
30
+ // Fixes commonjs compatability: https://github.com/FredKSchott/rollup-plugin-polyfill-node/pull/42
31
+ if (importee[0] == '\0' && /\?commonjs-\w+$/.test(importee)) {
32
+ importee = importee.slice(1).replace(/\?commonjs-\w+$/, '');
33
+ }
34
+ if (importee === DIRNAME_PATH) {
35
+ const id = getRandomId();
36
+ dirs.set(id, dirname("/" + relative(basedir, importer)));
37
+ return { id, moduleSideEffects: false };
38
+ }
39
+ if (importee === FILENAME_PATH) {
40
+ const id = getRandomId();
41
+ dirs.set(id, dirname("/" + relative(basedir, importer)));
42
+ return { id, moduleSideEffects: false };
43
+ }
44
+ if (importee && importee.slice(-1) === "/") {
45
+ importee = importee.slice(0, -1);
46
+ }
47
+ if (importer && importer.startsWith(PREFIX) && importee.startsWith('.')) {
48
+ importee = PREFIX + join(importer.substr(PREFIX_LENGTH).replace('.js', ''), '..', importee) + '.js';
49
+ }
50
+ if (importee.startsWith(PREFIX)) {
51
+ importee = importee.substr(PREFIX_LENGTH);
52
+ }
53
+ if (mods.has(importee) || POLYFILLS[importee.replace('.js', '') + '.js']) {
54
+ return { id: PREFIX + importee.replace('.js', '') + '.js', moduleSideEffects: false };
55
+ }
56
+ return null;
57
+ },
58
+ load(id) {
59
+ if (dirs.has(id)) {
60
+ return `export default '${dirs.get(id)}'`;
61
+ }
62
+ if (id.startsWith(PREFIX)) {
63
+ const importee = id.substr(PREFIX_LENGTH).replace('.js', '');
64
+ return mods.get(importee) || POLYFILLS[importee + '.js'];
65
+ }
66
+ },
67
+ transform(code, id) {
68
+ if (id === PREFIX + 'global.js')
69
+ return;
70
+ // @ts-ignore
71
+ return injectPlugin.transform.call(this, code, id.replace(PREFIX, resolve('node_modules', 'polyfill-node')));
72
+ },
73
+ };
74
+ }
75
+ function getRandomId() {
76
+ return randomBytes(15).toString("hex");
77
+ }
78
+ const DIRNAME_PATH = "\0node-polyfills:dirname";
79
+ const FILENAME_PATH = "\0node-polyfills:filename";
80
+
81
+ export { index as default };
@@ -0,0 +1,58 @@
1
+ import POLYFILLS from './polyfills.js';
2
+
3
+ const EMPTY_PATH = POLYFILLS['empty.js'];
4
+ function getModules() {
5
+ const libs = new Map();
6
+ libs.set('process', POLYFILLS['process-es6.js']);
7
+ libs.set('global', POLYFILLS['global.js']);
8
+ libs.set('buffer', POLYFILLS['buffer-es6.js']);
9
+ libs.set('util', POLYFILLS['util.js']);
10
+ libs.set('sys', libs.get('util'));
11
+ libs.set('events', POLYFILLS['events.js']);
12
+ libs.set('stream', POLYFILLS['stream.js']);
13
+ libs.set('path', POLYFILLS['path.js']);
14
+ libs.set('querystring', POLYFILLS['querystring.js']);
15
+ libs.set('punycode', POLYFILLS['punycode.js']);
16
+ libs.set('url', POLYFILLS['url.js']);
17
+ libs.set('string_decoder', POLYFILLS['string-decoder.js']);
18
+ libs.set('http', POLYFILLS['http.js']);
19
+ libs.set('https', POLYFILLS['http.js']);
20
+ libs.set('os', POLYFILLS['os.js']);
21
+ libs.set('assert', POLYFILLS['assert.js']);
22
+ libs.set('constants', POLYFILLS['constants.js']);
23
+ libs.set('_stream_duplex', POLYFILLS['__readable-stream/duplex.js']);
24
+ libs.set('_stream_passthrough', POLYFILLS['__readable-stream/passthrough.js']);
25
+ libs.set('_stream_readable', POLYFILLS['__readable-stream/readable.js']);
26
+ libs.set('_stream_writable', POLYFILLS['__readable-stream/writable.js']);
27
+ libs.set('_stream_transform', POLYFILLS['__readable-stream/transform.js']);
28
+ libs.set('_inherits', POLYFILLS['inherits.js']);
29
+ libs.set('_buffer_list', POLYFILLS['__readable-stream/buffer-list.js']);
30
+ libs.set('timers', POLYFILLS['timers.js']);
31
+ libs.set('console', POLYFILLS['console.js']);
32
+ libs.set('vm', POLYFILLS['vm.js']);
33
+ libs.set('zlib', POLYFILLS['zlib.js']);
34
+ libs.set('tty', POLYFILLS['tty.js']);
35
+ libs.set('domain', POLYFILLS['domain.js']);
36
+ // TODO: Decide if we want to implement these or not
37
+ // currently causing trouble in tests
38
+ libs.set('fs', EMPTY_PATH);
39
+ libs.set('crypto', EMPTY_PATH);
40
+ // libs.set('fs', POLYFILLS['browserify-fs.js']);
41
+ // libs.set('crypto', POLYFILLS['crypto-browserify.js']);
42
+ // TODO: No good polyfill exists yet
43
+ libs.set('http2', EMPTY_PATH);
44
+ // not shimmed
45
+ libs.set('dns', EMPTY_PATH);
46
+ libs.set('dgram', EMPTY_PATH);
47
+ libs.set('child_process', EMPTY_PATH);
48
+ libs.set('cluster', EMPTY_PATH);
49
+ libs.set('module', EMPTY_PATH);
50
+ libs.set('net', EMPTY_PATH);
51
+ libs.set('readline', EMPTY_PATH);
52
+ libs.set('repl', EMPTY_PATH);
53
+ libs.set('tls', EMPTY_PATH);
54
+ libs.set('perf_hooks', EMPTY_PATH);
55
+ return libs;
56
+ }
57
+
58
+ export { getModules };