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.
- package/LICENSE.md +26 -26
- package/dist/es/index.js +81 -0
- package/dist/es/modules.js +58 -0
- package/dist/es/polyfills.js +3 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +115 -0
- package/dist/modules.d.ts +1 -0
- package/dist/modules.js +60 -0
- package/dist/polyfills.d.ts +53 -0
- package/dist/polyfills.js +5 -0
- package/package.json +54 -10
- package/{ReadMe.md → readme.md} +85 -85
- package/browser-test/index.js +0 -20
- package/browser-test/main.js +0 -44
- package/polyfills/LICENSE-browserify-fs.txt +0 -472
- package/polyfills/LICENSE-buffer-es6.txt +0 -69
- package/polyfills/LICENSE-crypto-browserify.txt +0 -355
- package/polyfills/LICENSE-process-es6.txt +0 -32
- package/polyfills/__http-lib/capability.js +0 -52
- package/polyfills/__http-lib/request.js +0 -278
- package/polyfills/__http-lib/response.js +0 -185
- package/polyfills/__http-lib/to-arraybuffer.js +0 -30
- package/polyfills/__readable-stream/buffer-list.js +0 -59
- package/polyfills/__readable-stream/duplex.js +0 -45
- package/polyfills/__readable-stream/passthrough.js +0 -15
- package/polyfills/__readable-stream/readable.js +0 -896
- package/polyfills/__readable-stream/transform.js +0 -174
- package/polyfills/__readable-stream/writable.js +0 -483
- package/polyfills/__zlib-lib/LICENSE +0 -21
- package/polyfills/__zlib-lib/adler32.js +0 -31
- package/polyfills/__zlib-lib/binding.js +0 -290
- package/polyfills/__zlib-lib/crc32.js +0 -40
- package/polyfills/__zlib-lib/deflate.js +0 -1862
- package/polyfills/__zlib-lib/inffast.js +0 -325
- package/polyfills/__zlib-lib/inflate.js +0 -1650
- package/polyfills/__zlib-lib/inftrees.js +0 -329
- package/polyfills/__zlib-lib/messages.js +0 -11
- package/polyfills/__zlib-lib/trees.js +0 -1220
- package/polyfills/__zlib-lib/utils.js +0 -73
- package/polyfills/__zlib-lib/zstream.js +0 -28
- package/polyfills/assert.js +0 -488
- package/polyfills/buffer-es6.js +0 -1985
- package/polyfills/console.js +0 -13
- package/polyfills/constants.js +0 -498
- package/polyfills/domain.js +0 -100
- package/polyfills/empty.js +0 -1
- package/polyfills/events.js +0 -481
- package/polyfills/global.js +0 -3
- package/polyfills/http.js +0 -167
- package/polyfills/inherits.js +0 -25
- package/polyfills/os.js +0 -126
- package/polyfills/path.js +0 -234
- package/polyfills/process-es6.js +0 -223
- package/polyfills/punycode.js +0 -475
- package/polyfills/querystring.js +0 -147
- package/polyfills/setimmediate.js +0 -185
- package/polyfills/stream.js +0 -110
- package/polyfills/string-decoder.js +0 -220
- package/polyfills/timers.js +0 -76
- package/polyfills/tty.js +0 -20
- package/polyfills/url.js +0 -785
- package/polyfills/util.js +0 -716
- package/polyfills/vm.js +0 -202
- package/polyfills/zlib.js +0 -635
- package/rollup.config.mjs +0 -18
- package/scripts/build-constants.js +0 -18
- package/scripts/build-polyfills.js +0 -52
- package/scripts/collect-polyfills.js +0 -17
- package/src/index.ts +0 -92
- package/src/modules.ts +0 -61
- package/src/polyfills.ts +0 -1
- package/test/examples/assert.js +0 -12
- package/test/examples/constants.js +0 -7
- package/test/examples/crypto-broken.js +0 -2
- package/test/examples/crypto.js +0 -7
- package/test/examples/domain.js +0 -33
- package/test/examples/events.js +0 -7
- package/test/examples/os.js +0 -7
- package/test/examples/path.js +0 -11
- package/test/examples/stream.js +0 -31
- package/test/examples/string-decoder.js +0 -19
- package/test/examples/url-file-url-to-path.js +0 -11
- package/test/examples/url-format.js +0 -13
- package/test/examples/url-parse.js +0 -14
- package/test/examples/zlib.js +0 -24
- package/test/index.js +0 -77
- package/tsconfig.json +0 -14
package/test/examples/assert.js
DELETED
|
@@ -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
|
-
}
|
package/test/examples/crypto.js
DELETED
package/test/examples/domain.js
DELETED
|
@@ -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
|
-
}
|
package/test/examples/events.js
DELETED
package/test/examples/os.js
DELETED
package/test/examples/path.js
DELETED
|
@@ -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
|
-
}
|
package/test/examples/stream.js
DELETED
|
@@ -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,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
|
-
}
|
package/test/examples/zlib.js
DELETED
|
@@ -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