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

svelte-kit sync does not work when package file has json5 format #8918

Closed
christophsturm opened this issue Feb 6, 2023 · 1 comment
Closed

Comments

@christophsturm
Copy link

Describe the bug

pnpm supports json5 for the package file but when i do that 'svelte-kit sync' no longer works

Reproduction

pnpm create svelte@latest my-app # create a typescript skeletonproject with all defaults
cd my-app
mv package.json package.json5
pnpm update # to have pnpm start using json5 syntax in the file
pnpm exec svelte-kit sync
(node:23795) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/christoph/Projects/temp/my-app/svelte.config.js:1
import adapter from '@sveltejs/adapter-auto';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1166:20)
    at Module._compile (node:internal/modules/cjs/loader:1210:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1300:10)
    at Module.load (node:internal/modules/cjs/loader:1103:32)
    at Module._load (node:internal/modules/cjs/loader:942:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:168:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)

Node.js v19.6.0

Logs

No response

System Info

System:
    OS: macOS 13.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 67.03 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.6.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.4.0 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 108.0.5359.98
    Edge: 108.0.1462.46
    Firefox Developer Edition: 107.0
    Safari: 16.3
    Safari Technology Preview: 16.4

Severity

annoyance

Additional Information

No response

@Conduitry
Copy link
Member

pnpm may support JSON5, but Node itself still requires a package.json file with "type": "module" in order to interpret .js files as ESM. And pnpm is going to prefer the package.json file over the package.json5 file if they're both present (pnpm/pnpm#3027, pnpm/pnpm#5541). I'd suggest not using pnpm's JSON5 support for now (or even ever, maybe). There's not really anything SvelteKit can do about this for now.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2023
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

2 participants