Skip to content

fix: keep side effects from modules#1190

Merged
Anber merged 1 commit intocallstack:masterfrom
layershifter:fix/keep-important-side-effects
Jan 18, 2023
Merged

fix: keep side effects from modules#1190
Anber merged 1 commit intocallstack:masterfrom
layershifter:fix/keep-important-side-effects

Conversation

@layershifter
Copy link
Contributor

Motivation

Fixes #1189.

Summary

Generally there two kinds of side-effects:

  • asset imports (`import './foo.css')
  • real code ('import './foo')

We want to keep only imports that contain code. Implemented shouldKeepSideEffect() to check if an import should stay.

shouldKeepSideEffect('regenerator-runtime') // true
shouldKeepSideEffect('./asset.css') // false

The tricky part is that shouldKeepSideEffect('object.values') is false 💥 However, we can't do much at this step: to be sure we need to resolve imports 🙃

Test plan

New tests have been added.

@changeset-bot
Copy link

changeset-bot bot commented Jan 17, 2023

🦋 Changeset detected

Latest commit: 760cb5c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@linaria/shaker Patch
@linaria/babel-preset Patch
linaria Patch
@linaria/testkit Patch
vite-example Patch
@linaria/cli Patch
@linaria/esbuild Patch
@linaria/rollup Patch
@linaria/stylelint Patch
@linaria/vite Patch
@linaria/webpack4-loader Patch
@linaria/webpack5-loader Patch
esbuild-example Patch
rollup-example Patch
vpssr-linaria-solid-example Patch
@linaria/webpack-loader Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Anber Anber merged commit cf1d661 into callstack:master Jan 18, 2023
@layershifter layershifter deleted the fix/keep-important-side-effects branch January 18, 2023 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import side-effects are removed

2 participants