[pull] canary from vercel:canary#1102
Merged
Merged
Conversation
Fixed `search from` → `search for` and `at the of the page` → `at the top of the page` (confirmed by checking API ref pages — overview tables go at the top after a short intro and example).
This is a follow-up to this comment: https://github.com/vercel/next.js/blob/89562628d27b672352d212ecd8c6941873e83222/turbopack/crates/turbopack-ecmascript/src/analyzer/side_effects.rs#L22 I wouldn't consider it a comprehensive tracker of local variables. However, it's a start. Only `const`s are tracked at the moment. This is because with `let`s you can do things like: ```javascript let x = { a: "b" }; x = globalThis; x.a = "b" // side effect! ``` I do think this is a helpful improvement, though as it handles the common pattern that was mentioned in the comment.
This PR is looking to reduce the size of the runtime we're shipping. The goal is to not include worker helpers in the default runtime, if workers aren't being used / imported. The `createWorker()` function has been removed from the runtime. It now exists in `turbopack-ecmascript/js/src/worker/browser/createWorker.ts` and `turbopack-ecmascript/js/src/worker/node/createWorker.ts`. The reason behind having them in `turbopack-ecmascript` is that in `turbopack-ecmascript/src/worker_chunk/module.rs` we can then create a worker module (see `create_worker_module()`). This is then returned by `references()` as a `SingleChunkableModuleReference`. Instead of using `createWorker()` from the runtime we can instead now import it from that module. There are a couple of things in this PR that I'd like to flag for discussion: 1) The location of the JavaScript. Shipping it in `turbopack-ecmascript` doesn't quite feel natural; however, `turbopack-ecmascript-runtime` imports `turbopack-ecmascript` so I didn't want to create a circular dependency by importing `turbopack-ecmascript-runtime` in `turbopack-ecmascript`. 2) There a couple of things in the runtime that we need inside of `createWorker()`, they are: ```javascript TURBOPACK_ASSET_SUFFIX, TURBOPACK_CHUNK_BASE_PATH ``` which are values from the runtime we needed to references and: ```javascript function getChunkRelativeUrl( chunkPath: ChunkPath | ChunkListPath, basePath: string = CHUNK_BASE_PATH ): ChunkUrl ``` which is `TURBOPACK_CHUNK_RELATIVE_URL`. These currently exist in the runtime. To make them available, I've placed them in `browserContextPrototype` and `contextPrototype` in the node version. We also have a code gen that inserts the values of `_TURBOPACK_WORKER_FORWARDED_GLOBALS_` and `_TURBOPACK_WORKER_BASE_PATH_` during the analyzer's pass through free variables (takes them out of the chunking context). @lukesandberg curious to hear your thoughts about these! --------- Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )