Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Use pure ES modules #451

Closed
ehmicky opened this issue Oct 15, 2021 · 5 comments
Closed

Use pure ES modules #451

ehmicky opened this issue Oct 15, 2021 · 5 comments
Assignees
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@ehmicky
Copy link
Contributor

ehmicky commented Oct 15, 2021

See background at https://github.com/netlify/team-dev/issues/36

Once #450 is done and released, we should use pure ES modules and make a major release.

This is more than just switching from CommonJS to import/export. See this list for other changes which might be involved. This should be broken in many PRs, as much as possible, to lower the risk. Also, non-breaking changes (such as adding file extensions in imports, or loading JSON files differently) should be done before the breaking changes (such as using import/export statements).

At the moment, framework-info is only used by:

  • build-info: so support for pure ES modules should be added first there: Use pure ES modules build-info#181
  • netlify-cli: same thing for Netlify CLI: Use pure ES modules cli#3514
  • netlify-react-ui: will this be a problem when importing this module from netlify-react-ui? Do we bundle code to make ES modules work in netlify-react-ui? Or maybe we now only support browsers with ES modules support? @nasivuela Do you know what the situation is?
@ehmicky ehmicky added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Oct 15, 2021
@nasivuela
Copy link

netlify-react-ui: will this be a problem when importing this module from netlify-react-ui? Do we bundle code to make ES modules work in netlify-react-ui? Or maybe we now only support browsers with ES modules support? @nasivuela Do you know what the situation is?

We do bundle the code with webpack + esbuild. framework-info is relatively big, we split it from the main bundle and download it after the main bundle.
I do not know how it will behave with an only ESM package but I can see this sentence My repos are not the place to ask ESM/TypeScript/Webpack/Jest/ts-node/CRA support questions. in sindresorhus' guide 😅 Let me ask on the FE guild.

@erezrokah
Copy link
Contributor

erezrokah commented Oct 18, 2021

framework-info uses the designated package.json browser field:

"browser": "./dist/index.js",

and uses browserslist to target
"browserslist": [

I think Webpack uses the browser field for web based targets.

Based on #152, I believe we do support quite old browsers in the UI app

@nasivuela
Copy link

To be clear, I'm not contemplating using ESM directly on the browser at the moment, just wondering if our current setup will bundle an ESM package.

@ehmicky ehmicky self-assigned this Dec 3, 2021
@ehmicky
Copy link
Contributor Author

ehmicky commented Dec 6, 2021

The following items are left, in order:

@ehmicky
Copy link
Contributor Author

ehmicky commented Jan 19, 2022

Done!

@ehmicky ehmicky closed this as completed Jan 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

3 participants