feathers icon indicating copy to clipboard operation
feathers copied to clipboard

feat: ES module builds (ESM Support)

Open fratzinger opened this issue 3 years ago • 4 comments

This pull request adds ES module builds to all package distributables. It is backwards compatible by still providing the CommonJS version as well but will use ES modules in applications with "type": "module" (like the generated app) and with client side bundlers so it can use features like tree shaking.

Closes https://github.com/feathersjs/feathers/issues/2748 Closes https://github.com/feathersjs/feathers/issues/2001

fratzinger avatar Jun 12 '22 20:06 fratzinger

This looks like a good step, thank you. I am seeing the same error locally you can see in CI:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib' is not defined by "exports" in /home/runner/work/feathers/feathers/packages/transport-commons/node_modules/@feathersjs/errors/package.json

I'm not sure what that means since all those packages have an identical configuration.

daffl avatar Jun 13 '22 21:06 daffl

Deploy Preview for feathers-dove canceled.

Name Link
Latest commit 820743dac5fddeab1388f3459efd0b09b624f196
Latest deploy log https://app.netlify.com/sites/feathers-dove/deploys/63a1fa7fabc93400090a0d76

netlify[bot] avatar Oct 29 '22 17:10 netlify[bot]

@daffl, @FossPrime

I don't know what the error in the generator is about: image

Builds are passing. I think we could try it out.

I don't know what the best strategy is though. Install from github is not possible because of lerna workspace packages, right? Maybe we need pre-versions.

fratzinger avatar Jun 09 '23 18:06 fratzinger

Making a note here that the thing that may be missing is that the ESM and CJS folders each need a package.json that declares the module type like

{ "type": "module|commonjs" }

Now that TypeScript seems to support it properly it might also make sense to use full imports with .js extensions.

daffl avatar Dec 20 '23 19:12 daffl