rollup-packages-polyfill-core 0.13.0 → 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 (88) 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/index.js +0 -83
  16. package/polyfills/LICENSE-browserify-fs.txt +0 -472
  17. package/polyfills/LICENSE-buffer-es6.txt +0 -69
  18. package/polyfills/LICENSE-crypto-browserify.txt +0 -355
  19. package/polyfills/LICENSE-process-es6.txt +0 -32
  20. package/polyfills/__http-lib/capability.js +0 -52
  21. package/polyfills/__http-lib/request.js +0 -278
  22. package/polyfills/__http-lib/response.js +0 -185
  23. package/polyfills/__http-lib/to-arraybuffer.js +0 -30
  24. package/polyfills/__readable-stream/buffer-list.js +0 -59
  25. package/polyfills/__readable-stream/duplex.js +0 -45
  26. package/polyfills/__readable-stream/passthrough.js +0 -15
  27. package/polyfills/__readable-stream/readable.js +0 -896
  28. package/polyfills/__readable-stream/transform.js +0 -174
  29. package/polyfills/__readable-stream/writable.js +0 -483
  30. package/polyfills/__zlib-lib/LICENSE +0 -21
  31. package/polyfills/__zlib-lib/adler32.js +0 -31
  32. package/polyfills/__zlib-lib/binding.js +0 -290
  33. package/polyfills/__zlib-lib/crc32.js +0 -40
  34. package/polyfills/__zlib-lib/deflate.js +0 -1862
  35. package/polyfills/__zlib-lib/inffast.js +0 -325
  36. package/polyfills/__zlib-lib/inflate.js +0 -1650
  37. package/polyfills/__zlib-lib/inftrees.js +0 -329
  38. package/polyfills/__zlib-lib/messages.js +0 -11
  39. package/polyfills/__zlib-lib/trees.js +0 -1220
  40. package/polyfills/__zlib-lib/utils.js +0 -73
  41. package/polyfills/__zlib-lib/zstream.js +0 -28
  42. package/polyfills/assert.js +0 -488
  43. package/polyfills/buffer-es6.js +0 -1985
  44. package/polyfills/console.js +0 -13
  45. package/polyfills/constants.js +0 -498
  46. package/polyfills/domain.js +0 -100
  47. package/polyfills/empty.js +0 -1
  48. package/polyfills/events.js +0 -481
  49. package/polyfills/global.js +0 -3
  50. package/polyfills/http.js +0 -167
  51. package/polyfills/inherits.js +0 -25
  52. package/polyfills/os.js +0 -126
  53. package/polyfills/path.js +0 -234
  54. package/polyfills/process-es6.js +0 -223
  55. package/polyfills/punycode.js +0 -475
  56. package/polyfills/querystring.js +0 -147
  57. package/polyfills/setimmediate.js +0 -185
  58. package/polyfills/stream.js +0 -110
  59. package/polyfills/string-decoder.js +0 -220
  60. package/polyfills/timers.js +0 -76
  61. package/polyfills/tty.js +0 -20
  62. package/polyfills/url.js +0 -785
  63. package/polyfills/util.js +0 -716
  64. package/polyfills/vm.js +0 -202
  65. package/polyfills/zlib.js +0 -635
  66. package/rollup.config.mjs +0 -18
  67. package/scripts/build-constants.js +0 -18
  68. package/scripts/build-polyfills.js +0 -52
  69. package/scripts/collect-polyfills.js +0 -17
  70. package/src/index.ts +0 -92
  71. package/src/modules.ts +0 -61
  72. package/src/polyfills.ts +0 -1
  73. package/test/examples/assert.js +0 -12
  74. package/test/examples/constants.js +0 -7
  75. package/test/examples/crypto-broken.js +0 -2
  76. package/test/examples/crypto.js +0 -7
  77. package/test/examples/domain.js +0 -33
  78. package/test/examples/events.js +0 -7
  79. package/test/examples/os.js +0 -7
  80. package/test/examples/path.js +0 -11
  81. package/test/examples/stream.js +0 -31
  82. package/test/examples/string-decoder.js +0 -19
  83. package/test/examples/url-file-url-to-path.js +0 -11
  84. package/test/examples/url-format.js +0 -13
  85. package/test/examples/url-parse.js +0 -14
  86. package/test/examples/zlib.js +0 -24
  87. package/test/index.js +0 -77
  88. package/tsconfig.json +0 -14
@@ -1,12 +0,0 @@
1
- import {deepEqual} from 'assert';
2
- var err;
3
- try {
4
- deepEqual({foo: {bar: ['baz']}}, {foo: {bar: ['bat']}}, 'something');
5
- } catch (e) {
6
- err = e;
7
- }
8
- if (err && err.name === 'AssertionError') {
9
- done();
10
- } else {
11
- done(err || new Error('not right'));
12
- }
@@ -1,7 +0,0 @@
1
- import {SIGHUP, defaultCoreCipherList} from 'constants';
2
-
3
- if (SIGHUP !== _constants.SIGHUP || defaultCoreCipherList !== _constants.defaultCoreCipherList) {
4
- done(new Error('wrong constants'));
5
- } else {
6
- done();
7
- }
@@ -1,2 +0,0 @@
1
- import {diffieHellman} from 'crypto';
2
- console.log(diffieHellman);
@@ -1,7 +0,0 @@
1
- import crypto from 'crypto';
2
-
3
- if (Object.keys(crypto).length) {
4
- done(new Error('should not import crypto'));
5
- } else {
6
- done();
7
- }
@@ -1,33 +0,0 @@
1
- import {create} from 'domain';
2
-
3
- var d = create()
4
- d.on('error', function(err) {
5
- if (!err || err.message !== 'a thrown error') {
6
- done(new Error('wrong message'));
7
- } else {
8
- next();
9
- }
10
- })
11
- d.run(function() {
12
- throw new Error('a thrown error')
13
- })
14
-
15
- function next() {
16
- var d = create()
17
- d.on('error', function(err) {
18
- if (!err || err.message !== 'a thrown error') {
19
- done(new Error('wrong message'));
20
- } else {
21
- done();
22
- }
23
- })
24
- d.bind(function(err, a, b) {
25
- if (!err || err.message !== 'a passed error') {
26
- done(new Error('wrong message'));
27
- } else if (a !== 2 || b !== 3) {
28
- done(new Error('wrong stuff'));
29
- } else {
30
- throw new Error('a thrown error')
31
- }
32
- })(new Error('a passed error'), 2, 3)
33
- }
@@ -1,7 +0,0 @@
1
- import {EventEmitter as EE} from 'events';
2
-
3
- var e = new EE();
4
- e.on('it', function (foo) {
5
- done();
6
- });
7
- e.emit('it', 'works');
@@ -1,7 +0,0 @@
1
- import {endianness} from 'os';
2
- var ourE = endianness();
3
- if (endianness() === _osEndianness) {
4
- done();
5
- } else {
6
- done(new Error(`wrong endianness, expected ${_osEndianness} but got ${ourE}`));
7
- }
@@ -1,11 +0,0 @@
1
- import {dirname, relative} from 'path';
2
-
3
-
4
- var basedir = '/';
5
- var importer = './src/es6/path.js';
6
- var out = dirname('/' + relative(basedir, importer));
7
- if (out === '/src/es6'){
8
- done();
9
- } else {
10
- done(new Error(`wrong directory, expected '/src/es6' but got '${out}'`));
11
- }
@@ -1,31 +0,0 @@
1
- import {Transform} from 'stream';
2
- import * as allStreams from 'stream';
3
-
4
- var total = 0;
5
- var ended = false;
6
- var t = new Transform({
7
- objectMode: true,
8
- transform: function (chunk, _, next) {
9
- total++;
10
- next();
11
- },
12
- flush: function (end) {
13
- if (total !== 3) {
14
- done(new Error('wrong number'));
15
- end();
16
- return;
17
- }
18
- ended = true;
19
- end();
20
- }
21
- });
22
- t.on('finish', function () {
23
- if (!ended) {
24
- done(new Error('did not end'));
25
- return;
26
- }
27
- done();
28
- })
29
- t.write('foo');
30
- t.write('bar');
31
- t.end('baz');
@@ -1,19 +0,0 @@
1
- import {StringDecoder} from 'string_decoder';
2
-
3
- var text = Buffer.from('\uD835\uDC00\uD83D\uDCA9\uD835\uDC01');
4
-
5
- var decoder = new StringDecoder();
6
- var ref = [ '', '', '', '𝐀', '', '', '', '💩', '', '', '', '𝐁' ];
7
- var len = text.length;
8
- var i = -1;
9
- var bad = 0;
10
- while (++i < len) {
11
- if (ref[i] !== decoder.write(text.slice(i, i + 1))) {
12
- bad++;
13
- }
14
- }
15
- if (bad) {
16
- done(new Error('did not work right'));
17
- } else {
18
- done();
19
- }
@@ -1,11 +0,0 @@
1
- import {fileURLToPath} from 'url';
2
-
3
- const hello = 'file:///hello world';
4
-
5
- if (
6
- fileURLToPath(hello) !== '/hello world'
7
- ) {
8
- done(new Error('invalid object'));
9
- }
10
-
11
- done();
@@ -1,13 +0,0 @@
1
- import {format} from 'url';
2
-
3
- var created = format({
4
- protocol: 'foo',
5
- host: 'bar',
6
- pathname: '/baz'
7
- });
8
-
9
- if (created !== 'foo:bar/baz') {
10
- done(new Error('wrong output'));
11
- } else {
12
- done();
13
- }
@@ -1,14 +0,0 @@
1
- import {parse} from 'url';
2
-
3
- var ourUrl = 'https://💩.gov/baz/bat?a=b#lalalallala';
4
- var parsed = parse(ourUrl);
5
-
6
- if (
7
- parsed.hash !== '#lalalallala' ||
8
- parsed.query !== 'a=b' ||
9
- parsed.host !== 'xn--ls8h.gov'
10
- ) {
11
- done(new Error('invalid object'));
12
- } else {
13
- done();
14
- }
@@ -1,24 +0,0 @@
1
- import {deflateSync, inflateSync} from 'zlib';
2
-
3
-
4
- var input = new Buffer('hello hello hello');
5
-
6
- var deflated = deflateSync(input);
7
-
8
- var reinflated = inflateSync(deflated);
9
-
10
- if (reinflated.toString() !== 'hello hello hello') {
11
- done(new Error('expected \'hello hello hello\' but got \'' + reinflated.toString() +'\''));
12
- } else {
13
- next();
14
- }
15
- function next() {
16
- var expected = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
17
- var deflated = Buffer.from('eJxLTCQVAADjXBLz', 'base64');
18
- var reinflated = inflateSync(deflated).toString();
19
- if (reinflated.toString() !== expected) {
20
- done(new Error(`expected '${expected}' but got '${reinflated}'`));
21
- } else {
22
- done();
23
- }
24
- }
package/test/index.js DELETED
@@ -1,77 +0,0 @@
1
- const vm = require('vm');
2
- const rollup = require('rollup');
3
- const nodePolyfills = require('..');
4
- const os = require('os');
5
- const constants = require('constants');
6
- const debug = require('debug')('builtins:test');
7
- const files = [
8
- 'events.js',
9
- 'crypto.js',
10
- 'url-parse.js',
11
- 'url-file-url-to-path.js',
12
- 'url-format.js',
13
- 'stream.js',
14
- 'assert.js',
15
- 'constants.js',
16
- 'os.js',
17
- 'path.js',
18
- 'string-decoder.js',
19
- 'zlib.js',
20
- 'domain.js',
21
- 'crypto.js'
22
- ];
23
-
24
- describe('rollup-plugin-node-polyfills', function() {
25
-
26
- this.timeout(5000);
27
-
28
- files.forEach((file) => {
29
- it('works with ' + file, function (done) {
30
- rollup.rollup({
31
- input: 'test/examples/' + file,
32
- plugins: [
33
- nodePolyfills({
34
- include: null
35
- })
36
- ]
37
- })
38
- .then(bundle => bundle.generate({format: 'cjs'}))
39
- .then(generated => {
40
- const code = generated.output[0].code;
41
- debug(code);
42
- const script = new vm.Script(code);
43
- const context = vm.createContext({
44
- done: done,
45
- setTimeout: setTimeout,
46
- clearTimeout: clearTimeout,
47
- console: console,
48
- _constants: constants,
49
- _osEndianness: os.endianness()
50
- });
51
- context.self = context;
52
- script.runInContext(context);
53
- })
54
- .catch(done)
55
- });
56
- })
57
-
58
- it('crypto option works (though is broken)', function(done) {
59
- rollup.rollup({
60
- input: 'test/examples/crypto-broken.js',
61
- plugins: [
62
- nodePolyfills({
63
- include: null,
64
- crypto: true
65
- })
66
- ]
67
- }).then(function() {
68
- done(new Error ('should not get here'))
69
- }, function (err) {
70
- if (err.message === `"diffieHellman" is not exported by "\u0000polyfill-node.crypto.js", imported by "test/examples/crypto-broken.js".`) {
71
- done();
72
- return;
73
- }
74
- done(err)
75
- });
76
- });
77
- })
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "moduleResolution": "node",
5
- "module": "ES2020",
6
- "target": "es2018",
7
- "declaration": true,
8
- "outDir": "lib",
9
- "declarationDir": "dist"
10
- },
11
- "include": [
12
- "src"
13
- ]
14
- }