-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
feat(turbopack): Add reexports optimization #70336
base: canary
Are you sure you want to change the base?
Conversation
Failing test suitesCommit: 0001b0e
Expand output● app-dynamic-error › production mode › throws an error when prerendering a page with config dynamic error
Read more about building and testing Next.js in contributing.md.
Expand output● AMP Fragment Styles › production mode › adds styles from fragment in AMP mode correctly
Read more about building and testing Next.js in contributing.md.
Expand output● Auto Export _error bail › production mode › should not opt-out of auto static optimization from invalid _error
Read more about building and testing Next.js in contributing.md.
Expand output● app dir - dynamic css › should preload all chunks of dynamic component during SSR
● app dir - dynamic css › should only apply corresponding css for page loaded that /ssr
● app dir - dynamic css › should only apply corresponding css for page loaded in edge runtime
● app dir - dynamic css › should only apply corresponding css for page loaded that /another
● app dir - dynamic css › should not throw with accessing to ALS in preload css
Read more about building and testing Next.js in contributing.md.
Expand output● CSS optimization for SSR apps › production mode › should have all CSS files in manifest
● CSS optimization for SSR apps › production mode › should inline critical CSS
● CSS optimization for SSR apps › production mode › should inline critical CSS (dynamic)
● CSS optimization for SSR apps › production mode › should not inline non-critical css
Read more about building and testing Next.js in contributing.md.
Expand output● app dir - basepath › should successfully hard navigate from pages -> app
● app dir - basepath › should support
● app dir - basepath › should support Link with basePath prefixed
● app dir - basepath › should prefix metadata og image with basePath
● app dir - basepath › should prefix redirect() with basePath
● app dir - basepath › should render usePathname without the basePath
● app dir - basepath › should handle redirect in dynamic in suspense boundary routes with basePath
● app dir - basepath › should only make a single RSC call to the current page (/base/refresh)
● app dir - basepath › should only make a single RSC call to the current page (/base/refresh?foo=bar)
● app dir - basepath › should properly stream an internal server action redirect() with a relative URL
● app dir - basepath › should properly stream an internal server action redirect() with a absolute URL
● app dir - basepath › should redirect externally when encountering absolute URLs on the same host outside the basePath
Read more about building and testing Next.js in contributing.md.
Expand output● app dir client cache semantics (default semantics) › prefetch={true} › should prefetch the full page
● app dir client cache semantics (default semantics) › prefetch={true} › should re-use the cache for the full page, only for 5 mins
● app dir client cache semantics (default semantics) › prefetch={true} › should prefetch again after 5 mins if the link is visible again
● app dir client cache semantics (default semantics) › prefetch={false} › should not prefetch the page at all
● app dir client cache semantics (default semantics) › prefetch={false} › should not re-use the page segment cache
● app dir client cache semantics (default semantics) › prefetch={undefined} - default › should prefetch partially a dynamic page
● app dir client cache semantics (default semantics) › prefetch={undefined} - default › should not re-use the page segment cache
● app dir client cache semantics (default semantics) › prefetch={undefined} - default › should refetch the full page after 5 mins
● app dir client cache semantics (default semantics) › prefetch={undefined} - default › should respect a loading boundary that returns
● app dir client cache semantics (default semantics) › should renew the initial seeded data after expiration time
Read more about building and testing Next.js in contributing.md.
Expand output● 404 Page Support SSG › production mode › should build successfully
● 404 Page Support SSG › production mode › should respond to 404 correctly
● 404 Page Support SSG › production mode › should render error correctly
● 404 Page Support SSG › production mode › should not show an error in the logs for 404 SSG
● 404 Page Support SSG › production mode › should render index page normal
● 404 Page Support SSG › production mode › should not revalidate custom 404 page
● 404 Page Support SSG › production mode › should set pages404 in routes-manifest correctly
● 404 Page Support SSG › production mode › should have 404 page in prerender-manifest
Read more about building and testing Next.js in contributing.md.
Expand output● app-dir edge SSR › should handle edge only routes
● app-dir edge SSR › should retrieve cookies in a server component in the edge runtime
● app-dir edge SSR › should treat process as object without polyfill in edge runtime
● app-dir edge SSR › should handle /index routes correctly
● app-dir edge SSR › should generate matchers correctly in middleware manifest
Read more about building and testing Next.js in contributing.md.
Expand output● app-prefetch-false-loading › should render loading for the initial render
● app-prefetch-false-loading › should not re-trigger loading state when navigating between pages that share a dynamic layout
Read more about building and testing Next.js in contributing.md.
Expand output● app dir - external dependency › should support exporting multiple star re-exports |
What?
Create
ModulePart::StarReexports
and use it to optimizeexport *
-spackage-star/index.js
:package-reexport/index.js
:import { a } from 'package-reexport'
currently createsModulePart::Export("a")
forpackage-reexport
andModulePart::Exports
forpackage-star
.To make side effect optimization work, we need to create
ModulePart::Export("a")
forexport * from "package-star"
. There are two solutions.The first one is making
ImportMap
andEvalContext
parameterized by the requested export symbol name. Obviously, this breaks caching.Special casing star reexports while analyzing imports, and reuse the requested
part
if it's an export while determiningModulePart
for a dependency (import reference) inreferences/mod.rs
.The first one is not an option, so I did the second way. But now the problem is where it's used by
ModulePart::Internal
. We need a way to disable resolution when a package is side-effect-free and we don't use export. Currently, we check for side-effect-free modules inturbopack::apply_module_type
, but it's not even called for non-existent files. It's becauseorigin.resolve_asset
inspecific_resolve
returnsModuleResolveResult::unresolvable
.The unresolvable error is emitted without control from
turbopack-ecmascript
.Why?
To improve tree shaking
How?