Repository navigation
[code-infra] Build packages with tsdown - #49802
Conversation
Deploy previewBundle size
PerformanceNo regressions in 32 benchmarks · precise to ±9.1% (±14.8% at worst) · ran 4m 57s · details Check out the code infra dashboard for more information about this PR. |
cdbef70 to
e9d37ed
Compare
e9d37ed to
0a0b2e7
Compare
d21c6c3 to
a0efde0
Compare
|
known diff in declarations: bare side-effect imports like |
| @@ -0,0 +1,31 @@ | |||
| /* eslint-disable no-console */ | |||
There was a problem hiding this comment.
This is optional to strip banners from each file to reduce the package size due to the huge number of redundant files in the package.
a474d49 to
9a037ef
Compare
5f2ebf2 to
7a0dfa1
Compare
7a0dfa1 to
6bab48e
Compare
0ff6237 to
ab10d77
Compare
Switch @mui/internal-api-docs-builder, @mui/internal-core-docs and @mui/internal-docs-utils from `code-infra build` to `code-infra build-new`. core-docs needs two source changes for its declarations: - `standardNavIcons` gets an explicit type. Its inferred declaration pointed at `packages/mui-material/src`, a path that doesn't exist in the published package and that build-new refuses to bundle. - `VersionsContext` moves from JavaScript to TypeScript. build-new writes declarations for TypeScript sources only, so the context was re-exported without a declaration. `tsBuildInfoFile` pointed into `build/`, so build-new published the build info file. Without it the file stays out of the package, as in api-docs-builder.
Switch the published packages from `code-infra build` to `code-infra build-new`, which compiles with tsdown. Material UI is in alpha, so build regressions surface before the stable release. build-new writes tsgo declarations and the flat layout itself, so `--tsgo`, `--flat` and `--skipBabelRuntimeCheck` go away. mui-icons-material builds its committed `lib/` with build-new too. build-new has no `--skipMainCheck`, so the unused source `main` field goes; the published package.json still gets `main` from merge-package-json. build-new adds the license header to every file, which would add ~4 MB to the package, so a script keeps it only in the index files, as before. `lib/` is regenerated with the next icons update. mui-codemod stays on `code-infra build`: it loads transforms by file path at runtime, which an entry-based bundle doesn't emit.
The file has no export list, so TypeScript exports these declarations
implicitly. tsdown's declaration bundling appends `export {}`, which
turns that off; explicit exports keep the same public types.
Picks up the latest canary now that mui/mui-public#2096 is merged.
ab10d77 to
4e3dde4
Compare
There was a problem hiding this comment.
Compared the pkg.pr.new builds against the merge base. Exports, runtime loading and types (all 4,714 exports assignable both ways) match. Three issues:
- Imports of
styled/useThemeno longer go throughzero-styled(118 + 16 in@mui/material), which Pigment's tag resolver relies on, so Pigment integration likely breaks. (how much do we care?) nextFonts/index.jsin core-docs inlines alocalFont()call into an array; Next.js requires font loaders assigned to a const.minify: falsein build-new avoids it.- CJS output lost
"use strict";strict: truefor the cjs format restores it.
0.1.1-canary.41 includes mui/mui-public#2127: build-new output stays unminified, so Next.js font loaders stay assigned to a const, and CJS files start with "use strict" again. Export styled and useTheme from zero-styled as local bindings so the bundler keeps importers pointed at zero-styled, which Pigment CSS's tag resolver matches on.
code-infra 0.1.1-canary.41 resolves the hoisted @babel/preset-env against @babel/core 8.1.3, while @mui/codemod still got 8.1.2. jscodeshift's worker loads preset-env before installing its require hook, which preloaded the codemod's @babel/core only while both used the same version. With two versions, the hook compiled the ESM @babel/core 8.1.2 and the codemod CLI test failed.
Builds all packages except
@mui/codemodwithcode-infra build-new(tsdown), from@mui/internal-code-infra@0.1.1-canary.41.All packages are in alpha, so migrating now leaves time to find and fix any gaps in the new build before the stable release.
@mui/codemodstays oncode-infra build: it loads transforms by file path at runtime, and build-new only emits files reachable from entries.Changes
zero-styled:styledanduseThemeare exported as local bindings. Otherwise the bundler points importers at../styles/*, and Pigment CSS, which only transforms imports from azero-styledpath, skips the component styles.PopoverVirtualElement,PopoverRootPropsandPopoverPaperPropsare exported explicitly. tsdown appendsexport {}toPopover.d.ts, which turns off implicit exports."./_virtual/*": nullis added to the exports map. A script keeps the license banner only in index files (~4 MB smaller).@mui/internal-core-docs:standardNavIconshas an explicit type.VersionsContextis converted to TypeScript.Verification
code-infra buildofmaster, and@mui/materialemits 186 fewer files.pnpm release:build,pnpm docs:buildandpnpm typescript(@mui/material) pass.@mui/material@next.Known gaps
Some exported types are declared under a suffixed name (
export { Theme$1 as Theme }), so error messages showTheme$1. Tracked in Renamed import collapses to its original name and is shadowed by a same-named namespace member sxzz/rolldown-plugin-dts#339.Unrelated to this PR: both Pigment examples already fail on
master, becausecssis used inside a function inTouchRipple,Skeleton,LinearProgressandCircularProgress([transitions] Supportprefers-reduced-motion#48357).I have followed (at least) the PR section of the contributing guide.
Part of mui/mui-public#413