Skip to content

Latest commit

 

History

History
108 lines (80 loc) · 6.38 KB

README.md

File metadata and controls

108 lines (80 loc) · 6.38 KB

@mui/internal-code-infra

Scripts and configs to be used across MUI repos.

Documentation

This is stored in the docs top-level directory.

Read in Markdown

Read in Browser

Publishing packages

  1. Go to the publish action -
  1. 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. latest and latest-* also cannot move to a prerelease unless they already point to one, and latest-* cannot change its major.
  2. Click "Run workflow"

  3. Refresh the page to see the newly created workflow, and click it.

  4. 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.

Adding and publishing new packages

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.

  1. Go to your repo's code base on your system, then log in to npm using
npm login
  1. Once logged-in, open terminal and run:
pnpm code-infra publish-new-package

This 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
  1. Go to the settings link for each package, for example, https://www.npmjs.com/package/<pkg-name>/access, and setup Trusted Publisher.
  2. In the Select your publisher step in the above link, click on the GitHub Actions button to configure GitHub Actions-based trusted publishing.
  3. Fill in the details of the repo -
    1. Organization or user as mui,
    2. Repository as per the new package
    3. Workflow filename* should be publish.yml
    4. Environment name should be npm-publish or npm-publish-internal based on whether the package is user facing package or internal package respectively.
  4. In the Publishing access section, toggle the recommended option of Require two-factor authentication and disallow tokens.
  5. Finally, save the changes by clicking on Update Package Settings button.

After following these steps, the Publish workflow can be invoked again.

Agent skills

The agent skills previously shipped with this package now live at the repository root. See Install instructions.

Upcoming tsdown builds

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.