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

feat: build esm modules using ipjs #863

Closed
wants to merge 3 commits into from
Closed

Conversation

achingbrain
Copy link
Member

Includes ipjs to build esm projects.

  • Auto-detects esm projects based on the "type": "module" field in the project package.json
  • Builds cjs and esm version of the project with exports/browser/filesystem fallback for maximum compatibility

TODO:

  • Publishing from dist folder
  • Bundling?
  • TS definitions?

Includes ipjs to build esm projects.

- Auto-detects esm projects based on the `"type": "module"` field in the project `package.json`
- Builds cjs and esm version of the project with exports/browser/filesystem fallback for maximum compatibility

TODO:

- [ ] Publishing from `dist` folder
- [ ] Bundling?
- [ ] TS definitions?
Comment on lines +85 to +89
enabled: async ctx => {
const pkg = await fs.readJSON(path.join(process.cwd(), 'package.json'))

return pkg.type === 'module'
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enabled: async ctx => {
const pkg = await fs.readJSON(path.join(process.cwd(), 'package.json'))
return pkg.type === 'module'
},
enabled: ctx => {
const pkg = fs.readJsonSync(path.join(process.cwd(), 'package.json'))
return pkg.type === 'module'
},

listr enabled does not allow async functions

@achingbrain
Copy link
Member Author

Superseded by #865

@achingbrain achingbrain deleted the feat/build-esm-modules branch August 14, 2021 07:29
achingbrain added a commit that referenced this pull request Aug 14, 2021
This builds up on @achingbrain 's work on #863 with build improvements and full support

This adds:
- `ipjs` for ESM modules
  - auto-detected
- `types` property transformation, allowing real time ts check in dev and path update for dist folder (TLDR no dist in the path)
- `release` for ESM modules will navigate to the dist to publish its content
- Dockerfile to bundlesize action per actions/runner#772 (comment) as we need node14+ for ESM

One of the problematic modules in skypack using aegir is `uint8arrays`. It is a CJS module that depends on a ESM first module (multiformats), which makes skypack to get bad dependency paths.

I tested this out shipping `uint8arrays` achingbrain/uint8arrays#22 PR and everything working smoothly 🎉 

Original release: https://codepen.io/vascosantos/pen/KKmXoPV?editors=0011
Scoped release using `aegir`: https://codepen.io/vascosantos/pen/bGWoONq?editors=0011

(see browser built in console for errors)

Co-authored-by: achingbrain <alex@achingbrain.net>
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

2 participants