weareseeed / react-square-web-payments-sdk

Easily create PCI-compliant inputs to accept payments online with the Square Payments API. It supports the following payment methods: credit and debit cards, ACH bank transfers, Apple Pay, Google Pay, Gift Cards and Afterpay/Clearpay.
https://react-square-payments.weareseeed.com/
MIT License
37 stars 40 forks source link

Unexpected token 'export' when using Vite #96

Closed jmcmullen closed 7 months ago

jmcmullen commented 8 months ago

Describe the bug

I'm unable to use this package with vite, and attempting to do so throws the following error:

Unexpected token 'export'

/node_modules/.pnpm/react-square-web-payments-sdk@3.2.1_react@18.2.0/node_modules/react-square-web-payments-sdk/dist/index.es.js:1
export { Ach } from './components/ach/ach.es.js';
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)
    at Module._compile (node:internal/modules/cjs/loader:1220:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Your Example Website or App

https://stackblitz.com/edit/withastro-astro-tgict6?file=src%2Fcomponents%2FDemo.tsx

Steps to Reproduce the Bug or Issue

Import this library using vite.

Expected behavior

Correctly loads as an ES module.

Screenshots or Videos

No response

Platform

Additional context

Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

shabanbx commented 2 months ago

i am still getting this error just changed the compiler on my remix from its "Classic Compiler"to Vite