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

Resolved package.json does not reflect resolved file #7908

Closed
wbinnssmith opened this issue Apr 6, 2022 · 1 comment · Fixed by #7909
Closed

Resolved package.json does not reflect resolved file #7908

wbinnssmith opened this issue Apr 6, 2022 · 1 comment · Fixed by #7909
Labels

Comments

@wbinnssmith
Copy link
Contributor

wbinnssmith commented Apr 6, 2022

Consider the following tree:

foo/
  package.json {sideEffects: false}
  real-bar.js
  bar/
    package.json {main: '../real-bar.js', has no defined sideEffects property}

Intuitively, it seems that real-bar.js's sideEffects value should be false, not undefined, as it's a child of the foo directory, which has a package.json defining "sideEffects": false.

However, when import 'foo/bar' is currently resolved, it resolves correctly to foo/real-bar.js, but the associated package.json for the asset is foo/bar/package.json, not foo/package.json. This makes foo/real-bar.js's sideEffects value undefined when it's required as import 'foo/bar', but it's false when it's required as import 'foo/real-bar.js' (or import './real-bar.js' or similar).

We should consider conditionally re-resolving an asset's package.json when the initially resolved package.json points to a module that would otherwise resolve a different package.json.

cc @mischnic @devongovett @thebriando

@mischnic
Copy link
Member

mischnic commented Apr 6, 2022

I think the proposed way makes sense, in any case we should do what the other tools do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants