@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
@@ -9,26 +9,49 @@ import { globby } from 'globby';
9
9
  import * as fs from 'node:fs/promises';
10
10
  import * as os from 'node:os';
11
11
  import * as path from 'node:path';
12
- import { getOutExtension, mapConcurrently } from '../utils/build.mjs';
12
+ import { mapAsync } from 'es-toolkit/array';
13
+ import { getOutExtension } from '../utils/build.mjs';
13
14
 
14
15
  const $$ = $({ stdio: 'inherit' });
15
16
 
16
17
  /**
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.
18
+ * Finds a CLI shim in a directory's node_modules/.bin.
19
+ * @param {string} dir
20
+ * @param {string} name
21
+ * @returns {Promise<string | null>}
20
22
  */
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(
23
+ async function findBin(dir, name) {
24
+ const binPath = path.join(dir, 'node_modules', '.bin', name);
25
+ const exists = await fs.stat(binPath).then(
28
26
  (stat) => stat.isFile(),
29
27
  () => false,
30
28
  );
31
- return exists ? tsgoPath : null;
29
+ return exists ? binPath : null;
30
+ }
31
+
32
+ /**
33
+ * Resolves the native/JS TypeScript CLI pair from the workspace root's
34
+ * `node_modules/.bin`: tsgo/tsc when the legacy `tsgo` shim exists, tsc/tsc6
35
+ * otherwise, with bare `tsc` from PATH as the JS fallback.
36
+ *
37
+ * @param {string} cwd
38
+ * @returns {Promise<{ native: string | null, js: string }>}
39
+ */
40
+ async function findTscPair(cwd) {
41
+ const workspaceDir = await findWorkspaceDir(cwd);
42
+ if (!workspaceDir) {
43
+ return { native: null, js: 'tsc' };
44
+ }
45
+
46
+ const [tsgo, tsc, tsc6] = await Promise.all([
47
+ findBin(workspaceDir, 'tsgo'),
48
+ findBin(workspaceDir, 'tsc'),
49
+ findBin(workspaceDir, 'tsc6'),
50
+ ]);
51
+ if (tsgo) {
52
+ return { native: tsgo, js: 'tsc' };
53
+ }
54
+ return { native: tsc, js: tsc6 ?? 'tsc' };
32
55
  }
33
56
 
34
57
  /**
@@ -36,44 +59,38 @@ async function findTsgo(cwd) {
36
59
  * @param {string} tsconfig - The path to the tsconfig.json file.
37
60
  * @param {string} outDir - The output directory for the declaration files.
38
61
  * @param {Object} options
39
- * @param {boolean} [options.useTsgo] - Whether to use typescript native (tsgo).
62
+ * @param {boolean} [options.useTsgo] - Whether to use the native TypeScript compiler.
40
63
  */
41
64
  export async function emitDeclarations(tsconfig, outDir, options) {
42
65
  const { useTsgo = false } = options ?? {};
43
66
  const tsconfigDir = path.dirname(tsconfig);
44
67
  const rootDir = path.resolve(tsconfigDir, './src');
45
68
 
46
- const tsgoPath = useTsgo ? await findTsgo(tsconfigDir) : null;
69
+ const pair = await findTscPair(tsconfigDir);
70
+ const tsgoPath = useTsgo ? pair.native : null;
47
71
  if (useTsgo && !tsgoPath) {
48
72
  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.',
73
+ '--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
74
  );
51
75
  }
52
76
 
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
- }
77
+ const tscPath = tsgoPath ?? pair.js;
78
+ console.log(
79
+ tsgoPath
80
+ ? `Using ts-native for declaration emit: ${tscPath}`
81
+ : `Using ${tscPath} for declaration emit`,
82
+ );
83
+
84
+ await $$`${tscPath}
85
+ -p ${tsconfig}
86
+ --rootDir ${rootDir}
87
+ --outDir ${outDir}
88
+ --declaration
89
+ --emitDeclarationOnly
90
+ --noEmit false
91
+ --composite false
92
+ --incremental false
93
+ --declarationMap false`;
77
94
  }
78
95
 
79
96
  /**
@@ -129,7 +146,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
129
146
  return;
130
147
  }
131
148
 
132
- await mapConcurrently(
149
+ await mapAsync(
133
150
  dtsFiles,
134
151
  async (dtsFile) => {
135
152
  // Normalize to native separators to make path comparisons reliable on Windows
@@ -160,6 +177,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
160
177
  const outFileRelative = relativePath.replace(/\.d\.ts$/, newFileExtension);
161
178
  const outFilePath = path.join(buildDir, outFileRelative);
162
179
 
180
+ /** @type {import('@babel/core').PluginItem[]} */
163
181
  const babelPlugins = [
164
182
  [pluginTypescriptSyntax, { dts: true }],
165
183
  [pluginResolveImports, { outExtension: importExtension }],
@@ -182,7 +200,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
182
200
  await fs.unlink(nativeDtsFile);
183
201
  }
184
202
  },
185
- 30,
203
+ { concurrency: 30 },
186
204
  );
187
205
  }
188
206
 
@@ -198,7 +216,7 @@ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles
198
216
  * @param {string} param0.buildDir - The build directory.
199
217
  * @param {string} param0.cwd - The current working directory.
200
218
  * @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).
219
+ * @param {boolean} [param0.useTsgo=false] - Whether to build types using the native TypeScript compiler.
202
220
  * @param {'module' | 'commonjs'} [param0.packageType] - The package.json type field.
203
221
  */
204
222
  export async function createTypes({