Better support for node core modules? #6
Comments
Should I map node built-in packages to https://www.npmjs.com/package/browser-builtins ? |
Looks like browserify no longer relies on browser-builtins bundle but maps to individual packages - https://unpkg.com/[email protected]/lib/builtins.js . So I guess I should do the same thing here. |
I spent a while looking at this topic yesterday... namely comparing https://github.com/calvinmetcalf/rollup-plugin-node-builtins and https://unpkg.com/[email protected]/lib/builtins.js. Unfortunately, some of the choices rollup makes (like So... that illustrates the wonderful wonderful thing about I'm rambling off topic. Yes, let's use the mappings in |
A'ight, so I've whittled down the list to these: assert: https://unpkg.com/assert I need to think of a good way to test them. Lemme grab a coffee. |
Test playground: https://codepen.io/wmhilton/project/editor/XbNoRz Using configuration: System.config({
meta: {
//util: {loader: 'js'}
},
map: {
assert: 'https://unpkg.com/assert',
buffer: 'https://unpkg.com/buffer',
crypto: 'https://unpkg.com/crypto-browserify',
domain: 'https://unpkg.com/domain-browser',
events: 'https://unpkg.com/events',
http: 'https://unpkg.com/stream-http',
https: 'https://unpkg.com/https-browserify',
os: 'https://unpkg.com/os-browserify',
path: 'https://unpkg.com/path-browserify',
punycode: 'https://unpkg.com/punycode',
querystring: 'https://unpkg.com/querystring',
stream: 'https://unpkg.com/stream-browserify',
util: 'https://unpkg.com/util/util.js',
'util/': 'https://unpkg.com/util/util.js',
tty: 'https://unpkg.com/tty-browserify',
url: 'https://unpkg.com/url',
vm: 'https://unpkg.com/vm-browserify',
zlib: 'https://unpkg.com/browserify-zlib',
process: 'https://unpkg.com/process'
}
})
System.load('./main.js') Here's my results so far. commented out ones fail. const { Buffer } = require('buffer');
alert(Buffer.isBuffer);
global.Buffer = Buffer
alert(require('process'));
global.process = require('process');
alert(require('assert'));
//alert(require('crypto'));
alert(require('domain'));
alert(require('events'));
//alert(require('http'));
//alert(require('https'));
alert(require('os'));
alert(require('path'));
alert(require('punycode'));
//alert(require('querystring'));
alert(require('stream'));
alert(require('util'));
alert(require('tty'));
alert(require('vm'));
//alert(require('zlib'));
//alert(require('url')); |
I'm trying to use a lot of modules that were originally written for browserify and really jumping through a lot of hoops. Is that a use case you'd be willing to consider? I believe it would be a matter of adding new entries in
getlibs/config/
forassert
,util
, and so on that point at the correct browserify shims.The text was updated successfully, but these errors were encountered: