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

Configure 2 TypeScript compile targets for ESM and CJS #1704

Merged
merged 21 commits into from
Mar 14, 2023

Conversation

anniel-stripe
Copy link
Contributor

@anniel-stripe anniel-stripe commented Mar 9, 2023

Summary

Prepare to convert stripe-node to a dual package. This sets up the TypeScript build step to transpile into two separate ESM and CJS outputs, but we only expose the cjs entry point for now.

In this PR:

  • Configure 2 TypeScript builds for CJS and ESM, respectively, to cjs and esm (lib is removed)
  • Update entry points to point to the CommonJS entry point defined by src/stripe.cjs.*..ts, will add ESM entry point in a follow-up PR
  • Rename stripe.common.ts to stripe.core.ts because the naming is too similar to CommonJS
  • Add Stripe and default properties to Stripe object in stripe.core.ts for backwards compatibility
  • Update relative imports to specify .js file ending
  • Set package version directly in stripe.core.ts and add rule to update that version during releases.
  • Update paths in test files to point to cjs/ output

Testing

In addition to CI tests, verified that package works as expected in manual test projects

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/createStripe.ts Outdated Show resolved Hide resolved
src/createStripe.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@pakrym-stripe pakrym-stripe left a comment

Choose a reason for hiding this comment

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

Nice work! Mostly nits and discussions.

.eslintrc.js Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
cjs/RequestSender.js Outdated Show resolved Hide resolved
tsconfig.esm.json Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/createStripe.ts Outdated Show resolved Hide resolved
test/utils.spec.ts Show resolved Hide resolved
src/stripe.esm.worker.ts Show resolved Hide resolved
src/createStripe.ts Outdated Show resolved Hide resolved
test/PlatformFunctions.spec.ts Show resolved Hide resolved
@anniel-stripe anniel-stripe changed the title Add support for ESM Configure 2 TypeScript compile targets for ESM and CJS Mar 13, 2023
.eslintrc.js Outdated Show resolved Hide resolved
Copy link
Contributor

@pakrym-stripe pakrym-stripe left a comment

Choose a reason for hiding this comment

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

nits

Copy link
Contributor

@pakrym-stripe pakrym-stripe left a comment

Choose a reason for hiding this comment

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

Great work!

@anniel-stripe anniel-stripe merged commit e14e183 into master Mar 14, 2023
@anniel-stripe anniel-stripe deleted the anniel-dual-entrypoints branch March 14, 2023 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants