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

json helper that end with ?commonjs-proxy go through vite:json then throws a error #1679

Closed
2 of 3 tasks
QiroNT opened this issue Jan 24, 2021 · 0 comments
Closed
2 of 3 tasks

Comments

@QiroNT
Copy link

QiroNT commented Jan 24, 2021

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

If a commonjs dependence imports a json, vite throws an error.

[vite:json] Failed to parse JSON file.
file: /***/***.json?commonjs-proxy

By manually logging the id passed to vite:json:

/***/***.json
/***/***.json?commonjs-proxy

It shows that the json helper come out from @rollup/plugin-commonjs get recognized as a "json" and go through vite:json plugin.

Reproduction

Add a commonjs dependence that imports a json, like markdown-it.

System Info

  • vite version: 2.0.0-beta.45
  • Operating System: Windows
  • Node version: 15.5.1
  • Package manager (npm/yarn/pnpm) and version: yarn 2.4.0

Logs (Optional if provided reproduction)

building for production...
[vite:json] Failed to parse JSON file.
file: /***/node_modules/entities/lib/maps/entities.json?commonjs-proxy
error during build:
Error: Failed to parse JSON file.
    at error (\***\node_modules\rollup\dist\shared\rollup.js:4528:30)
    at throwPluginError (\***\node_modules\rollup\dist\shared\rollup.js:18162:12)
    at Object.error (\***\node_modules\rollup\dist\shared\rollup.js:18769:24)
    at Object.error (\***\node_modules\rollup\dist\shared\rollup.js:18331:38)
    at Object.transform (\***\node_modules\vite\dist\node\chunks\dep-76d13b8d.js:40690:22)
    at \***\node_modules\rollup\dist\shared\rollup.js:18971:25
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant