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

Ignore invalid package.json fields #10053

Merged
merged 1 commit into from
Dec 16, 2024
Merged

Ignore invalid package.json fields #10053

merged 1 commit into from
Dec 16, 2024

Conversation

devongovett
Copy link
Member

Fixes #10051

Some popular packages started putting invalid values like "main": false in their package.jsons causing serde to fail to parse. See es-shims/dunder-proto#2 and es-shims/math-intrinsics#2 for example. This uses a custom serde deserializer to ignore errors and use the default value instead.

@devongovett devongovett merged commit 86ca555 into v2 Dec 16, 2024
17 checks passed
@devongovett devongovett deleted the invalid-package branch December 16, 2024 17:50
@ljharb
Copy link

ljharb commented Dec 16, 2024

To be clear, this isn't the same as the default value - false means "you can't ever import it", not "use index.js"

@devongovett
Copy link
Member Author

To be clear, this isn't the same as the default value - false means "you can't ever import it", not "use index.js"

@ljharb No, that's incorrect. Node falls back to index.js when "main" is set to false. That's clear from the spec in the Node docs (https://nodejs.org/api/modules.html#all-together):

If "main" is a falsy value, GOTO 2.

...
2. LOAD_INDEX(X)

Here's a small example to prove it. Run node test.js to see for yourself. test.zip

@ljharb
Copy link

ljharb commented Dec 16, 2024

fair enough, thanks for keeping me honest :-)

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

Successfully merging this pull request may close these issues.

Parcel 2, bult error with on @parcel/transformer-pug
2 participants