Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Use pure ES modules #749

Closed
ehmicky opened this issue Oct 15, 2021 · 3 comments · Fixed by #1230
Closed

Use pure ES modules #749

ehmicky opened this issue Oct 15, 2021 · 3 comments · Fixed by #1230
Labels
type: chore work needed to keep the product and development running smoothly

Comments

@ehmicky
Copy link
Contributor

ehmicky commented Oct 15, 2021

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

Once #748 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).

This should only be done after pure ES modules are supported in both Netlify CLI (netlify/cli#3514) and Netlify Build (netlify/build#3742).

@ehmicky
Copy link
Contributor Author

ehmicky commented Jan 28, 2022

I have opened several PRs to tackle most of the problems related to migrating to pure ES modules:

Each of those PRs can be released with the current codebase without any breaking changes nor change of behavior for consumers, including without switching to pure ES modules. Since each of those changes carries some risk with it, they are marked with fix: so we can release those incrementally.

Two problems are still pending:

  • Several dependencies are currently missing their types when using the new TypeScript nodenext option. I am currently using @ts-ignore comments, but am considering switching to using declare statements in a *.d.ts instead.
  • esbuild is adding some ES modules-specific test helpers to Netlify Functions, even if they use CommonJS, if this repository's switches to pure ES modules.

The following PR is the final PR which does the actual migration. It includes all of the PRs above, plus the actual migration. It is in draft mode until all the above PRs are merged.

Once this is done, the three following issues can be done:

  • Use our ES modules-specific ESLint configuration
  • Use our ES modules-specific Renovate configuration
  • With the new Renovate configuration, many dependencies upgrade PRs will be created, which can be merged

@brittneypostma
Copy link

Any progress on this? It's blocking a adapter-netlify update for SvelteKit.

@danez
Copy link
Contributor

danez commented Oct 18, 2022

This is only about releasing zisi as esm module, this has nothing to do with how we bundle functions. What you are probably looking for is #750

The linked svelte kit issue (sveltejs/kit#5177) might have been fixed with sveltejs/kit#6666 from @eduardoboucas, but not sure.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: chore work needed to keep the product and development running smoothly
Projects
None yet
3 participants