Skip to content

Commit ffbec46

Browse files
committed
Build published packages with tsdown
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.
1 parent 3af17c5 commit ffbec46

15 files changed

Lines changed: 46 additions & 14 deletions

File tree

‎packages/mui-envinfo/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"homepage": "https://github.com/mui/material-ui/tree/HEAD/packages/mui-envinfo",
1717
"files": [],
1818
"scripts": {
19-
"build": "code-infra build --flat --bundle cjs --buildTypes false --skipBabelRuntimeCheck"
19+
"build": "code-infra build-new --bundle cjs --buildTypes false"
2020
},
2121
"dependencies": {
2222
"envinfo": "^7.21.0"

‎packages/mui-icons-material/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"author": "MUI Team",
55
"description": "Material Design icons distributed as SVG React components.",
66
"license": "MIT",
7-
"main": "./src/index.js",
87
"keywords": [
98
"react",
109
"react-component",
@@ -29,7 +28,7 @@
2928
"scripts": {
3029
"build": "rimraf build && shx cp -r lib/ build/ && pnpm build:copy-files && pnpm build:typings && pnpm build:pkg-json",
3130
"build:pkg-json": "node ./scripts/merge-package-json.mjs",
32-
"build:lib": "code-infra build --flat --hasLargeFiles --skipMainCheck --buildTypes false --no-expand",
31+
"build:lib": "code-infra build-new --buildTypes false --no-expand && node ./scripts/strip-icon-banners.mjs",
3332
"build:lib:clean": "rimraf lib && pnpm build:lib && shx cp -R build lib && rimraf build",
3433
"build:copy-files": "shx cp README.md ../../CHANGELOG.md ../../LICENSE build",
3534
"build:typings": "node ./scripts/create-typings.mjs",
@@ -77,6 +76,7 @@
7776
".": "./src/index.js",
7877
"./*": "./src/*.js",
7978
"./index*": null,
79+
"./utils/createSvgIcon": "./src/utils/createSvgIcon.js",
8080
"./utils/*": null
8181
}
8282
}

‎packages/mui-icons-material/scripts/merge-package-json.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const packageDir = path.resolve(currentDirectory, '..');
1313
// and https://github.com/microsoft/TypeScript/issues/60854.
1414
const wildcardExports = {
1515
'./package.json': './package.json',
16+
'./_virtual/*': null,
1617
'.': {
1718
require: './index.js',
1819
import: './index.mjs',
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-disable no-console */
2+
import path from 'path';
3+
import * as fs from 'fs/promises';
4+
import glob from 'fast-glob';
5+
import url from 'url';
6+
7+
const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));
8+
const BUILD_DIR = path.resolve(currentDirectory, '../build');
9+
const BANNER_END = ' */\n';
10+
11+
// `code-infra build-new` adds the license header to every file. With ~21k icon files it adds
12+
// ~4 MB to the package, so only the index files keep it, as with `code-infra build`.
13+
async function run() {
14+
const files = await glob(['**/*.{js,mjs}', '!index.{js,mjs}'], { cwd: BUILD_DIR });
15+
await Promise.all(
16+
files.map(async (file) => {
17+
const filePath = path.join(BUILD_DIR, file);
18+
const code = await fs.readFile(filePath, 'utf8');
19+
if (!code.startsWith('/**\n * @mui/icons-material v')) {
20+
return;
21+
}
22+
await fs.writeFile(filePath, code.slice(code.indexOf(BANNER_END) + BANNER_END.length));
23+
}),
24+
);
25+
console.log(`Removed the license header from ${files.length} files.`);
26+
}
27+
28+
run().catch((error) => {
29+
console.error(error);
30+
process.exit(1);
31+
});

‎packages/mui-lab/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"url": "https://opencollective.com/mui-org"
2828
},
2929
"scripts": {
30-
"build": "code-infra build --tsgo --flat",
30+
"build": "code-infra build-new",
3131
"release": "pnpm build && pnpm publish",
3232
"test": "pnpm --workspace-root test:unit --project \"*:@mui/lab\"",
3333
"typescript": "tsc -p tsconfig.json"

‎packages/mui-material-nextjs/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"url": "https://opencollective.com/mui-org"
2424
},
2525
"scripts": {
26-
"build": "code-infra build --tsgo --flat",
26+
"build": "code-infra build-new --cjsCopy",
2727
"release": "pnpm build && pnpm publish",
2828
"test": "pnpm --workspace-root test:unit --project \"*:@mui/material-nextjs\"",
2929
"typescript": "tsc -p tsconfig.json",

‎packages/mui-material-pigment-css/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"url": "https://opencollective.com/mui-org"
2626
},
2727
"scripts": {
28-
"build": "code-infra build --tsgo --flat --copy \"src/styles.css\"",
28+
"build": "code-infra build-new --copy \"src/styles.css\"",
2929
"release": "pnpm build && pnpm publish",
3030
"test": "pnpm --workspace-root test:unit --project \"*:@mui/material-pigment-css\"",
3131
"typescript": "tsc -p tsconfig.json"

‎packages/mui-material/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"scripts": {
2828
"prebuild": "node ./scripts/stagePublishedDocs.mjs",
29-
"build": "code-infra build --tsgo --flat --copy \"published-docs/**:docs\"",
29+
"build": "code-infra build-new --copy \"published-docs/**:docs\"",
3030
"release": "pnpm build && pnpm publish",
3131
"test": "pnpm --workspace-root test:unit --project \"*:@mui/material\"",
3232
"typescript": "tsc -p tsconfig.json",

‎packages/mui-private-theming/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"url": "https://opencollective.com/mui-org"
2525
},
2626
"scripts": {
27-
"build": "code-infra build --tsgo --flat",
27+
"build": "code-infra build-new",
2828
"release": "pnpm build && pnpm publish",
2929
"test": "pnpm --workspace-root test:unit --project \"*:@mui/private-theming\"",
3030
"typescript": "tsc -p tsconfig.json"

‎packages/mui-styled-engine-sc/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"url": "https://opencollective.com/mui-org"
2525
},
2626
"scripts": {
27-
"build": "code-infra build --tsgo --flat",
27+
"build": "code-infra build-new",
2828
"release": "pnpm build && pnpm publish",
2929
"test": "pnpm --workspace-root test:unit --project \"*:@mui/styled-engine-sc\"",
3030
"typescript": "tsc -p tsconfig.json"

0 commit comments

Comments
 (0)