stripe-firebase-extensions icon indicating copy to clipboard operation
stripe-firebase-extensions copied to clipboard

firestore-stripe-payments v0.0.4 has error: SyntaxError: Unexpected token 'export'

Open dninomiya opened this issue 3 years ago • 18 comments

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 :)

dninomiya avatar Dec 10 '21 02:12 dninomiya

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.

louis-md avatar Jan 04 '22 20:01 louis-md

Experiencing this in a Svelte app as well.

dpsthree avatar Jan 08 '22 04:01 dpsthree

+1 Experiencing the same issue with @deerboy. Also using Next.js

normanwongcl avatar Jan 18 '22 03:01 normanwongcl

Until Stripe fixes this you can use the useStripe React webhook I threw together.

christiangenco avatar Jan 29 '22 16:01 christiangenco

This is still an issue.

chernushevich avatar Jan 30 '22 18:01 chernushevich

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 avatar Feb 01 '22 16:02 lahirumaramba

@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",

KaiSpencer avatar Feb 06 '22 16:02 KaiSpencer

Having this same issue with sveltekit, any one who can help?

avilabss avatar Nov 15 '22 01:11 avilabss

Same issue here with nextjs, ~~workaround not working~~

Workaround works, was user (by which I mean my own) error

NomadicDeveloper22 avatar Dec 09 '22 01:12 NomadicDeveloper22

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.

locatejp avatar Jan 05 '23 01:01 locatejp

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.

vantezzen avatar Jan 11 '23 13:01 vantezzen

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

jmdibble avatar Jan 12 '23 10:01 jmdibble

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!

avilabss avatar Jan 13 '23 06:01 avilabss

transpilePackages does not work for me.

epleaner avatar Jan 26 '23 01:01 epleaner

Any updates here?

mattlrobinson7 avatar Feb 03 '23 05:02 mattlrobinson7

transpilePackages works for me

waltershewmake avatar Feb 05 '23 00:02 waltershewmake

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

cjschamith avatar Jul 03 '23 11:07 cjschamith

With the sdk update, you need to change the workaround to :

const nextConfig = {
  ...
  transpilePackages: ["@invertase/firestore-stripe-payments"],
};

vidalmaxime avatar Nov 24 '23 11:11 vidalmaxime