Skip to content
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

experimental es module support #27

Closed
wants to merge 4 commits into from

Conversation

chase-moskal
Copy link

hello friend,

i wanted to load simplex-noise as a hip new web-ready es module

i created this branch and also published simplex-noise-esm@2.5.0-esm.0 to npm for my own usage

the es module is available now via cdn here: https://unpkg.com/simplex-noise-esm@2.5.0-esm.0/dist-esm/simplex-noise.js

i used babel-plugin-transform-commonjs to generate the es module distribution

codepen example demonstrates loading simplex-noise-esm as an es module

introduce babel compilation to web-ready es modules, which are made
available in the "dist-esm" directory

summary of changes:

 [.gitignore] modified
  added "/dist*" to ignore the "dist-esm" directory

 [babel.config.js] added
  configures the babel esm compilation

 [index.html] added
  use `npm start` and browse to http://localhost:8080
  to check that the es module is web-ready
  an automated build step would be better

 [package.json] modified
  move scripts block closer to top of package.json
  add field "module", directs browsers to the es module distribution
  add "dist-esm" to the files array
  add script "prepare", runs build and tests on each install/publish
  add script "start", runs local http-server to test index.html
  add script "clean", deletes the "dist-esm" directory
  add script "compile-esm", babel generates es modules in "dist-esm"
@chase-moskal
Copy link
Author

hello

i see the build failed under node 4

node 4 has been deprecated for a long time now, so we should simply drop it from the travis config

plus the consumable package will still work in node 4, it's only the babel-related build tooling that is presenting an issue

@amilajack
Copy link

I think its actually that the version of eslint doesn't support node 4. I agree that we should drop node 4. We should probably use travis node versions:

node_js:
  - node
  - 8

- build was failing under node 4
- no reason to support old node for *build* time
@jwagner
Copy link
Owner

jwagner commented Jul 4, 2021

I somehow missed this PR when it was created but I'm now working on getting esm support in. I'll probably also port it to typescript and restructure it to enable tree shaking while at it. Same setup as I used for https://github.com/jwagner/dont-crop/.

Sorry for the really slow reply @chase-moskal

@jwagner
Copy link
Owner

jwagner commented Aug 25, 2021

Since the typescript port has landed and supports esm natively I'm closing this MR.

Thanks a lot for the initial work @chase-moskal . Much appreciated!

@jwagner jwagner closed this Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants