Scripts and configs to be used across MUI repos.
This is stored in the docs top-level directory.
- Go to the publish action -
-
Choose "Run workflow" dropdown
- Branch: master
- Commit SHA to release from: the commit that contains the merged release on master. This commit is linked to the GitHub release.
- Run in dry-run mode: Used for debugging.
- Create GitHub release: Keep selected if you want a GitHub release to be automatically created from the changelog.
- npm dist tag to publish to Use to publish legacy or canary versions. The publish fails before it publishes anything when a dist-tag would move to a lower version.
latestandlatest-*also cannot move to a prerelease unless they already point to one, andlatest-*cannot change its major.
-
Click "Run workflow"
-
Refresh the page to see the newly created workflow, and click it.
-
The next screen shows "@username requested your review to deploy to npm-publish", click "Review deployments" and authorize your workflow run. Never approve workflow runs you didn't initiaite.
Note
A CI dry run (code-infra publish --ci --dry-run) runs the same dist-tag check. On a branch that does not publish to latest, pass the dist-tag of the release to it, for example --tag next for prereleases or --tag latest-v8 for a previous major.
Important
Go through the below steps if there is an error that says The following packages are new and need to be published manually first in the publish flow.
Whenever new packages are added to the repo (that will get published to npm) or a private package is turned into a public one, follow the below steps before invoking the publish workflow of the previous section.
Note
This applies to packages published to npm, which is where Trusted Publishing needs the package to already exist. Packages that set publishConfig.registry to another registry are skipped by this check and need none of these steps.
- Go to your repo's code base on your system, then log in to npm using
npm login- Once logged-in, open terminal and run:
pnpm code-infra publish-new-packageThis command detects the new public packages in the repo and asks for your confirmation before publishing them to the npm registry. Add the --dryRun flag to skip the actual publishing.
If publishing fails with npm asking for otp, run the command again with 6 digit auth code from your authenticator app where you've added npm; Google Authenticator, Authy or similar:
pnpm code-infra publish-new-package --otp=123456- Go to the settings link for each package, for example,
https://www.npmjs.com/package/<pkg-name>/access, and setupTrusted Publisher. - In the
Select your publisherstep in the above link, click on theGitHub Actionsbutton to configure GitHub Actions-based trusted publishing. - Fill in the details of the repo -
Organization or userasmui,Repositoryas per the new packageWorkflow filename*should bepublish.ymlEnvironment nameshould benpm-publishornpm-publish-internalbased on whether the package is user facing package or internal package respectively.
- In the
Publishing accesssection, toggle the recommended option ofRequire two-factor authentication and disallow tokens. - Finally, save the changes by clicking on
Update Package Settingsbutton.
After following these steps, the Publish workflow can be invoked again.
The agent skills previously shipped with this package now live at the repository root. See Install instructions.
code-infra build-new is experimental. It compiles the src modules behind the package's
exports, imports and bin, plus every module they import, to the publishConfig.directory with
tsdown, keeping every package import external. Modules loaded with
new URL('./file', import.meta.url), such as workers, are built too, and the URL points at their
output. It copies files with tsdown's copy option using the same --copy rules as
code-infra build. It writes the same package.json as code-infra build (the deprecated
--no-expand keeps exports/imports patterns). Every JavaScript file starts with the package's
license header. Oxc strips types, compiles JSX and lowers syntax for the stable (ESM) and node
(CJS) browserslist environments, and MUI_VERSION variables are inlined. Babel runs the workspace
babel.config.js with getBaseConfig reduced to the MUI plugins Oxc lacks: display names, React
pure annotations, prop-types removal and clsx optimization, plus the React compiler with
--enableReactCompiler. Babel helpers, and the helpers Oxc's lowering needs, are imported from the
@babel/runtime version the package depends on; the build fails when the output imports them
without that dependency. Declarations come from tsdown's dts with the workspace TypeScript 7 tsc
and the package's tsconfig.build.json (--no-buildTypes skips them); hand-written .d.ts files
need explicit exports. The output keeps export * as and import * as namespaces, which Rolldown
turns into <name>_exports objects in unbundled builds. A namespace stays an object when Rolldown
inlines its constants into it, when the module reads it itself, or, in JavaScript, when it is
imported next to a default import or by a quoted name. The output is validated with publint, as in
code-infra build. The output isn't minified, and CJS files start with "use strict". With
--cjsCopy, imported .cjs sources are emitted unchanged and imported as-is, as in
code-infra build, and the local modules they require are built at the paths they name; the build
fails when no bundle outputs a module at that path. --cjsCopy is deprecated: only
@mui/material-nextjs needs it, until next has an exports map
(vercel/next.js#77200). Continue using
code-infra build for package builds.