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
When requireing a json file, the plugin @rollup/plugin-json is required.
If the plugin is missing, I would expect to get the message Error: Unexpected token (Note that you need @rollup/plugin-json to import JSON files) - as a new user, this is an extremely helpful error message.
Actual Behaviour
When requireing a json file that has an array as the root, and not an object, this error message is not displayed - instead, a much less useful message Error: 'default' is not exported by json-array.json, imported by /home/projects/node-krh8ki/json-array.json?commonjs-proxy is shown.
The text was updated successfully, but these errors were encountered:
An empty array is valid JavaScript, so it is slightly tricky to detect this. But I guess to improve here, it would be sufficient to extend the errors for missing exports with a check if the file extension is .json and then add the same hint to those error messages.
Glad you like the hint we added to the parse error 😉
Rollup Version
^2.78.0
Operating System (or Browser)
MacOS 12.2.1
Node Version (if applicable)
No response
Link To Reproduction
https://stackblitz.com/edit/node-krh8ki?file=README
Expected Behaviour
When
require
ing a json file, the plugin@rollup/plugin-json
is required.If the plugin is missing, I would expect to get the message
Error: Unexpected token (Note that you need @rollup/plugin-json to import JSON files)
- as a new user, this is an extremely helpful error message.Actual Behaviour
When
require
ing a json file that has an array as the root, and not an object, this error message is not displayed - instead, a much less useful messageError: 'default' is not exported by json-array.json, imported by /home/projects/node-krh8ki/json-array.json?commonjs-proxy
is shown.The text was updated successfully, but these errors were encountered: