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
@@ -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
- }