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

package.json is missing main field #552

Closed
IanVS opened this issue Dec 13, 2022 · 3 comments
Closed

package.json is missing main field #552

IanVS opened this issue Dec 13, 2022 · 3 comments
Labels

Comments

@IanVS
Copy link

IanVS commented Dec 13, 2022

Describe the bug

Not all tooling supports the package.json exports field, including TypeScript when running with moduleResolution: node (which is the case for most apps using a bundler). Is there a reason not to include a main field to improve compatibility with existing tooling?

In my particular case, I'm having trouble with eslint's import/no-extraneous rule. It does not think the plugin is installed, but it is.

Reproduction URL

https://stackblitz.com/edit/vitejs-vite-yb9bgt?file=src%2Fexample.js&terminal=lint

Reproduction

Check the example, eslint throws an error. If you add a main to the package.json, the error disappears.

Logs

No response

System Info

N/A
@IanVS IanVS added bug Something isn't working triage Awaiting triage by a project member labels Dec 13, 2022
@dominikg
Copy link
Member

This should be raised at eslint. exports map has a higher priority than main, in fact it means that main must be ignored.

Typescript has it's own types condition and we set that, so that should not be a problem if it is, again, raise it with them.

Sorry if this sounds harsh but the whole "main vs module vs browser vs whatever" top level resolve hint field debacle is only going to get worse if people start adding exports maps to the mix instead of replacing the older fields.

We kept main until we were dropping our commonjs output for backwards compatibility. For all node versions we support, exports maps is supported, so use that.

@dominikg dominikg closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2022
@IanVS
Copy link
Author

IanVS commented Dec 13, 2022

That's disappointing. It feels like you're intentionally causing pain to developers like me for purely philosophical reasons.

And for what it's worth, the eslint issue has been open for a long time. It's not a simple matter to just fix it. import-js/eslint-plugin-import#2132

@dominikg
Copy link
Member

dominikg commented Dec 13, 2022

There is no pain, you can easily change your eslint config to ignore this rule for vite-plugin-svelte, or add a comment to ignore it above the import or contribute a fix to the eslint rule. Tools to resolve exports map exist: https://github.com/lukeed/resolve.exports
So having their issue open for 18 months is the cause of this, not us removing main because it is no longer needed.

@dominikg dominikg added commonjs and removed bug Something isn't working triage Awaiting triage by a project member labels Dec 13, 2022
IanVS added a commit to storybookjs/storybook that referenced this issue Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants