Skip to content
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

Export CJS and ESM Lib #127

Closed
ClementCornut opened this issue Nov 17, 2023 · 1 comment · Fixed by #161
Closed

Export CJS and ESM Lib #127

ClementCornut opened this issue Nov 17, 2023 · 1 comment · Fixed by #161
Labels
enhancement New feature or request

Comments

@ClementCornut
Copy link

Feature Request

Is your feature request related to a problem? Please describe.

I have a serverless setup with type: "module" and no bundler like vite, webpack etc (I use serverless-jetpack to upload only necessary files). With the actual output config of vite the lib is cjs only and cannot be imported like said in the doc under my configuration.
Because of that I have no choice but to import with default export
For example
import awsPkg from "@h4ad/serverless-adapter/lib/adapters/aws/index.js";
It's not very convenient.

Describe the solution you'd like
It would be great if the lib was exported as both cjs and esm with appropriate resolution in package.json. It shoudn't impact cjs users and benefit to esm users

Are you willing to resolve this issue by submitting a Pull Request?

I can try to do it but I prefer to wait some comments on this request if I missed something

@ClementCornut ClementCornut added the enhancement New feature or request label Nov 17, 2023
@H4ad
Copy link
Owner

H4ad commented Nov 17, 2023

Having the path as import awsPkg from "@h4ad/serverless-adapter/lib/adapters/aws/index.js" is intentional because I want the CJS users to have multiple environments supported in the same code and they only need to install a library for that environment if they import that file.

But if we can have something like: import awsPkg from "@h4ad/serverless-adapter/adapters/aws I will be happy to accept.

I don't know much about publishing to esm, so I appreciate it if you could open a PR.

The main goal that we should achieve is: that the users can install this library and only need to install an optional dependency if they import that code, so express users can use ExpressFramework without need to install all the other frameworks, for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants