@mui/internal-code-infra 0.0.4-canary.98 → 0.1.1-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +4 -0
  2. package/build/babel-config.d.mts +4 -4
  3. package/build/babelPluginInlineEnvironmentVariables.d.mts +11 -0
  4. package/build/brokenLinksChecker/index.d.mts +147 -0
  5. package/build/changelog/fetchChangelogs.d.mts +3 -0
  6. package/build/cli/cmdArgosPush.d.mts +6 -0
  7. package/build/cli/cmdBuild.d.mts +45 -0
  8. package/build/cli/cmdCopyFiles.d.mts +12 -0
  9. package/build/cli/cmdGenerateChangelog.d.mts +15 -0
  10. package/build/cli/cmdListWorkspaces.d.mts +14 -2
  11. package/build/cli/cmdNetlifyIgnore.d.mts +9 -0
  12. package/build/cli/cmdPublish.d.mts +20 -2
  13. package/build/cli/cmdPublishCanary.d.mts +18 -0
  14. package/build/cli/cmdPublishNewPackage.d.mts +6 -0
  15. package/build/cli/cmdRenameScope.d.mts +18 -0
  16. package/build/cli/cmdSetVersionOverrides.d.mts +3 -0
  17. package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +6 -0
  18. package/build/eslint/testConfig.d.mts +1 -7
  19. package/build/utils/babel.d.mts +6 -0
  20. package/build/utils/build.d.mts +3 -15
  21. package/build/utils/extractErrorCodes.d.mts +16 -0
  22. package/build/utils/git.d.mts +9 -0
  23. package/build/utils/github.d.mts +12 -0
  24. package/build/utils/pnpm.d.mts +147 -9
  25. package/build/utils/testUtils.d.mts +21 -0
  26. package/build/utils/typescript.d.mts +2 -2
  27. package/package.json +54 -56
  28. package/src/babel-config.mjs +21 -11
  29. package/src/babelPluginInlineEnvironmentVariables.mjs +45 -0
  30. package/src/brokenLinksChecker/index.mjs +3 -3
  31. package/src/cli/cmdArgosPush.mjs +2 -4
  32. package/src/cli/cmdBuild.mjs +8 -9
  33. package/src/cli/cmdCopyFiles.mjs +3 -3
  34. package/src/cli/cmdListWorkspaces.mjs +3 -31
  35. package/src/cli/cmdPublish.mjs +23 -29
  36. package/src/cli/cmdRenameScope.mjs +77 -0
  37. package/src/cli/cmdSetVersionOverrides.mjs +32 -25
  38. package/src/cli/cmdVale.mjs +3 -6
  39. package/src/cli/cmdValidateBuiltTypes.mjs +3 -4
  40. package/src/cli/index.mjs +2 -0
  41. package/src/eslint/testConfig.mjs +3 -31
  42. package/src/untyped-plugins.d.ts +11 -49
  43. package/src/utils/build.mjs +0 -39
  44. package/src/utils/extractErrorCodes.mjs +12 -7
  45. package/src/utils/pnpm.mjs +380 -16
  46. package/src/utils/testUtils.mjs +35 -0
  47. package/src/utils/typescript.mjs +60 -42
@@ -1,6 +1,15 @@
1
1
  export type RepoInfo = {
2
+ /**
3
+ * - Repository owner
4
+ */
2
5
  owner: string;
6
+ /**
7
+ * - Repository name
8
+ */
3
9
  repo: string;
10
+ /**
11
+ * - Remote name
12
+ */
4
13
  remoteName: string;
5
14
  };
6
15
  /**
@@ -7,9 +7,21 @@
7
7
  *
8
8
  */
9
9
  export type GitHubAppAuthenticationWithRefreshToken = {
10
+ /**
11
+ * - The access token
12
+ */
10
13
  token: string;
14
+ /**
15
+ * - ISO string when the access token expires
16
+ */
11
17
  expiresAt?: string;
18
+ /**
19
+ * - The refresh token
20
+ */
12
21
  refreshToken?: string;
22
+ /**
23
+ * - ISO string when the refresh token expires
24
+ */
13
25
  refreshTokenExpiresAt?: string;
14
26
  };
15
27
  /**
@@ -1,35 +1,98 @@
1
1
  #!/usr/bin/env node
2
2
  export type PrivatePackage = {
3
+ /**
4
+ * - Package name
5
+ */
3
6
  name?: string;
7
+ /**
8
+ * - Package version
9
+ */
4
10
  version?: string;
11
+ /**
12
+ * - Package directory path
13
+ */
5
14
  path: string;
15
+ /**
16
+ * - Whether the package is private
17
+ */
6
18
  isPrivate: true;
7
19
  };
8
20
  export type PublicPackage = {
21
+ /**
22
+ * - Package name
23
+ */
9
24
  name: string;
25
+ /**
26
+ * - Package version
27
+ */
10
28
  version: string;
29
+ /**
30
+ * - Package directory path
31
+ */
11
32
  path: string;
33
+ /**
34
+ * - Whether the package is private
35
+ */
12
36
  isPrivate: false;
13
37
  };
14
38
  export type VersionInfo = {
39
+ /**
40
+ * - Whether current version exists on npm
41
+ */
15
42
  currentVersionExists: boolean;
43
+ /**
44
+ * - Latest canary version if available
45
+ */
16
46
  latestCanaryVersion: string | null;
17
47
  };
18
48
  export type PublishOptions = {
49
+ /**
50
+ * - Whether to run in dry-run mode
51
+ */
19
52
  dryRun?: boolean;
53
+ /**
54
+ * - Whether to skip git checks
55
+ */
20
56
  noGitChecks?: boolean;
57
+ /**
58
+ * - NPM dist tag to publish to
59
+ */
21
60
  tag?: string;
22
61
  };
23
62
  export type PnpmListResultItem = {
63
+ /**
64
+ * - Package name
65
+ */
24
66
  name?: string;
67
+ /**
68
+ * - Package version
69
+ */
25
70
  version?: string;
71
+ /**
72
+ * - Package directory path
73
+ */
26
74
  path: string;
75
+ /**
76
+ * - Whether the package is private
77
+ */
27
78
  private: boolean;
28
79
  };
29
80
  export type GetWorkspacePackagesOptions = {
81
+ /**
82
+ * - Git reference to filter changes since
83
+ */
30
84
  sinceRef?: string | null;
85
+ /**
86
+ * - Whether to filter to only public packages
87
+ */
31
88
  publicOnly?: boolean;
89
+ /**
90
+ * - Current working directory to run pnpm command in
91
+ */
32
92
  cwd?: string;
93
+ /**
94
+ * - Same as filtering packages with --filter in pnpm. Only include packages matching the filter. See https://pnpm.io/filtering.
95
+ */
33
96
  filter?: string[];
34
97
  };
35
98
  export declare function getWorkspacePackages(options?: {
@@ -49,6 +112,16 @@ export declare function getWorkspacePackages(options?: GetWorkspacePackagesOptio
49
112
  * @returns {Promise<string>} Normalized registry URL, ending in a slash
50
113
  */
51
114
  export declare function getPublishRegistry(packagePath: string): Promise<string>;
115
+ /**
116
+ * Get the version to release from the workspace-root package.json.
117
+ *
118
+ * Resolves the workspace root so the version is the monorepo's regardless of
119
+ * which directory publish runs from.
120
+ *
121
+ * @param {string} [cwd] - Directory to resolve the workspace root from
122
+ * @returns {Promise<string | null>} Version string, or null when absent/invalid
123
+ */
124
+ export declare function getReleaseVersion(cwd?: string): Promise<string | null>;
52
125
  /**
53
126
  * Filter to the packages that must be published by hand before CI can take over.
54
127
  *
@@ -90,19 +163,22 @@ export type PublishSummaryEntry = {
90
163
  */
91
164
  export declare function publishPackages(packages: PublicPackage[], options?: PublishOptions): Promise<PublishSummaryEntry[]>;
92
165
  export type GetTransitiveDependenciesOptions = {
166
+ /**
167
+ * - Map of workspace package name to directory path
168
+ */
93
169
  workspacePathByName?: Map<string, string>;
170
+ /**
171
+ * - Whether to include devDependencies in the traversal
172
+ */
94
173
  includeDev?: boolean;
95
174
  };
96
- /**
97
- * @typedef {Object} GetTransitiveDependenciesOptions
98
- * @property {Map<string, string>} [workspacePathByName] - Map of workspace package name to directory path
99
- * @property {boolean} [includeDev=true] - Whether to include devDependencies in the traversal
100
- */
101
175
  /**
102
176
  * Get all transitive workspace dependencies for a set of packages.
103
177
  *
104
178
  * Only follows deps whose version spec starts with `workspace:` (e.g. `workspace:*`
105
- * or `workspace:^`), meaning they are sourced directly from the monorepo. Pinned
179
+ * or `workspace:^`), meaning they are sourced directly from the monorepo. An
180
+ * alias spec (`workspace:@scope/name@range`) is followed to the package it
181
+ * targets, which need not match the dependency key. Pinned
106
182
  * external versions (e.g. `^1.0.0`) are ignored even when the package name exists
107
183
  * in the workspace. Traverses `dependencies` and optionally `devDependencies`.
108
184
  * Results are cached per package so each package is read from disk at most once
@@ -172,18 +248,80 @@ export declare function writePackageJson(packagePath: string, packageJson: Objec
172
248
  */
173
249
  export declare function writeOverridesToWorkspace(workspaceDir: string, overrides: Record<string, string>): Promise<void>;
174
250
  /**
175
- * Resolve a package@version specifier to an exact version
251
+ * Move the publishable workspace packages in one scope to another.
252
+ *
253
+ * Only packages that are part of the workspace are touched, so dependencies
254
+ * that merely share the scope but come from the registry (say `@base-ui/react`
255
+ * alongside a workspace `@base-ui/mosaic`) are left alone. Dependents keep the
256
+ * original dependency name and gain a `workspace:` alias, so imports in the
257
+ * repo resolve exactly as before.
258
+ *
259
+ * @param {(PublicPackage | PrivatePackage)[]} packages - All workspace packages
260
+ * @param {string} fromScope - Scope to move away from
261
+ * @param {string} toScope - Scope to move to
262
+ * @returns {Promise<Map<string, string>>} Old package name to new package name
263
+ */
264
+ export declare function renameWorkspaceScope(packages: (PublicPackage | PrivatePackage)[], fromScope: string, toScope: string): Promise<Map<string, string>>;
265
+ /**
266
+ * Pick the version to pin for a specifier whose newest match is too recent to
267
+ * satisfy a `minimumReleaseAge` cooldown.
268
+ *
269
+ * Only the three specifier shapes this tool is given are handled. An exact
270
+ * version is not a choice, so it stands and the install reports it. A range
271
+ * resolves within itself. A dist-tag repoints to the highest aged-in version
272
+ * sharing the major and prerelease-ness — except `latest`, which pnpm allows to
273
+ * cross majors. Unlike pnpm, a deprecated version is not passed over: `pnpm info`
274
+ * lists bare version strings, so that flag would cost a request per candidate.
275
+ *
276
+ * @param {string} requested - The specifier as given: a dist-tag, range or exact version
277
+ * @param {string} resolvedVersion - Version the specifier resolves to today
278
+ * @param {string[]} versions - Every published version, from `pnpm info <pkg> versions`
279
+ * @param {Record<string, string>} publishTimes - Version to ISO publish date, from `pnpm info <pkg> time`
280
+ * @param {number} cutoff - Epoch ms; versions published after this are too recent
281
+ * @param {string[]} [exemptVersions] - Versions `minimumReleaseAgeExclude` installs regardless of age
282
+ * @returns {string | null} Version to pin, or null when nothing qualifies
283
+ * @internal exported for unit tests
284
+ */
285
+ export declare function selectAgedVersion(requested: string, resolvedVersion: string, versions: string[], publishTimes: Record<string, string>, cutoff: number, exemptVersions?: string[]): string | null;
286
+ /**
287
+ * Read the effective pnpm configuration, including everything resolved from
288
+ * pnpm-workspace.yaml. `config list` types the values and omits unset keys,
289
+ * where `config get` stringifies everything and prints `undefined`.
290
+ *
291
+ * @returns {Promise<Record<string, any>>} Parsed configuration
292
+ */
293
+ export declare function readPnpmConfig(): Promise<Record<string, any>>;
294
+ /**
295
+ * Read the registry cooldown from pnpm config, so resolution stays in step with
296
+ * what the subsequent install will enforce.
297
+ *
298
+ * @returns {Promise<import('@pnpm/config.version-policy').PublishedByPolicy>} Cutoff date and exemption policy, both undefined when no cooldown is configured
299
+ */
300
+ export declare function getMinimumReleaseAgePolicy(): Promise<import('@pnpm/config.version-policy').PublishedByPolicy>;
301
+ /**
302
+ * Resolve a package@version specifier to an exact version.
303
+ *
304
+ * Given a cooldown policy, the result is the newest version the install will
305
+ * actually accept — a dist-tag on a daily channel always points at a build too
306
+ * recent to install under one. See {@link selectAgedVersion}.
307
+ *
176
308
  * @param {string} packageSpec - Package specifier in format "package@version"
309
+ * @param {import('@pnpm/config.version-policy').PublishedByPolicy} policy - Cooldown from {@link getMinimumReleaseAgePolicy}
177
310
  * @returns {Promise<string>} Exact version string
178
311
  */
179
- export declare function resolveVersion(packageSpec: string): Promise<string>;
312
+ export declare function resolveVersion(packageSpec: string, policy: import('@pnpm/config.version-policy').PublishedByPolicy): Promise<string>;
180
313
  /**
181
314
  * Find the version of a dependency for a specific package@version
315
+ *
316
+ * The parent's spec is often a range, so the cooldown applies here too. Stepping
317
+ * back stays within that range and so never contradicts the parent.
318
+ *
182
319
  * @param {string} packageSpec - Package specifier in format "package@version"
183
320
  * @param {string} dependency - Dependency name to look up
321
+ * @param {import('@pnpm/config.version-policy').PublishedByPolicy} policy - Registry cooldown to resolve within
184
322
  * @returns {Promise<string>} Exact version string of the dependency
185
323
  */
186
- export declare function findDependencyVersionFromSpec(packageSpec: string, dependency: string): Promise<string>;
324
+ export declare function findDependencyVersionFromSpec(packageSpec: string, dependency: string, policy: import('@pnpm/config.version-policy').PublishedByPolicy): Promise<string>;
187
325
  /**
188
326
  * Get the maximum semver version between two versions
189
327
  * @param {string} a
@@ -5,3 +5,24 @@
5
5
  * @returns {Promise<string>} The path of the created temporary directory.
6
6
  */
7
7
  export declare function makeTempDir(): Promise<string>;
8
+ /**
9
+ * Write a package.json into a subdirectory of a temp workspace.
10
+ *
11
+ * @param {string} root - Workspace root
12
+ * @param {string} dir - Subdirectory to create
13
+ * @param {object} pkgJson - Manifest contents
14
+ * @returns {Promise<string>} The package directory
15
+ */
16
+ export declare function writePackage(root: string, dir: string, pkgJson: object): Promise<string>;
17
+ /**
18
+ * @param {string} name
19
+ * @param {string} pkgPath
20
+ * @returns {import('./pnpm.mjs').PublicPackage}
21
+ */
22
+ export declare function publicPkg(name: string, pkgPath: string): import('./pnpm.mjs').PublicPackage;
23
+ /**
24
+ * @param {string} name
25
+ * @param {string} pkgPath
26
+ * @returns {import('./pnpm.mjs').PrivatePackage}
27
+ */
28
+ export declare function privatePkg(name: string, pkgPath: string): import('./pnpm.mjs').PrivatePackage;
@@ -3,7 +3,7 @@
3
3
  * @param {string} tsconfig - The path to the tsconfig.json file.
4
4
  * @param {string} outDir - The output directory for the declaration files.
5
5
  * @param {Object} options
6
- * @param {boolean} [options.useTsgo] - Whether to use typescript native (tsgo).
6
+ * @param {boolean} [options.useTsgo] - Whether to use the native TypeScript compiler.
7
7
  */
8
8
  export declare function emitDeclarations(tsconfig: string, outDir: string, options: {
9
9
  useTsgo?: boolean;
@@ -44,7 +44,7 @@ export declare function moveAndTransformDeclarations({ inputDir, buildDir, bundl
44
44
  * @param {string} param0.buildDir - The build directory.
45
45
  * @param {string} param0.cwd - The current working directory.
46
46
  * @param {boolean} param0.skipTsc - Whether to skip running TypeScript compiler (tsc) for building types.
47
- * @param {boolean} [param0.useTsgo=false] - Whether to build types using typescript native (tsgo).
47
+ * @param {boolean} [param0.useTsgo=false] - Whether to build types using the native TypeScript compiler.
48
48
  * @param {'module' | 'commonjs'} [param0.packageType] - The package.json type field.
49
49
  */
50
50
  export declare function createTypes({ bundles, srcDir, buildDir, cwd, skipTsc, useTsgo, packageType, verbose, }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-code-infra",
3
- "version": "0.0.4-canary.98",
3
+ "version": "0.1.1-canary.0",
4
4
  "author": "MUI Team",
5
5
  "description": "Infra scripts and configs to be used across MUI repos.",
6
6
  "license": "MIT",
@@ -53,59 +53,62 @@
53
53
  "code-infra": "./bin/code-infra.mjs"
54
54
  },
55
55
  "dependencies": {
56
- "@argos-ci/core": "6.5.0",
57
- "@babel/cli": "^7.29.7",
58
- "@babel/core": "^7.29.7",
59
- "@babel/plugin-syntax-jsx": "^7.29.7",
60
- "@babel/plugin-syntax-typescript": "^7.29.7",
61
- "@babel/plugin-transform-runtime": "^7.29.7",
62
- "@babel/preset-env": "^7.29.7",
63
- "@babel/preset-react": "^7.29.7",
64
- "@babel/preset-typescript": "^7.29.7",
65
- "@eslint/compat": "^2.1.0",
56
+ "@argos-ci/core": "6.8.4",
57
+ "@babel/cli": "^8.0.5",
58
+ "@babel/core": "^8.0.5",
59
+ "@babel/plugin-syntax-jsx": "^8.0.1",
60
+ "@babel/plugin-syntax-typescript": "^8.0.1",
61
+ "@babel/plugin-transform-runtime": "^8.0.1",
62
+ "@babel/preset-env": "^8.0.5",
63
+ "@babel/preset-react": "^8.0.1",
64
+ "@babel/preset-typescript": "^8.0.1",
65
+ "@eslint/compat": "^2.1.1",
66
66
  "@eslint/js": "^10.0.1",
67
- "@eslint/json": "^2.0.1",
68
- "@inquirer/confirm": "^6.1.1",
69
- "@inquirer/select": "^5.2.1",
70
- "@napi-rs/keyring": "^1.3.0",
71
- "@octokit/auth-action": "^6.0.2",
72
- "@octokit/oauth-methods": "^6.0.2",
67
+ "@eslint/json": "^2.1.0",
68
+ "@inquirer/confirm": "^6.3.2",
69
+ "@inquirer/select": "^5.2.5",
70
+ "@mui/internal-babel-plugin-display-name": "2.0.1-canary.0",
71
+ "@mui/internal-babel-plugin-minify-errors": "3.0.1-canary.0",
72
+ "@mui/internal-babel-plugin-resolve-imports": "3.0.1-canary.0",
73
+ "@napi-rs/keyring": "^2.0.0",
74
+ "@octokit/auth-action": "^6.0.3",
75
+ "@octokit/oauth-methods": "^6.0.5",
73
76
  "@octokit/rest": "^22.0.1",
77
+ "@pnpm/config.version-policy": "^1100.2.3",
74
78
  "@pnpm/find-workspace-dir": "^1000.1.5",
75
- "@typescript-eslint/types": "^8.64.0",
76
- "@typescript-eslint/utils": "^8.64.0",
77
- "@vitest/eslint-plugin": "^1.6.23",
79
+ "@pnpm/parse-wanted-dependency": "^1001.0.0",
80
+ "@typescript-eslint/types": "^8.70.0",
81
+ "@typescript-eslint/utils": "^8.70.0",
82
+ "@vitest/eslint-plugin": "^1.6.27",
78
83
  "babel-plugin-optimize-clsx": "^2.6.2",
79
84
  "babel-plugin-react-compiler": "^1.0.0",
80
- "babel-plugin-transform-import-meta": "^2.3.3",
81
- "babel-plugin-transform-inline-environment-variables": "^0.4.4",
85
+ "babel-plugin-transform-import-meta": "^3.0.0",
82
86
  "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
83
87
  "babel-plugin-transform-remove-imports": "^1.8.1",
84
- "chalk": "^5.6.2",
85
- "clipboardy": "^5.3.1",
86
- "content-type": "^2.0.0",
88
+ "chalk": "^6.0.0",
89
+ "clipboardy": "^5.3.2",
90
+ "content-type": "^3.1.0",
87
91
  "env-ci": "^11.2.0",
88
- "es-toolkit": "^1.49.0",
92
+ "es-toolkit": "^1.52.0",
89
93
  "eslint-config-prettier": "^10.1.8",
90
- "eslint-import-resolver-typescript": "^4.4.4",
94
+ "eslint-import-resolver-typescript": "^4.4.5",
91
95
  "eslint-module-utils": "^2.14.0",
92
96
  "eslint-plugin-compat": "^7.0.2",
93
97
  "eslint-plugin-import": "^2.32.0",
94
98
  "eslint-plugin-jsx-a11y": "^6.10.2",
95
99
  "eslint-plugin-mdx": "^3.8.1",
96
- "eslint-plugin-mocha": "^11.3.0",
97
100
  "eslint-plugin-react": "^7.37.5",
98
101
  "eslint-plugin-react-compiler": "^19.1.0-rc.2",
99
102
  "eslint-plugin-react-hooks": "^7.1.1",
100
103
  "eslint-plugin-testing-library": "^7.16.2",
101
- "execa": "^9.6.1",
104
+ "execa": "^10.0.1",
102
105
  "git-url-parse": "^16.1.0",
103
- "globals": "^17.7.0",
104
- "globby": "^16.2.0",
105
- "html-validate": "^11.5.5",
106
- "minimatch": "^10.2.5",
107
- "node-html-parser": "^9.0.0",
108
- "open": "^11.0.0",
106
+ "globals": "^17.12.0",
107
+ "globby": "^16.2.4",
108
+ "html-validate": "^11.15.0",
109
+ "minimatch": "^10.2.6",
110
+ "node-html-parser": "^9.0.4",
111
+ "open": "^11.0.3",
109
112
  "postcss-styled-syntax": "^0.7.2",
110
113
  "regexp.escape": "^2.0.1",
111
114
  "rehype-slug": "^6.0.0",
@@ -127,35 +130,28 @@
127
130
  "remark-parse": "^11.0.0",
128
131
  "remark-rehype": "^11.1.2",
129
132
  "resolve-pkg-maps": "^1.0.0",
130
- "semver": "^7.8.0",
133
+ "semver": "^7.8.5",
131
134
  "stylelint-config-standard": "^40.0.0",
132
- "typescript-eslint": "^8.64.0",
135
+ "typescript-eslint": "^8.70.0",
133
136
  "unified": "^11.0.5",
134
137
  "unified-lint-rule": "^3.0.1",
135
138
  "unist-util-visit": "^5.1.0",
136
- "yaml": "^2.9.0",
137
- "yargs": "^18.0.0",
138
- "@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.30",
139
- "@mui/internal-babel-plugin-display-name": "1.0.4-canary.23",
140
- "@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.41"
139
+ "yaml": "^2.9.1",
140
+ "yargs": "^18.1.0"
141
141
  },
142
142
  "peerDependencies": {
143
143
  "@next/eslint-plugin-next": "*",
144
- "@typescript/native-preview": ">=7.0.0-dev.0",
145
144
  "eslint": "^9.0.0 || ^10.0.0",
146
145
  "prettier": "^3.0.0",
147
- "typescript": "^5.0.0 || ^6.0.0"
146
+ "typescript": "^5.0.0 || ^6.0.0 || ^7.0.0"
148
147
  },
149
148
  "peerDependenciesMeta": {
150
- "@typescript/native-preview": {
151
- "optional": true
152
- },
153
149
  "typescript": {
154
150
  "optional": true
155
151
  }
156
152
  },
157
153
  "devDependencies": {
158
- "@octokit/types": "16.0.0",
154
+ "@octokit/types": "18.0.0",
159
155
  "@types/babel__core": "7.20.5",
160
156
  "@types/babel__preset-env": "7.10.0",
161
157
  "@types/env-ci": "3.1.4",
@@ -165,15 +161,17 @@
165
161
  "@types/mdast": "4.0.4",
166
162
  "@types/regexp.escape": "2.0.0",
167
163
  "@types/yargs": "17.0.35",
168
- "@typescript-eslint/parser": "8.64.0",
169
- "@typescript-eslint/rule-tester": "8.64.0",
170
- "eslint": "10.7.0",
164
+ "@typescript-eslint/parser": "8.70.0",
165
+ "@typescript-eslint/rule-tester": "8.70.0",
166
+ "@typescript/native": "npm:typescript@7.0.2",
167
+ "eslint": "10.10.0",
171
168
  "get-port": "7.2.0",
172
- "prettier": "3.9.5",
169
+ "prettier": "3.9.6",
173
170
  "remark": "15.0.1",
174
171
  "remark-mdx": "3.1.1",
175
172
  "serve": "14.2.6",
176
- "typescript-eslint": "8.64.0"
173
+ "typescript": "npm:@typescript/typescript6@6.0.2",
174
+ "typescript-eslint": "8.70.0"
177
175
  },
178
176
  "files": [
179
177
  "bin",
@@ -188,10 +186,10 @@
188
186
  "publishConfig": {
189
187
  "access": "public"
190
188
  },
191
- "gitSha": "5a40e5ed0fc8d5ff358463279c75f69b33062d9f",
189
+ "gitSha": "764e3b3cfc14293e74e93f3413609025f502bab9",
192
190
  "scripts": {
193
- "build": "tsgo -p tsconfig.build.json",
194
- "typescript": "tsgo -noEmit",
191
+ "build": "tsc -p tsconfig.build.json",
192
+ "typescript": "tsc -noEmit",
195
193
  "test": "pnpm -w test --project @mui/internal-code-infra",
196
194
  "test:copy": "rm -rf build && node bin/code-infra.mjs copy-files --glob \"src/cli/*.mjs\" --glob \"src/eslint/**/*.mjs:esm\""
197
195
  }
@@ -7,8 +7,8 @@ import pluginResolveImports from '@mui/internal-babel-plugin-resolve-imports';
7
7
  import pluginOptimizeClsx from 'babel-plugin-optimize-clsx';
8
8
  import pluginReactCompiler from 'babel-plugin-react-compiler';
9
9
  import pluginTransformImportMeta from 'babel-plugin-transform-import-meta';
10
- import pluginTransformInlineEnvVars from 'babel-plugin-transform-inline-environment-variables';
11
10
  import pluginRemovePropTypes from 'babel-plugin-transform-react-remove-prop-types';
11
+ import pluginTransformInlineEnvVars from './babelPluginInlineEnvironmentVariables.mjs';
12
12
 
13
13
  /**
14
14
  * @typedef {'annotation' | 'syntax' | 'infer' | 'all'} ReactCompilationMode
@@ -26,7 +26,7 @@ import pluginRemovePropTypes from 'babel-plugin-transform-react-remove-prop-type
26
26
  * @param {string} [param0.reactCompilerReactVersion]
27
27
  * @param {ReactCompilationMode} [param0.reactCompilerMode]
28
28
  * @param {{ allowedCallees?: Record<string, string[]> }} [param0.displayName] - Options for the display name plugin.
29
- * @returns {import('@babel/core').TransformOptions} The base Babel configuration.
29
+ * @returns {import('@babel/core').InputOptions} The base Babel configuration.
30
30
  */
31
31
  export function getBaseConfig({
32
32
  debug = false,
@@ -44,22 +44,19 @@ export function getBaseConfig({
44
44
  * @type {import('@babel/preset-env').Options}
45
45
  */
46
46
  const presetEnvOptions = {
47
- bugfixes: true,
48
47
  debug,
49
48
  modules: bundle === 'esm' ? false : 'commonjs',
50
49
  // @TODO
51
50
  browserslistEnv: bundle === 'esm' ? 'stable' : 'node',
52
51
  };
53
52
  /**
54
- * @type {import('@babel/core').TransformOptions["plugins"]}
53
+ * @type {import('@babel/core').PluginItem[]}
55
54
  */
56
55
  const plugins = [
57
56
  [
58
57
  pluginTransformRuntime,
59
58
  {
60
59
  version: runtimeVersion,
61
- regenerator: false,
62
- useESModules: bundle === 'esm',
63
60
  },
64
61
  '@babel/plugin-transform-runtime',
65
62
  ],
@@ -143,12 +140,24 @@ export function getBaseConfig({
143
140
  presets: [
144
141
  [presetEnv, presetEnvOptions],
145
142
  [
146
- presetReact,
147
- { runtime: 'automatic', useBuiltIns: bundle === 'esm', useSpread: bundle === 'esm' },
143
+ presetTypescript,
144
+ {
145
+ // Babel 8 defaults this to `true`, which keeps `import { type A } from 'x'` as a
146
+ // side-effect `import 'x'`. Restore full elision so type-only imports don't create
147
+ // runtime module cycles.
148
+ onlyRemoveTypeImports: false,
149
+ },
148
150
  ],
149
- [presetTypescript],
150
151
  ],
151
152
  plugins,
153
+ overrides: [
154
+ {
155
+ // Babel 8 keeps the JSX parser on for every file the React preset touches, which
156
+ // misparses generic arrows like `<T = unknown>(x) => x` in plain `.ts` files.
157
+ exclude: /\.[cm]?ts$/,
158
+ presets: [[presetReact, { runtime: 'automatic' }]],
159
+ },
160
+ ],
152
161
  };
153
162
  }
154
163
 
@@ -161,7 +170,7 @@ export function getBaseConfig({
161
170
 
162
171
  /**
163
172
  * @param {import('@babel/core').ConfigAPI | Options} api
164
- * @returns {import('@babel/core').TransformOptions}
173
+ * @returns {import('@babel/core').InputOptions}
165
174
  */
166
175
  export default function getBabelConfig(api) {
167
176
  /** @type {'esm' | 'cjs'} */
@@ -183,7 +192,8 @@ export default function getBabelConfig(api) {
183
192
  debug: process.env.MUI_BUILD_VERBOSE === 'true',
184
193
  bundle,
185
194
  outExtension: process.env.MUI_OUT_FILE_EXTENSION || null,
186
- // any package needs to declare 7.25.0 as a runtime dependency. default is ^7.0.0
195
+ // Lower bound of @babel/runtime a consumer must ship; `code-infra build` reads the real
196
+ // version off the package's dependencies instead. Runtime 7 and 8 both satisfy this.
187
197
  runtimeVersion: process.env.MUI_BABEL_RUNTIME_VERSION || '^7.25.0',
188
198
  optimizeClsx: process.env.MUI_OPTIMIZE_CLSX === 'true',
189
199
  removePropTypes: process.env.MUI_REMOVE_PROP_TYPES === 'true',
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Inlines `process.env.X` member expressions with their build-time value.
3
+ *
4
+ * Forked from `babel-plugin-transform-inline-environment-variables` (unmaintained, last
5
+ * published 2022) because it calls the now-removed `NodePath#toComputedKey()` under Babel 8's
6
+ * `@babel/traverse`. Behavior is otherwise identical to the upstream plugin.
7
+ *
8
+ * @param {import('@babel/core').PluginAPI} api
9
+ * @returns {import('@babel/core').PluginObject}
10
+ */
11
+ export default function babelPluginInlineEnvironmentVariables({ types: t }) {
12
+ /**
13
+ * @param {import('@babel/core').NodePath<import('@babel/core').types.MemberExpression>} path
14
+ */
15
+ function isLeftSideOfAssignmentExpression(path) {
16
+ return t.isAssignmentExpression(path.parent) && path.parent.left === path.node;
17
+ }
18
+
19
+ return {
20
+ name: 'transform-inline-environment-variables',
21
+ visitor: {
22
+ MemberExpression(
23
+ path,
24
+ /** @type {{ opts?: { include?: string[], exclude?: string[] } }} */ {
25
+ opts: { include, exclude } = {},
26
+ },
27
+ ) {
28
+ if (!path.get('object').matchesPattern('process.env')) {
29
+ return;
30
+ }
31
+
32
+ const key = t.toComputedKey(path.node);
33
+
34
+ if (
35
+ t.isStringLiteral(key) &&
36
+ !isLeftSideOfAssignmentExpression(path) &&
37
+ (!include || include.indexOf(key.value) !== -1) &&
38
+ (!exclude || exclude.indexOf(key.value) === -1)
39
+ ) {
40
+ path.replaceWith(t.valueToNode(process.env[key.value]));
41
+ }
42
+ },
43
+ },
44
+ };
45
+ }
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-console */
2
- import { execaCommand } from 'execa';
2
+ import { execa, parseCommandString } from 'execa';
3
3
  import timers from 'node:timers/promises';
4
4
  import * as fs from 'node:fs/promises';
5
5
  import * as path from 'node:path';
@@ -626,7 +626,7 @@ export async function crawl(rawOptions) {
626
626
  if (options.startCommand) {
627
627
  console.log(chalk.blue(`Starting server with "${options.startCommand}"...`));
628
628
  controller = new AbortController();
629
- const appProcess = execaCommand(options.startCommand, {
629
+ const appProcess = execa({
630
630
  stdout: 'pipe',
631
631
  stderr: 'pipe',
632
632
  cancelSignal: controller.signal,
@@ -634,7 +634,7 @@ export async function crawl(rawOptions) {
634
634
  FORCE_COLOR: '1',
635
635
  ...process.env,
636
636
  },
637
- });
637
+ })`${parseCommandString(options.startCommand)}`;
638
638
 
639
639
  // Prefix server logs
640
640
  const serverPrefix = chalk.gray('server: ');