-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix tree shaking #21
Fix tree shaking #21
Conversation
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
Here are a few tests with canary |
"main": "./dist/index.js", | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.js", |
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.
Does that mean that we don't provide cjs exports anymore?
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 found a couple of places where it says that setting "main": "./dist/index.js",
is enough for cjs. But I might be wrong. What would be your recommendation?
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 am not that experienced with this kind of setting. @ndelangen is the best person to ask.
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.
On what basis are we making these changes? What's the rationale? Do we know what effects these changes will have and why?
I'd expect a PR description detailing what the problem was, how the code change fixes it and potentially the alternatives and potential alternatives.
This is the first time for me looking at this codebase as far as I can remember, so I can't determine if this change is ok or now.
- removing
cjs
exports seems/feels wrong - adding the "pure"-comments in source seems wrong too.
But maybe there are valid reasons for doing this. I do not have enough context.
I do not trust the screenshots of a website I do not know the details of.
I was told it's running esbuild, but it's extremely dependent on how esbuil is configured, as well as other factors in our toolchain if the code is actually treeshaken in the end or not.
I'd like to see the actual tree-shaken code when consumed in the manager itself, and inside a manager-entry.
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.
@ndelangen We are not using the library anywhere right now. The question is more about is the best way to export the library in package.json
. I made this change in package.json
because it was recommended in a couple of articles I found but I'm definitely not an expert in that field.
- I am not removing
cjs
export - Adding the pure comment is a compromise we found with @JReinhold and @valentinpalkovic to make sure forward Ref is considered pure. This PR for more context:
React.forwardRef
is not annotated as PURE evanw/esbuild#2749
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 I'm not sure what's the difference between:
"main": "./dist/index.js",
"module": "./dist/index.mjs",
and
"main": "./dist/index.js",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
}
}
In the later, it seem we still need "main"
. I can't find a clear answer on the web.
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.
By the way @ndelangen I brought back the change.
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.
Adding the pure comment is a compromise we found with @JReinhold and @valentinpalkovic to make sure forward Ref is considered pure. This PR for more context: evanw/esbuild#2749
Thank you for that context & link, I agree that it makes sense then.
brought back the change
Ok, I see. I'm fine with removing it, if we're sure that's the right thing to do, and we can argue why, and preferable demonstrate.
package.json
exports fields are complex, because they are used by a variety of tools in a variety of ways depending on multiple variables
@Georgegriff This new library was introduced in 8.0 only. We deprecated the old icon package in Did you use this library already in your project? |
Here is an explanation of the chain of dependencies: -
This is the error we hit: Hopefully this explains how this was a breaking change, it was other |
In the previous PR we introduced
React.forwardRef
and reformatted how svgs are structured. Because ESBuild and TSUP doesn't considerReact.forwardRef
as pure we had to add it locally on each components to make sure that tree shaking is working again.Here's a reference to a similar issue and why ESBuild is not going to resolve that:
evanw/esbuild#2749
📦 Published PR as canary version:
1.2.1--canary.21.bf34a28.0
✨ Test out this PR locally via: