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

pkg.main is always parsed as a script, even if it's not #311

Open
Rich-Harris opened this issue Sep 14, 2022 · 1 comment
Open

pkg.main is always parsed as a script, even if it's not #311

Rich-Harris opened this issue Sep 14, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Rich-Harris
Copy link
Contributor

I would categorise this as a super-duper-edge case were it not for the fact that the offending package, @mapbox/node-pre-gyp, has around 3.3m weekly downloads.

That package's package.json contains the following:

"main": "index.html"

Unsurprisingly, this blows up: sveltejs/kit#5577 (comment).

Perhaps pkg.main should be treated as a script or asset based on the same extension logic as other files?

@styfle
Copy link
Member

styfle commented Sep 14, 2022

Yeah I think we could exclude .html even if explicitly defined in main.

Technically this usage is valid today if index.html is actually a JS file and Node.js will happily accept it.

But in practice that is probably not common and so we could skip the parse step.

Another alternative is to parse and fail, then ignore the warning if it ends with .html. Although that seems like something the consumer of nft can do too, like this: sveltejs/kit#6810

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants