@mui/internal-code-infra 0.0.4-canary.110 → 0.0.4-canary.111

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.
@@ -48,7 +48,7 @@ export type Args = {
48
48
  */
49
49
  enableReactCompiler?: boolean;
50
50
  /**
51
- * - Whether to build types using typescript native (tsgo).
51
+ * - Whether to build types using the native TypeScript compiler.
52
52
  */
53
53
  tsgo?: boolean;
54
54
  /**
@@ -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.110",
3
+ "version": "0.0.4-canary.111",
4
4
  "author": "MUI Team",
5
5
  "description": "Infra scripts and configs to be used across MUI repos.",
6
6
  "license": "MIT",
@@ -136,21 +136,17 @@
136
136
  "unist-util-visit": "^5.1.0",
137
137
  "yaml": "^2.9.0",
138
138
  "yargs": "^18.1.0",
139
- "@mui/internal-babel-plugin-display-name": "1.0.4-canary.23",
140
- "@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.42",
141
- "@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.30"
139
+ "@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.31",
140
+ "@mui/internal-babel-plugin-display-name": "1.0.4-canary.24",
141
+ "@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.43"
142
142
  },
143
143
  "peerDependencies": {
144
144
  "@next/eslint-plugin-next": "*",
145
- "@typescript/native-preview": ">=7.0.0-dev.0",
146
145
  "eslint": "^9.0.0 || ^10.0.0",
147
146
  "prettier": "^3.0.0",
148
147
  "typescript": "^5.0.0 || ^6.0.0"
149
148
  },
150
149
  "peerDependenciesMeta": {
151
- "@typescript/native-preview": {
152
- "optional": true
153
- },
154
150
  "typescript": {
155
151
  "optional": true
156
152
  }
@@ -168,12 +164,14 @@
168
164
  "@types/yargs": "17.0.35",
169
165
  "@typescript-eslint/parser": "8.68.0",
170
166
  "@typescript-eslint/rule-tester": "8.68.0",
167
+ "@typescript/native": "npm:typescript@7.0.2",
171
168
  "eslint": "10.9.1",
172
169
  "get-port": "7.2.0",
173
170
  "prettier": "3.9.6",
174
171
  "remark": "15.0.1",
175
172
  "remark-mdx": "3.1.1",
176
173
  "serve": "14.2.6",
174
+ "typescript": "npm:@typescript/typescript6@6.0.2",
177
175
  "typescript-eslint": "8.68.0"
178
176
  },
179
177
  "files": [
@@ -189,10 +187,10 @@
189
187
  "publishConfig": {
190
188
  "access": "public"
191
189
  },
192
- "gitSha": "fdfa28912aa56f2473702b4a49a5a7a3164f5e4c",
190
+ "gitSha": "9e0cb003bd909d9f1b5f9f33b1706f3ce1627ea8",
193
191
  "scripts": {
194
- "build": "tsgo -p tsconfig.build.json",
195
- "typescript": "tsgo -noEmit",
192
+ "build": "tsc -p tsconfig.build.json",
193
+ "typescript": "tsc -noEmit",
196
194
  "test": "pnpm -w test --project @mui/internal-code-infra",
197
195
  "test:copy": "rm -rf build && node bin/code-infra.mjs copy-files --glob \"src/cli/*.mjs\" --glob \"src/eslint/**/*.mjs:esm\""
198
196
  }
@@ -30,7 +30,7 @@ import { readPnpmConfig } from '../utils/pnpm.mjs';
30
30
  * @property {string[]} ignore - Globs to be ignored by Babel.
31
31
  * @property {string[]} [copy] - Files/Directories to be copied. Can be a glob pattern.
32
32
  * @property {boolean} [enableReactCompiler] - Whether to use the React compiler.
33
- * @property {boolean} [tsgo] - Whether to build types using typescript native (tsgo).
33
+ * @property {boolean} [tsgo] - Whether to build types using the native TypeScript compiler.
34
34
  * @property {boolean} [flat] - Deprecated no-op; flat builds are always used.
35
35
  * @property {boolean} expand - Whether to enumerate glob patterns in exports/imports into concrete entries.
36
36
  */
@@ -229,9 +229,9 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
229
229
  })
230
230
  .option('tsgo', {
231
231
  type: 'boolean',
232
- default: process.env.MUI_USE_TSGO,
232
+ default: false,
233
233
  description:
234
- 'Uses tsgo cli instead of tsc for type generation. Can also be set via env var "MUI_USE_TSGO"',
234
+ 'Use the native TypeScript compiler instead of the TS6 JS compiler for type generation',
235
235
  })
236
236
  .option('flat', {
237
237
  type: 'boolean',
@@ -14,21 +14,43 @@ import { getOutExtension, mapConcurrently } from '../utils/build.mjs';
14
14
  const $$ = $({ stdio: 'inherit' });
15
15
 
16
16
  /**
17
- * Checks if tsgo CLI is available in the workspace's node_modules.
18
- * @param {string} cwd - The current working directory to start searching from.
19
- * @returns {Promise<string | null>} - The path to tsgo if found, null otherwise.
17
+ * Finds a CLI shim in a directory's node_modules/.bin.
18
+ * @param {string} dir
19
+ * @param {string} name
20
+ * @returns {Promise<string | null>}
20
21
  */
21
- async function findTsgo(cwd) {
22
- const workspaceDir = await findWorkspaceDir(cwd);
23
- if (!workspaceDir) {
24
- return null;
25
- }
26
- const tsgoPath = path.join(workspaceDir, 'node_modules', '.bin', 'tsgo');
27
- const exists = await fs.stat(tsgoPath).then(
22
+ async function findBin(dir, name) {
23
+ const binPath = path.join(dir, 'node_modules', '.bin', name);
24
+ const exists = await fs.stat(binPath).then(
28
25
  (stat) => stat.isFile(),
29
26
  () => false,
30
27
  );
31
- return exists ? tsgoPath : null;
28
+ return exists ? binPath : null;
29
+ }
30
+
31
+ /**
32
+ * Resolves the native/JS TypeScript CLI pair from the workspace root's
33
+ * `node_modules/.bin`: tsgo/tsc when the legacy `tsgo` shim exists, tsc/tsc6
34
+ * otherwise, with bare `tsc` from PATH as the JS fallback.
35
+ *
36
+ * @param {string} cwd
37
+ * @returns {Promise<{ native: string | null, js: string }>}
38
+ */
39
+ async function findTscPair(cwd) {
40
+ const workspaceDir = await findWorkspaceDir(cwd);
41
+ if (!workspaceDir) {
42
+ return { native: null, js: 'tsc' };
43
+ }
44
+
45
+ const [tsgo, tsc, tsc6] = await Promise.all([
46
+ findBin(workspaceDir, 'tsgo'),
47
+ findBin(workspaceDir, 'tsc'),
48
+ findBin(workspaceDir, 'tsc6'),
49
+ ]);
50
+ if (tsgo) {
51
+ return { native: tsgo, js: 'tsc' };
52
+ }
53
+ return { native: tsc, js: tsc6 ?? 'tsc' };
32
54
  }
33
55
 
34
56
  /**
@@ -36,44 +58,38 @@ async function findTsgo(cwd) {
36
58
  * @param {string} tsconfig - The path to the tsconfig.json file.
37
59
  * @param {string} outDir - The output directory for the declaration files.
38
60
  * @param {Object} options
39
- * @param {boolean} [options.useTsgo] - Whether to use typescript native (tsgo).
61
+ * @param {boolean} [options.useTsgo] - Whether to use the native TypeScript compiler.
40
62
  */
41
63
  export async function emitDeclarations(tsconfig, outDir, options) {
42
64
  const { useTsgo = false } = options ?? {};
43
65
  const tsconfigDir = path.dirname(tsconfig);
44
66
  const rootDir = path.resolve(tsconfigDir, './src');
45
67
 
46
- const tsgoPath = useTsgo ? await findTsgo(tsconfigDir) : null;
68
+ const pair = await findTscPair(tsconfigDir);
69
+ const tsgoPath = useTsgo ? pair.native : null;
47
70
  if (useTsgo && !tsgoPath) {
48
71
  throw new Error(
49
- '--tsgo flag was passed or MUI_USE_TSGO environment was set but no tsgo cli was found. Either remove the flag to use tsc or install the native package "@typescript/native-preview" at the workspace level to use tsgo.',
72
+ '--tsgo flag was passed but no native TypeScript cli was found. Either remove the flag to use the JS compiler or install TypeScript 7 at the workspace root, as "typescript@^7" or under an alias such as "@typescript/native".',
50
73
  );
51
74
  }
52
75
 
53
- if (tsgoPath) {
54
- console.log('Using tsgo for declaration emit');
55
- await $$`${tsgoPath}
56
- -p ${tsconfig}
57
- --rootDir ${rootDir}
58
- --outDir ${outDir}
59
- --declaration
60
- --emitDeclarationOnly
61
- --noEmit false
62
- --composite false
63
- --incremental false
64
- --declarationMap false`;
65
- } else {
66
- await $$`tsc
67
- -p ${tsconfig}
68
- --rootDir ${rootDir}
69
- --outDir ${outDir}
70
- --declaration
71
- --emitDeclarationOnly
72
- --noEmit false
73
- --composite false
74
- --incremental false
75
- --declarationMap false`;
76
- }
76
+ const tscPath = tsgoPath ?? pair.js;
77
+ console.log(
78
+ tsgoPath
79
+ ? `Using ts-native for declaration emit: ${tscPath}`
80
+ : `Using ${tscPath} for declaration emit`,
81
+ );
82
+
83
+ await $$`${tscPath}
84
+ -p ${tsconfig}
85
+ --rootDir ${rootDir}
86
+ --outDir ${outDir}
87
+ --declaration
88
+ --emitDeclarationOnly
89
+ --noEmit false
90
+ --composite false
91
+ --incremental false
92
+ --declarationMap false`;
77
93
  }
78
94
 
79
95
  /**
@@ -198,7 +214,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
198
214
  * @param {string} param0.buildDir - The build directory.
199
215
  * @param {string} param0.cwd - The current working directory.
200
216
  * @param {boolean} param0.skipTsc - Whether to skip running TypeScript compiler (tsc) for building types.
201
- * @param {boolean} [param0.useTsgo=false] - Whether to build types using typescript native (tsgo).
217
+ * @param {boolean} [param0.useTsgo=false] - Whether to build types using the native TypeScript compiler.
202
218
  * @param {'module' | 'commonjs'} [param0.packageType] - The package.json type field.
203
219
  */
204
220
  export async function createTypes({