stripe-firebase-extensions
stripe-firebase-extensions copied to clipboard
firestore-stripe-payments v0.0.4 has error: SyntaxError: Unexpected token 'export'
Bug report
- @stripe/firestore-stripe-payments
Describe the bug
in Next.js
import {
createCheckoutSession,
getStripePayments,
} from '@stripe/firestore-stripe-payments';
// some code ...
👇🏻
SyntaxError: Unexpected token 'export'
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
/Users/nino/Projects/simple-flock/node_modules/ (stripe/firestore-stripe-payments/lib/index.js (16)
Object.compileFunction
node:vm (352:18)
wrapSafe
node:internal/modules/cjs/loader (1025:15)
Module._compile
node:internal/modules/cjs/loader (1059:27)
Object.Module._extensions..js
node:internal/modules/cjs/loader (1147:10)
Module.load
node:internal/modules/cjs/loader (975:32)
Function.Module._load
node:internal/modules/cjs/loader (822:12)
Module.require
node:internal/modules/cjs/loader (999:19)
require
node:internal/modules/cjs/helpers (102:18)
Object.@stripe/firestore-stripe-payments
file:///Users/nino/Projects/simple-flock/.next/server/pages/mypage.js (197:18)
__webpack_require__
file:///Users/nino/Projects/simple-flock/.next/server/webpack-runtime.js (33:42)
v0.0.3 is work ✅ v0.0.4 has error 🚫
Thank you for your support :)
Same problem.
I tried to edit the package.json of the module, as well as the project is imported in, to "type": "module", but didn't solve the problem. I tried downgrading the module to v0.0.3, but it did not solve it either.
Experiencing this in a Svelte app as well.
+1 Experiencing the same issue with @deerboy. Also using Next.js
Until Stripe fixes this you can use the useStripe React webhook I threw together.
This is still an issue.
I was able to reproduce this issue on all versions v0.0.3
to v0.0.6
with a next-js
starter project.
├── @stripe/[email protected]
├── [email protected]
├── [email protected]
└── [email protected]
Couldn't find any specific config changes that could cause this in firestore-stripe-payments
codebase.
However, I was able to fix the error by adding the following to next.config.js
.
const withTM = require('next-transpile-modules')([
'@stripe/firestore-stripe-payments'
]);
/** @type {import('next').NextConfig} */
module.exports = withTM({
reactStrictMode: true,
});
Let us know if using next-transpile-modules
in next.config.js
could be a workaround until we find the root cause for this issue. Thanks!
FYI: @lemuel-stripe @cjavilla-stripe
@lahirumaramba I can confirm this workaround works.
"@stripe/firestore-stripe-payments": "^0.0.6",
"firebase": "^9.6.6",
"next": "12.0.0",
"next-transpile-modules": "^9.0.0",
Having this same issue with sveltekit, any one who can help?
Same issue here with nextjs, ~~workaround not working~~
Workaround works, was user (by which I mean my own) error
Same issue here, starting a new project that only has npm i firebase
and npm i @stripe/firestore-stripe-payments
with import getStripePayments from '@stripe/firestore-stripe-payments'
and running the file with node <filename>.js
is enough to reproduce the issue.
For those experiencing this bug, you can add this to your next.config.js
:
const nextConfig = {
// ...
transpilePackages: ["@stripe/firestore-stripe-payments"],
};
Edit: You will need to restart the server and might still get an error in the console, but the package should still work normally.
Having the same issue when deploying Firebase cloud function using version 0.0.6
using import { getStripePayments } from "@stripe/firestore-stripe-payments";
The error points to line 16 in this file:
node_modules/@stripe/firestore-stripe-payments/lib/index.js
A bit of a nasty workaround, but I did this: I copied all code as is just how they are in files. Make necessary changes and put everything in "lib" folder to make a mini module out of it.
Then you can import it normally and that works!
transpilePackages
does not work for me.
Any updates here?
transpilePackages
works for me
It's been more than a year but still no solution to it even after identified it as a bug. meanwhile, you guys are still recommending people to use it with Run Payments with Stripe extension.
really disappointed! @lahirumaramba
With the sdk update, you need to change the workaround to :
const nextConfig = {
...
transpilePackages: ["@invertase/firestore-stripe-payments"],
};