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

only add import references when they are used #8874

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

sokra
Copy link
Member

@sokra sokra commented Jul 30, 2024

Description

skips import to modules that are side effect free and have no exports referenced

This allows to e. g. skip the package import completely in the following code:

import { something } from "package"; // package is marked as side effect free

if (falsy) {
  something();
}

This could happen e. g. with code like if(process.env.NODE_ENV === "production")

Testing Instructions

skips import to modules that are side effect free and have no exports referenced
Copy link

vercel bot commented Jul 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2024 6:40am
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2024 6:40am
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Jul 30, 2024 6:40am
examples-designsystem-docs ⬜️ Ignored (Inspect) Jul 30, 2024 6:40am
examples-gatsby-web ⬜️ Ignored (Inspect) Jul 30, 2024 6:40am
examples-kitchensink-blog ⬜️ Ignored (Inspect) Jul 30, 2024 6:40am
examples-native-web ⬜️ Ignored (Inspect) Jul 30, 2024 6:40am
examples-svelte-web ⬜️ Ignored (Inspect) Jul 30, 2024 6:40am
examples-tailwind-web ⬜️ Ignored (Inspect) Jul 30, 2024 6:40am
examples-vite-web ⬜️ Ignored (Inspect) Jul 30, 2024 6:40am

@sokra sokra requested a review from kdy1 July 30, 2024 06:41
Copy link
Contributor

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

✅ This change can build next-swc

Copy link
Contributor

github-actions bot commented Jul 30, 2024

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (mac/win, non-blocking)

See workflow summary for details

@sokra sokra requested a review from bgw July 30, 2024 12:37
@sokra sokra merged commit 54b5b6d into main Jul 30, 2024
58 of 60 checks passed
@sokra sokra deleted the sokra/side-effect-free-imports branch July 30, 2024 14:44
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 30, 2024
### Description

skips import to modules that are side effect free and have no exports
referenced

This allows to e. g. skip the `package` import completely in the
following code:

``` js
import { something } from "package"; // package is marked as side effect free

if (falsy) {
  something();
}
```

This could happen e. g. with code like `if(process.env.NODE_ENV ===
"production")`

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->
sokra added a commit to vercel/next.js that referenced this pull request Jul 31, 2024
* vercel/turborepo#8875 <!-- Tobias Koppers -
improve test glob to exclude output folder -->
* vercel/turborepo#8874 <!-- Tobias Koppers - only
add import references when they are used -->
* vercel/turborepo#8766 <!-- Niklas Mischkulnig -
Replace MDX ModuleType with MDX SourceTransform -->
* vercel/turborepo#8090 <!-- DevMirza - fix(ci):
Trying to fix `benchmark-turbopack` workflow -->
* vercel/turborepo#8837 <!-- Niklas Mischkulnig -
Make JS Lints have lower severity -->
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
### Description

skips import to modules that are side effect free and have no exports
referenced

This allows to e. g. skip the `package` import completely in the
following code:

``` js
import { something } from "package"; // package is marked as side effect free

if (falsy) {
  something();
}
```

This could happen e. g. with code like `if(process.env.NODE_ENV ===
"production")`

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 16, 2024
* vercel/turborepo#8875 <!-- Tobias Koppers -
improve test glob to exclude output folder -->
* vercel/turborepo#8874 <!-- Tobias Koppers - only
add import references when they are used -->
* vercel/turborepo#8766 <!-- Niklas Mischkulnig -
Replace MDX ModuleType with MDX SourceTransform -->
* vercel/turborepo#8090 <!-- DevMirza - fix(ci):
Trying to fix `benchmark-turbopack` workflow -->
* vercel/turborepo#8837 <!-- Niklas Mischkulnig -
Make JS Lints have lower severity -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants