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 types for node16/bundler module resolution strategies #553

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 20.x
- run: yarn install --frozen-lockfile
- run: yarn run lint
- run: yarn run typecheck
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ of features of Stripe.js.
## Minimum requirements

- Node.js: v12.16
- TypeScript: v.3.1.1

## Installation

Expand Down Expand Up @@ -77,6 +78,18 @@ Note that we may release new [minor and patch](https://semver.org/) versions of
`@stripe/stripe-js` with small but backwards-incompatible fixes to the type
declarations. These changes will not affect Stripe.js itself.

### [`moduleResolution`](https://www.typescriptlang.org/tsconfig#moduleResolution) support

This package supports the following module resolution strategies:

- `bundler`
- `node16`
- `nodenext`

This package does not support `node10` or `node` strategies, which do not
support ES6 modules. Using `node16` or `nodenext` is recommended as a
replacement configuration.

## Ensuring Stripe.js is available everywhere

To best leverage Stripe’s advanced fraud functionality, ensure that Stripe.js is
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
"exports": {
".": {
"import": {
"types": "./types/index.d.ts",
"types": "./dist/index.d.mts",
"default": "./dist/stripe.mjs"
},
"require": {
"types": "./types/index.d.ts",
"types": "./dist/index.d.ts",
"default": "./dist/stripe.js"
}
},
"./pure": {
"import": {
"types": "./types/pure.d.ts",
"types": "./dist/pure.d.mts",
"default": "./dist/pure.mjs"
},
"require": {
"types": "./types/pure.d.ts",
"types": "./dist/pure.d.ts",
"default": "./dist/pure.js"
}
}
Expand Down Expand Up @@ -78,6 +78,7 @@
"rimraf": "^2.6.2",
"rollup": "^1.29.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-typescript2": "^0.25.3",
"ts-jest": "^24.3.0",
"typescript": "^4.1.2",
Expand Down
17 changes: 17 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import babel from 'rollup-plugin-babel';
import ts from 'rollup-plugin-typescript2';
import {dts} from 'rollup-plugin-dts';
import replace from '@rollup/plugin-replace';

import pkg from './package.json';
Expand All @@ -25,6 +26,14 @@ export default [
],
plugins: PLUGINS,
},
{
input: 'types/index.d.ts',
output: [
{file: './dist/index.d.ts', format: 'cjs'},
{file: './dist/index.d.mts', format: 'es'},
],
plugins: [dts()],
},
{
input: 'src/pure.ts',
output: [
Expand All @@ -33,4 +42,12 @@ export default [
],
plugins: PLUGINS,
},
{
input: 'types/pure.d.ts',
output: [
{file: './dist/pure.d.ts', format: 'cjs'},
{file: './dist/pure.d.mts', format: 'es'},
],
plugins: [dts()],
},
];
4 changes: 2 additions & 2 deletions types/pure.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///<reference path='./index.d.ts' />
import {loadStripe as _loadStripe} from './index';

export const loadStripe: typeof import('@stripe/stripe-js').loadStripe & {
export const loadStripe: typeof _loadStripe & {
setLoadParameters: (params: {advancedFraudSignals: boolean}) => void;
};
18 changes: 17 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==

"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14":
"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.4.15":
version "1.4.15"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==
Expand Down Expand Up @@ -3774,6 +3774,13 @@ magic-string@^0.25.5:
dependencies:
sourcemap-codec "^1.4.4"

magic-string@^0.30.4:
version "0.30.7"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.7.tgz#0cecd0527d473298679da95a2d7aeb8c64048505"
integrity sha512-8vBuFF/I/+OSLRmdf2wwFCJCz+nSn0m6DPvGH1fS/KiQoSaR+sETbov0eIk9KhEKy8CYqIkIAnbohxT/4H0kuA==
dependencies:
"@jridgewell/sourcemap-codec" "^1.4.15"

make-dir@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
Expand Down Expand Up @@ -4661,6 +4668,15 @@ rollup-plugin-babel@^4.3.3:
"@babel/helper-module-imports" "^7.0.0"
rollup-pluginutils "^2.8.1"

rollup-plugin-dts@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-6.1.0.tgz#56e9c5548dac717213c6a4aa9df523faf04f75ae"
integrity sha512-ijSCPICkRMDKDLBK9torss07+8dl9UpY9z1N/zTeA1cIqdzMlpkV3MOOC7zukyvQfDyxa1s3Dl2+DeiP/G6DOw==
dependencies:
magic-string "^0.30.4"
optionalDependencies:
"@babel/code-frame" "^7.22.13"

rollup-plugin-typescript2@^0.25.3:
version "0.25.3"
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.25.3.tgz#a5fb2f0f85488789334ce540abe6c7011cbdf40f"
Expand Down
Loading