Fix sideEffects package configuration for "auto" entrypoints #194
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The package uses
sideEffects
along with ES Moduleexports
to allow consuming projects to optimize the amount of code generated when using individual components from the package, via dead-code elimination / "tree shaking".sideEffects
instructs the bundler that there are no side-effects in importing the code, and that it's safe to discard code except for direct references to exported members.However, this project also distributes an "auto" version, which is intended to automatically handle initialization for all components simply by being loaded:
This requires side effects, and therefore must be made an exception by passing paths as an array to
sideEffects
(see documentation). Otherwise, no code will be loaded since Webpack will assume it's safe to eliminate all unreferenced exports, and since there are no referenced exports, all code would be omitted.In the meantime, projects using the current published version can work around this by configuring Webpack to override the package's default
sideEffects
value (reference):