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

[node-resolve]: sideEffects in project root package.json unexpectedly affects the bundled result of codes out of node_modules #692

Closed
07akioni opened this issue Dec 6, 2020 · 2 comments

Comments

@07akioni
Copy link

07akioni commented Dec 6, 2020

  • Rollup Plugin Name: plugin-node-resolve
  • Rollup Plugin Version: 11.0.0
  • Rollup Version: 2.34.2
  • Operating System (or Browser): Mas OS, Chrome
  • Node Version: v10.22.0
  • Link to reproduction (⚠️ read below):

https://repl.it/join/xcjdwawr-07akioni

Expected Behavior

The sideEffect field in project root package.json shouldn't affect the bundled code inside the project.

Actual Behavior

It has effects.

app-index.js → app-output.js...
created app-output.js in 101ms
var dist = { name: 'object' };

console.log(dist);

app-index.js → app-output-no-node-resolve.js...
created app-output-no-node-resolve.js in 57ms
var dist = { name: 'object' };

dist.sideEffect = true;

console.log(dist);

Additional Information

I'm building a library without side effects. However the demo site (may have some side-effects, for example css or some codes) is both placed in same the folder. Should we make codes out of node_modules follow its package.json?

@tjenkinson
Copy link
Member

The sideEffect field in project root package.json shouldn't affect the bundled code inside the project.

This makes sense although I haven't checked the spec yet.

I think for each file we always look at the nearest package.json to determine if the file has side effects, which we probably shouldn't do for the root package. Added a currently failing test in 91a881d

@stale
Copy link

stale bot commented Apr 3, 2021

Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it.

@stale stale bot closed this as completed Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants