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

feat/server-esm #366

Closed
wants to merge 3 commits into from
Closed

feat/server-esm #366

wants to merge 3 commits into from

Conversation

MasterKale
Copy link
Owner

@MasterKale MasterKale commented Feb 23, 2023

This PR aims to add an ESM build to @simplewebauthn/server, alongside the existing CJS build.

Fixes #338.

@MasterKale MasterKale added the package:server @simplewebauthn/server label Mar 1, 2023
@@ -7,13 +7,20 @@
"lib": [
"ES2021",
],
// "module": "CommonJS", // Regular CJS output
"module": "ESNext",
"moduleResolution": "node16",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"moduleResolution": "node16",
"moduleResolution": "bundler",

You might find that the bundler option works well here for your use case.

Copy link
Owner Author

@MasterKale MasterKale Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't I find any docs on how bundler is different from node16? Not even the TypeScript docs explain the new option:

https://www.typescriptlang.org/tsconfig#moduleResolution

Can you shed any light on how this will help this ESM effort?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#moduleresolution-bundler

It allows you to optionally omit the file extension in imports but keep the other benefits of node16.

Copy link
Owner Author

@MasterKale MasterKale Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#moduleresolution-bundler

Oh my god you have saved me so much time, thank you! 🤩

Edit: Tempering my enthusiasm a bit, bundler might not be a silver bullet, but it's still worth looking into:

On the other hand, if you’re writing a library that’s meant to be published on npm, using the bundler option can hide compatibility issues that may arise for your users who aren’t using a bundler. So in these cases, using the node16 or nodenext resolution options is likely to be a better path.

@MasterKale
Copy link
Owner Author

Superseded by #425.

@MasterKale MasterKale closed this Aug 22, 2023
@MasterKale MasterKale deleted the feat/server-esm branch August 22, 2023 00:15
@spendres
Copy link

spendres commented Aug 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:server @simplewebauthn/server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an ESM build to @simplewebauthn/server to support non-Node runtimes
3 participants