-
Notifications
You must be signed in to change notification settings - Fork 62
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
Feature: ESM module #253
Comments
feathers-swagger is quite an old module written in plain javascript not using any transpiler. Can you explain to me the pain of importing cjs modules into esm code? |
@AshotN Can you test the branch https://github.com/feathersjs-ecosystem/feathers-swagger/tree/esm if it does work like that? |
Having to import like this import feathersSwagger from 'feathers-swagger'
const { createSwaggerServiceOptions } = feathersSwagger
Mostly everything worked, besides the functions are not available when default importing. Have to do this import swagger, { customMethodsHandler, swaggerUI } from 'feathers-swagger' because
|
This was on purpose, I thought this is how it should be to allow "tree shaking" even if it is not a real thing on the backend, but then it is a breaking change, mhh. Btw in my Typescript projects |
That works because you are not using ESM. https://github.com/Mairu/feathersjs-swagger-tests/blob/feathers-v5-koa-typebox/tsconfig.json#L7 If |
Chiming in on this old issue. I'm trying to use
Could this possibly be fixed by the same issue or is it unrelated? |
Hi @AwesomeBobX64, sorry for the late response. I don't think it is related. This is an export only available in feathers v4 and feathers-swagger supports v4 and v5 and checks on runtime which feathers version is installed by checking the available dependency. And there is a try/catch checking done before in the if block. feathers-swagger/lib/custom-methods.js Lines 11 to 13 in 657ab29
feathers-swagger/lib/helpers.js Lines 52 to 62 in 657ab29
Were you able to mark it as external to resolve your issue? |
Is your feature request related to a problem? Please describe.
I am attempting to move my code base off of CJS and onto ESM.
Describe the solution you'd like
For feathers-swagger to support both ESM and CJS with conditional exports
Describe alternatives you've considered
Default exports are compatible across ESM and CJS, but it is kind of a pain as far as developer experience goes
Additional context
I recently updated my package to support both, as an example AshotN/adminjs-feathers@69a5360
The text was updated successfully, but these errors were encountered: