netlify / zip-it-and-ship-it

Intelligently prepare Node.js Lambda functions for deployment

Home Page:https://www.npmjs.com/package/@netlify/zip-it-and-ship-it

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use pure ES modules

ehmicky opened this issue · comments

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).

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

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

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.