Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Unexpected token 'export' when using with Remix/Vite #40

Open
valdineifer opened this issue Jun 2, 2024 · 0 comments
Open

Error Unexpected token 'export' when using with Remix/Vite #40

valdineifer opened this issue Jun 2, 2024 · 0 comments

Comments

@valdineifer
Copy link

valdineifer commented Jun 2, 2024

I'm getting this error when using this package with Remix/Vite. I only fixed this error with one of these actions:

  • adding "type": "module" in the package.json of this npm package;
  • adding the module (as string json-diff-kit) to the ssr.noExternal array in vite.config.ts (i think this option may affect performance).

Update: Actually, I think that the second option doesn't works, because now I'm getting another error: document is not defined, possibly due to SSR.
Update 2: I used the Suspense element from React and it solved the document error.

I created this issue because I think that it doesn't seems to be right do one of these things to get this package to work, instead of the common way: install->import->usage.


Details of the error:

19:37:18 [vite] Error when evaluating SSR module virtual:remix/server-build: failed to import "...myfile..._.$id.tsx"
|- ~/myprojectfolder/node_modules/json-diff-kit/dist/index.js:1
export { default as Differ } from './differ.js';
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:77:18)
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1340:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:356:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant