-
Notifications
You must be signed in to change notification settings - Fork 8
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
Update package.json #104
base: main
Are you sure you want to change the base?
Update package.json #104
Conversation
Add sideEffects: false for better code split Signed-off-by: denisx <[email protected]>
@@ -15,6 +15,7 @@ | |||
"url": "https://github.com/fastify/fast-uri/issues" | |||
}, | |||
"homepage": "https://github.com/fastify/fast-uri", | |||
"sideEffects": false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this? How is this used by the project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brave Search:
In a package.json file, sideEffects is a property that indicates whether a package has side effects or not. A side effect occurs when a module’s execution affects something outside its own scope, such as:
Modifying the global scope (e.g., adding properties to the window object).
Throwing errors or exceptions.
Logging messages to the console.
Making network requests or I/O operations.Why is sideEffects important?
When a bundler like Webpack or Rollup builds a bundle, it uses the sideEffects property to determine which modules can be safely removed or “tree-shaken” from the bundle. This optimization helps reduce the bundle size and improves performance.
I don't know if we support these non-official properties though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- https://wiki.commonjs.org/wiki/Packages/1.0
- https://docs.npmjs.com/cli/v10/configuring-npm/package-json?v=true
In general, if it isn't documented in one of those places, and doesn't have a direct use by the project itself (e.g. a precommit
field used by @fastify/pre-commit
), I don't think unexplained properties should be added to the package manifest. If it requires searching the Internet to figure out its purpose, it is an unmaintainable property contributing nothing other than mystery to the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this in principle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of which are used by this project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could add this for isomorphic libraries
I won't block this, but I think it is a mistake to add unexplained properties to the package manifest.
add more info at description 🙏 |
Please detail an actual problem. As it is written, I do not see what problem is being fixed. And it seems like there are probably better ways of fixing whatever the problem is. |
adding more info. profit, we need size profit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically we can't set sideEffects to false because some lookup data is initialized at evaluation time.
Can we understand this data and set to sideEffects directly? (for skipping other unused) |
@mcollina if some data used at evaluation time (or anywhere) and it have been imported, it won't be cutted by bundler |
we can make rc and check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed my mind about not adding a blocking review as it stands. We have not seen a clear explanation of what this actually fixes, and there is not any test included to prove that it fixes whatever that problem is. In my opinion, in order to merge this, it needs to include a test that fails without the change.
Have you test to check |
Second line to bundler Signed-off-by: denisx <[email protected]>
I don't understand the question. |
You write "it needs to include a test", but my pr set package.json settings, such another Ok, my decision: a make a clone with another name, and publish not oficial rc version, to check at project. And then we will resolve or reject pr. |
As detailed in #104 (comment), the Regardless, it is tested in all of the unit tests. As an example: Line 4 in 8911706
|
Add
sideEffects: false
andmodule
path, for better code splitThis set help package works at commonjs and esm emulation
In code we have some named imports
but it is not tree shaked by bundler, and it use all functions for build.
profit: it will be less unused code at prod bundle (now - using named imports make no effect)