fix(turbopack): respect arrow function targets - #97484
Conversation
Failing test suitesCommit: d803640 | About building and testing Next.js
Expand output● Image Component Tests › SSR Image Component Tests › should render an image tag ● Image Component Tests › SSR Image Component Tests › should support passing through arbitrary attributes ● Image Component Tests › SSR Image Component Tests › should modify src with the loader ● Image Component Tests › SSR Image Component Tests › should correctly generate src even if preceding slash is included in prop ● Image Component Tests › SSR Image Component Tests › should add a srcset based on the loader ● Image Component Tests › SSR Image Component Tests › should add a srcset even with preceding slash in prop ● Image Component Tests › SSR Image Component Tests › should use imageSizes when width matches, not deviceSizes from next.config.js ● Image Component Tests › SSR Image Component Tests › should support the unoptimized attribute ● Image Component Tests › SSR Image Component Tests › should not add a srcset if unoptimized attribute present ● Image Component Tests › SSR Image Component Tests › should keep auto parameter if already set ● Image Component Tests › SSR Image Component Tests › should keep width parameter if already set ● Image Component Tests › SSR Image Component Tests › should keep fit parameter if already set ● Image Component Tests › SSR Image Component Tests › should add a preload tag for a priority image ● Image Component Tests › SSR Image Component Tests › should add a preload tag for a priority image with preceding slash ● Image Component Tests › SSR Image Component Tests › should add a preload tag for a priority image, with arbitrary host ● Image Component Tests › SSR Image Component Tests › should add a preload tag for a priority image, with quality ● Image Component Tests › SSR Image Component Tests › should not create any preload tags higher up the page than CSS preload tags ● Image Component Tests › SSR Image Component Tests › should add data-nimg data attribute based on layout ... truncated ...
Expand output● Custom Resolver Tests › SSR Custom Loader Tests › Should use a custom resolver for image URL ● Custom Resolver Tests › SSR Custom Loader Tests › should add a srcset based on the custom resolver ● Custom Resolver Tests › SSR Custom Loader Tests › should support the unoptimized attribute ● Custom Resolver Tests › Client-side Custom Loader Tests › Should use a custom resolver for image URL ● Custom Resolver Tests › Client-side Custom Loader Tests › should add a srcset based on the custom resolver ● Custom Resolver Tests › Client-side Custom Loader Tests › should support the unoptimized attribute
Expand output● Image Component Tests › SSR Image Component Tests › should render an image tag ● Image Component Tests › SSR Image Component Tests › should support passing through arbitrary attributes ● Image Component Tests › SSR Image Component Tests › should modify src with the loader ● Image Component Tests › SSR Image Component Tests › should correctly generate src even if preceding slash is included in prop ● Image Component Tests › SSR Image Component Tests › should add a srcset based on the loader ● Image Component Tests › SSR Image Component Tests › should add a srcset even with preceding slash in prop ● Image Component Tests › SSR Image Component Tests › should use imageSizes when width matches, not deviceSizes from next.config.js ● Image Component Tests › SSR Image Component Tests › should support the unoptimized attribute ● Image Component Tests › SSR Image Component Tests › should not add a srcset if unoptimized attribute present ● Image Component Tests › SSR Image Component Tests › should keep auto parameter if already set ● Image Component Tests › SSR Image Component Tests › should keep width parameter if already set ● Image Component Tests › SSR Image Component Tests › should keep fit parameter if already set ● Image Component Tests › SSR Image Component Tests › should add a preload tag for a priority image ● Image Component Tests › SSR Image Component Tests › should add a preload tag for a priority image with preceding slash ● Image Component Tests › SSR Image Component Tests › should add a preload tag for a priority image, with arbitrary host ● Image Component Tests › SSR Image Component Tests › should add a preload tag for a priority image, ... truncated to fit in one GitHub comment ... |
Stats from current PR🟢 2 improvements
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
Build Cache
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URLCommit: d803640 |
| import { execSync } from 'child_process' | ||
| import { readFileSync, readdirSync } from 'fs' | ||
| import { join } from 'path' | ||
| import { parse } from 'acorn' |
There was a problem hiding this comment.
This fails with
next:typescript:
//:typescript: test/production/escheck-output/index.test.ts(5,23): error TS2307: Cannot find module 'acorn' or its corresponding type declarations.
//:typescript: ELIFECYCLE Command failed with exit code 2.
next:typescript: ELIFECYCLE Command failed.
And doesn't escheck already cover this?
There was a problem hiding this comment.
sorry i miss this, updated and fixed.
What?
Why?
Turbopack already uses the target's arrow-function support for outer chunk factories, but some generated loaders still hardcoded arrow functions. SWC compression could also turn compatible functions and object methods back into arrow functions even when the output target did not support them.
As a result, production output could contain
ArrowFunctionExpressionnodes that were incompatible with the configured Browserslist target.How?
supports_arrow_functionsfrom the chunking environment when generating loaders and selecting minifier options.CompressOptions.arrowsfrom the same runtime capability.Tests
pnpm build-allcargo test -p turbopack-ecmascript respects_arrow_function_supportcargo clippy --all-targets -- -D warnings --no-depstest/production/escheck-output(4/4 passing)Related to #83799