Code Monkey home page Code Monkey logo

Comments (5)

xkam avatar xkam commented on May 27, 2024

Should I map node built-in packages to https://www.npmjs.com/package/browser-builtins ?

from getlibs.

xkam avatar xkam commented on May 27, 2024

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.

from getlibs.

billiegoose avatar billiegoose commented on May 27, 2024

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 buffer-es6) are just forks of the browserify versions that are not as well maintained. (buffer-es6 is a good 100 commits behind buffer). I ultimately decided not to use rollup-plugin-node-builtins but rather use both rollup and browserify in consecutive build steps.

So... that illustrates the wonderful wonderful thing about getlibs I like so much. When it works It just works (TM). None of these awful build tools... which are wonderful yes, but now that I've tasted dynamic module loading I can't see how anyone would ever want to go back.

I'm rambling off topic. Yes, let's use the mappings in https://unpkg.com/[email protected]/lib/builtins.js except for the empty ones and ones that don't make sense. (console?)

from getlibs.

billiegoose avatar billiegoose commented on May 27, 2024

A'ight, so I've whittled down the list to these:

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

I need to think of a good way to test them. Lemme grab a coffee.

from getlibs.

billiegoose avatar billiegoose commented on May 27, 2024

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'));

from getlibs.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.