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

Fix mismatched types between entrypoint and pure modules #565

Merged
merged 2 commits into from Mar 14, 2024

Conversation

fruchtose-stripe
Copy link
Contributor

Summary & motivation

This change addresses #563. Types from pure and the main entrypoint are not interchangeable since rollup-plugin-dts generates two separate sets of types. This fixes the issue and keeps the .d.mts files by copying the .d.ts files from the types directory into ./dist in two copies: one with the .d.ts extension, and with the .d.mts extension as well.

I've also made two directories for module entrypoints so that the main and pure entrypoints live in sister folders lib and pure. This helps with testing and standardization.

Testing & documentation

I tested these changes with a number of sample repos, as well as with the react-stripe-js repo. I also checked with arethetypeswrong and publint.

Copy link
Contributor

@winnie-stripe winnie-stripe left a comment

Choose a reason for hiding this comment

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

morale stamp

@fruchtose-stripe fruchtose-stripe merged commit 0230bbd into master Mar 14, 2024
2 checks passed
@fruchtose-stripe fruchtose-stripe deleted the fruchtose/dupe-dts branch March 14, 2024 17:25
@esetnik
Copy link

esetnik commented Mar 14, 2024

@fruchtose-stripe I am seeing the following in our jest tests after updating to v3.0.9

   Cannot find module '../dist/stripe' from 'node_modules/@stripe/stripe-js/lib/index.js'

    Require stack:
      node_modules/@stripe/stripe-js/lib/index.js
      src/App.tsx
      test/test-utils.tsx
      src/Components/__tests__/PickerMulti.tsx
      ```

@yaskor
Copy link

yaskor commented Mar 14, 2024

Same problem as esetnik here:

X [ERROR] Could not resolve "../dist/stripe.mjs"

node_modules/@stripe/stripe-js/lib/index.mjs:1:14:
  1 │ export * from '../dist/stripe.mjs';

Created Issue...
Downgrade doesn't work...

@fruchtose-stripe
Copy link
Contributor Author

Hi all. Thank you for the reports. This pull request has been reverted in issue v3.0.10. Please use that version instead.

fruchtose-stripe added a commit that referenced this pull request Mar 14, 2024
* Change types generation strategy to avoid duplicate declarations

* Remove rollup-plugin-dts
fruchtose-stripe added a commit that referenced this pull request Mar 14, 2024
* Fix mismatched types between entrypoint and pure modules (#565)

* Change types generation strategy to avoid duplicate declarations

* Remove rollup-plugin-dts

* Fix import paths
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.

None yet

7 participants