Skip to content

[WIP] esm: Import modules by https

Hi everyone,

I implemented basic version of esm over the internet idea. Example below is working.

I'd like to know from the community: what do you think?

Personally I am dying to see Node.js doing something like this. I just feel like node_modules managed by npm sometimes just gets overhead. It's how we got used to it - yeah. But it doesn't mean we can't experiment with other ideas, right?

import assert from 'assert';

import { a } from 'https://raw.githubusercontent.com/kuroljov/esm-test/master/a.js';
import { b } from 'https://raw.githubusercontent.com/kuroljov/esm-test/master/b.js';

assert.strictEqual(a, 'a');
assert.strictEqual(b(), 'b');

How

I basically added new translator called http where I am fetching (or if it's already there then reading from the disk) something

Next

I am able to invest more time to it but I'd like to know if it will make sense. That is why WIP basically 😄

If yes then I'd like to see in this PR

  • Remote dependency resolving (right now you can't fetch script that has import statements (it's like in the browser right now - you get one script that has to export default)
  • Community fixes and suggestions

Checklist

Consider this PR more like a draft for now. Things will get done if I get green light

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading