You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The firestore-stripe-web-sdk module is written as an ES Module, but it has a few problems that make it invalid ESM. First, there is no "type": "module" field in package.json and the files do not use the .mjs extension. Second, the relative imports need the full extension (as mentioned in TypeScript's docs), which they currently don't have.
import { getStripePayments } from "@stripe/firestore-stripe-payments";
^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'getStripePayments' not found. The requested module '@stripe/firestore-stripe-payments' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@stripe/firestore-stripe-payments';
const { getStripePayments } = pkg;
To Reproduce
It should be reproduceable with simpler configurations (without a framework), but I faced the issue when working with SvelteKit, so the the repro is based on SvelteKit.
Steps to reproduce the behavior:
npm create svelte@latest demo-app (choose Skeleton project for simplicity)
Add a src/routes/+layout.js file with just export const prerender = true; inside.
Run npm run build
Expected behavior
It should work normally.
System information
OS: Windows 10
Browser: Chrome
Node: v16.15.1
Additional context
Some build systems may auto-detect the module system and ignore the missing extension problem, but that doesn't make it a valid ES Module. In particular, I didn't face this issue with SvelteKit v1.0.0-next.350, but when I updated to a recent version that requires a separate vite config and the Vite CLI I got the error above. I'm not sure about the underlying difference between both versions.
Solution
The solution is simple:
Add "type": "module" to package.json
Add the .js extension to all relative imports (even if the source files are TS)
I can submit a PR with the fixes if needed.
The text was updated successfully, but these errors were encountered:
Bug report
Describe the bug
The firestore-stripe-web-sdk module is written as an ES Module, but it has a few problems that make it invalid ESM. First, there is no
"type": "module"
field inpackage.json
and the files do not use the.mjs
extension. Second, the relative imports need the full extension (as mentioned in TypeScript's docs), which they currently don't have.To Reproduce
It should be reproduceable with simpler configurations (without a framework), but I faced the issue when working with SvelteKit, so the the repro is based on SvelteKit.
Steps to reproduce the behavior:
npm create svelte@latest demo-app
(choose Skeleton project for simplicity)cd demo-app
andnpm install
npm install firebase @stripe/firestore-stripe-payments @sveltejs/adapter-static
adapter-auto
import withadapter-static
insvelte.config.js
src/routes/+page.svelte
:src/routes/+layout.js
file with justexport const prerender = true;
inside.npm run build
Expected behavior
It should work normally.
System information
Additional context
Some build systems may auto-detect the module system and ignore the missing extension problem, but that doesn't make it a valid ES Module. In particular, I didn't face this issue with SvelteKit
v1.0.0-next.350
, but when I updated to a recent version that requires a separatevite
config and the Vite CLI I got the error above. I'm not sure about the underlying difference between both versions.Solution
The solution is simple:
"type": "module"
topackage.json
.js
extension to all relative imports (even if the source files are TS)I can submit a PR with the fixes if needed.
The text was updated successfully, but these errors were encountered: