Skip to content

Convert loader to ESM #1313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

Convert loader to ESM #1313

wants to merge 4 commits into from

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Jun 3, 2020

This PR converts the loader to ESM format so it is more easily usable both on the web and under node.js. I stumbled over this while working on the new website and its editor, where I need a little hack to make the loader work. Of course that'd be easily fixable by appending an AMD/CommonJS shim, which I considered first, but with #1306 being a thing now (see for context) I figured that I can as well initiate the switch to ESM at the loader.

Thoughts? :)

  • I've read the contributing guidelines

@dcodeIO
Copy link
Member Author

dcodeIO commented Jun 3, 2020

Well, seems TypeScript isn't happy with that in the bootstrap test. Also quickly looked up how to make a hybrid module, but that requires either transpiling, which is silly, or keeping the base code in CommonJS format, which isn't helpful in the browser.

@dcodeIO
Copy link
Member Author

dcodeIO commented Jun 3, 2020

[insert random swearwords / honest opinion here]

Looks like the only thing that'll actually work in all circumstances is to transpile, but pulling in potentially heavy dependencies like babel just for that feels wrong as well :(

@jtenner
Copy link
Contributor

jtenner commented Jun 4, 2020

Why not go the whole nine yards and convert the loader to typescript? :)

@dcodeIO
Copy link
Member Author

dcodeIO commented Jun 4, 2020

That's indeed another option given the circumstances. What I'm trying to achieve currently is that we have future proof sources in ESM, and would make the code base directly use the sources so making changes is immediately in sync without a build step, and contributors don't get confused by multiple files that look like sources. Then, if we absolutely need a build step, automate it on publish.

For instance, with TypeScript we'll either have to ship both the TS sources and the transpiled files so stuff just works™ on clone but contributors will make changes to the wrong files or be otherwise confused, or we leave the transpiled files out of source control avoiding that but then people must build them after cloning :(

@dcodeIO
Copy link
Member Author

dcodeIO commented Jun 4, 2020

Latest commit now gives this a shot using esm2umd as a prepublish step, making the loader default to ESM with UMD as a fallback. ts-node doesn't like this, unfortunately, perhaps because we are stuck on v6, so I converted the bootstrap test to ESM as well.

@dcodeIO
Copy link
Member Author

dcodeIO commented Oct 22, 2020

Superseded by #1513

@dcodeIO dcodeIO closed this Oct 22, 2020
@dcodeIO dcodeIO deleted the esm-loader branch June 1, 2021 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants