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

Tree Shaking shared state and side effects #8370

Merged
merged 23 commits into from
Jun 10, 2024
Merged

Conversation

sokra
Copy link
Member

@sokra sokra commented Jun 7, 2024

Description

adds more test cases

Testing Instructions

Copy link

vercel bot commented Jun 7, 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 Jun 10, 2024 0:44am
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 10, 2024 0:44am
8 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Jun 10, 2024 0:44am
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Jun 10, 2024 0:44am
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Jun 10, 2024 0:44am
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Jun 10, 2024 0:44am
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Jun 10, 2024 0:44am
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Jun 10, 2024 0:44am
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Jun 10, 2024 0:44am
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Jun 10, 2024 0:44am

Comment on lines 15 to 24
## Item 2: Stmt 1, `VarDeclarator(0)`

```js
const value = externalFunction();

```

- Declares: `value`
- Reads: `externalFunction`
- Write: `value`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be flagged as side effect as it calls an external function.

Comment on lines 26 to 35
## Item 3: Stmt 2, `VarDeclarator(0)`

```js
const value2 = externalObject.propertyWithGetter;

```

- Declares: `value2`
- Reads: `externalObject`
- Write: `value2`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be flagged as side effect as it accesses a property on an object which might have an getter.


```

- Side effects
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct

Copy link
Contributor

github-actions bot commented Jun 7, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Comment on lines 47 to 56
## Item 5: Stmt 4, `VarDeclarator(0)`

```js
const value3 = externalFunction();

```

- Declares: `value3`
- Reads: `externalFunction`
- Write: `value3`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be flagged as side effect as the function call was annotated with PURE.

Copy link
Contributor

github-actions bot commented Jun 7, 2024

✅ This change can build next-swc

Copy link
Contributor

github-actions bot commented Jun 7, 2024

⚠️ CI failed ⚠️

The following steps have failed in CI:

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

See workflow summary for details

@kdy1 kdy1 self-assigned this Jun 10, 2024
@@ -217,14 +217,17 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests
"[project]/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js [test] (ecmascript) <module evaluation>": (({ r: __turbopack_require__, f: __turbopack_module_context__, i: __turbopack_import__, s: __turbopack_esm__, v: __turbopack_export_value__, n: __turbopack_export_namespace__, c: __turbopack_cache__, M: __turbopack_modules__, l: __turbopack_load__, j: __turbopack_dynamic__, P: __turbopack_resolve_absolute_path__, U: __turbopack_relative_url__, R: __turbopack_resolve_module_id_path__, g: global, __dirname }) => (() => {
"use strict";

__turbopack_esm__({});
__turbopack_esm__({
"lib": ()=>__TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$basic$2d$tree$2d$shake$2f$import$2d$namespace$2f$input$2f$lib$2e$js__$5b$test$5d$__$28$ecmascript$29$__$3c$facade$3e$__
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does seem unneeded, but can be follow up fix

@sokra sokra marked this pull request as ready for review June 10, 2024 13:28
@sokra sokra requested a review from a team as a code owner June 10, 2024 13:28
@sokra
Copy link
Member Author

sokra commented Jun 10, 2024

Approved

@sokra sokra merged commit 4061e06 into main Jun 10, 2024
56 of 58 checks passed
@sokra sokra deleted the sokra/tree-shaking-shared branch June 10, 2024 13:28
ForsakenHarmony added a commit to vercel/next.js that referenced this pull request Jun 10, 2024
### What?
This is a fix for a bundle potentially referring to two different
external modules (e.g. `react` because it gets invalided from the
require cache)

See vercel/turborepo#7988

### Turbopack Updates
* vercel/turborepo#8376 <!-- Tim Neutkens - Rename
ChunkLoading::None to ChunkLoading::Edge -->
* vercel/turborepo#8371 <!-- Donny/강동윤 - test: Add
an execution test for `paren_remover` -->
* vercel/turborepo#8370 <!-- Tobias Koppers - Tree
Shaking shared state and side effects -->
* vercel/turborepo#7988 <!-- hrmny -
feat(turbopack-ecmascript): cache external modules with wrapper -->

Closes PACK-2622
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
### Description

adds more test cases

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->

---------

Co-authored-by: 강동윤 (Donny) <[email protected]>
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
### Description

adds more test cases

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->

---------

Co-authored-by: 강동윤 (Donny) <[email protected]>
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
### Description

adds more test cases

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->

---------

Co-authored-by: 강동윤 (Donny) <[email protected]>
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
### Description

adds more test cases

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->

---------

Co-authored-by: 강동윤 (Donny) <[email protected]>
ForsakenHarmony added a commit to vercel/next.js that referenced this pull request Aug 16, 2024
This is a fix for a bundle potentially referring to two different
external modules (e.g. `react` because it gets invalided from the
require cache)

See vercel/turborepo#7988

* vercel/turborepo#8376 <!-- Tim Neutkens - Rename
ChunkLoading::None to ChunkLoading::Edge -->
* vercel/turborepo#8371 <!-- Donny/강동윤 - test: Add
an execution test for `paren_remover` -->
* vercel/turborepo#8370 <!-- Tobias Koppers - Tree
Shaking shared state and side effects -->
* vercel/turborepo#7988 <!-- hrmny -
feat(turbopack-ecmascript): cache external modules with wrapper -->

Closes PACK-2622
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