1
- # ⚠️ v3.0.x Notice
1
+ # Stripe.js as a CommonJS module or ES module
2
2
3
- We are aware of an issue impacting builds for some TypeScript users in our
4
- package releases ** v3.0.0** , ** v3.0.1** , ** v3.0.2** and recommend users to
5
- upgrade to our latest package release
6
- [ ** v3.0.3** ] ( https://github.com/stripe/stripe-js/releases/tag/v3.0.3 ) which
7
- contains a fix.
8
-
9
- # Stripe.js ES Module
10
-
11
- Use [ Stripe.js] ( https://stripe.com/docs/stripe-js ) as an ES module.
3
+ This package allows [ Stripe.js] ( https://stripe.com/docs/stripe-js ) to be
4
+ imported as a CommonJS module or ES module.
12
5
13
6
** Note** : To be
14
7
[ PCI compliant] ( https://stripe.com/docs/security/guide#validating-pci-compliance ) ,
@@ -86,18 +79,6 @@ Note that we may release new [minor and patch](https://semver.org/) versions of
86
79
` @stripe/stripe-js ` with small but backwards-incompatible fixes to the type
87
80
declarations. These changes will not affect Stripe.js itself.
88
81
89
- ### [ ` moduleResolution ` ] ( https://www.typescriptlang.org/tsconfig#moduleResolution ) support
90
-
91
- This package supports the following module resolution strategies:
92
-
93
- - ` bundler `
94
- - ` node16 `
95
- - ` nodenext `
96
-
97
- This package does not support ` node10 ` or ` node ` strategies, which do not
98
- support ES6 modules. Using ` node16 ` or ` nodenext ` is recommended as a
99
- replacement configuration.
100
-
101
82
## Ensuring Stripe.js is available everywhere
102
83
103
84
To best leverage Stripe’s advanced fraud functionality, ensure that Stripe.js is
@@ -137,9 +118,12 @@ one. When you call `loadStripe`, it will use the existing script tag.
137
118
138
119
If you would like to use ` loadStripe ` in your application, but defer loading the
139
120
Stripe.js script until ` loadStripe ` is first called, use the alternative
140
- ` @stripe/stripe-js/pure ` import path :
121
+ ` @stripe/stripe-js/pure ` import module :
141
122
142
123
``` js
124
+ // CommonJS module import
125
+ const {loadStripe } = require (' @stripe/stripe-js/pure' );
126
+ // ES module import
143
127
import {loadStripe } from ' @stripe/stripe-js/pure' ;
144
128
145
129
// Stripe.js will not be loaded until `loadStripe` is called
@@ -153,6 +137,9 @@ If you would like to
153
137
altogether, use ` loadStripe.setLoadParameters ` :
154
138
155
139
``` js
140
+ // CommonJS module import
141
+ const {loadStripe } = require (' @stripe/stripe-js/pure' );
142
+ // ES module import
156
143
import {loadStripe } from ' @stripe/stripe-js/pure' ;
157
144
158
145
loadStripe .setLoadParameters ({advancedFraudSignals: false });
0 commit comments