@mui/internal-code-infra 0.0.4-canary.57 → 0.0.4-canary.59
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.
- package/build/cli/cmdBuild.d.mts +1 -0
- package/build/utils/build.d.mts +58 -22
- package/package.json +4 -4
- package/src/cli/cmdBuild.mjs +39 -16
- package/src/eslint/docsConfig.mjs +2 -1
- package/src/utils/build.mjs +607 -259
- package/src/utils/build.test.mjs +740 -171
package/build/cli/cmdBuild.d.mts
CHANGED
package/build/utils/build.d.mts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export type BundleType = 'esm' | 'cjs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export type BundleMeta = {
|
|
3
|
+
type: BundleType;
|
|
4
|
+
dir: string;
|
|
5
|
+
condition: 'import' | 'require';
|
|
6
|
+
outExtension: string;
|
|
7
|
+
typeOutExtension: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const BASE_IGNORES: string[];
|
|
5
10
|
/**
|
|
6
11
|
* @param {BundleType} bundle
|
|
7
12
|
* @param {Object} [options]
|
|
@@ -16,17 +21,17 @@ export declare function getOutExtension(bundle: BundleType, options?: {
|
|
|
16
21
|
packageType?: 'module' | 'commonjs';
|
|
17
22
|
}): string;
|
|
18
23
|
/**
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {{type: BundleType; dir: string}[]}
|
|
22
|
-
* @param {string}
|
|
23
|
-
* @param {string}
|
|
24
|
-
* @param {boolean} [
|
|
25
|
-
* @param {boolean} [
|
|
26
|
-
* @param {
|
|
24
|
+
* @param {import('../cli/packageJson').PackageJson['exports']} packageExports
|
|
25
|
+
* @param {Object} options
|
|
26
|
+
* @param {{type: BundleType; dir: string}[]} options.bundles
|
|
27
|
+
* @param {string} options.outputDir
|
|
28
|
+
* @param {string} options.cwd
|
|
29
|
+
* @param {boolean} [options.addTypes]
|
|
30
|
+
* @param {boolean} [options.isFlat]
|
|
31
|
+
* @param {boolean} [options.expand] - Whether to enumerate glob patterns into concrete entries.
|
|
32
|
+
* @param {'module' | 'commonjs'} [options.packageType]
|
|
27
33
|
*/
|
|
28
|
-
export declare function createPackageExports(
|
|
29
|
-
exports: import('../cli/packageJson').PackageJson['exports'];
|
|
34
|
+
export declare function createPackageExports(packageExports: import('../cli/packageJson').PackageJson['exports'], { bundles, outputDir, cwd, addTypes, isFlat, expand, packageType, }: {
|
|
30
35
|
bundles: {
|
|
31
36
|
type: BundleType;
|
|
32
37
|
dir: string;
|
|
@@ -35,6 +40,7 @@ export declare function createPackageExports({ exports: packageExports, bundles,
|
|
|
35
40
|
cwd: string;
|
|
36
41
|
addTypes?: boolean;
|
|
37
42
|
isFlat?: boolean;
|
|
43
|
+
expand?: boolean;
|
|
38
44
|
packageType?: 'module' | 'commonjs';
|
|
39
45
|
}): Promise<{
|
|
40
46
|
main?: string;
|
|
@@ -42,15 +48,46 @@ export declare function createPackageExports({ exports: packageExports, bundles,
|
|
|
42
48
|
exports: import('../cli/packageJson').PackageJson.ExportConditions;
|
|
43
49
|
}>;
|
|
44
50
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
50
|
-
*
|
|
51
|
+
* Generates the package.json `imports` field for the built package, rewriting
|
|
52
|
+
* internal subpath imports (keys starting with `#`) that point at source files
|
|
53
|
+
* into their built equivalents with `import`/`require`/`types` conditions.
|
|
54
|
+
*
|
|
55
|
+
* Mirrors {@link createPackageExports} but without the `.` / `package.json` /
|
|
56
|
+
* `main` / `types` index handling that only applies to public exports. Entries
|
|
57
|
+
* that resolve to bare specifiers (e.g. an external package) are passed through
|
|
58
|
+
* unchanged, since the `imports` field commonly aliases dependencies.
|
|
59
|
+
* @param {import('../cli/packageJson').PackageJson['imports']} packageImports
|
|
60
|
+
* @param {Object} options
|
|
61
|
+
* @param {{type: BundleType; dir: string}[]} options.bundles
|
|
62
|
+
* @param {string} options.cwd
|
|
63
|
+
* @param {string} [options.outputDir] - Used to verify non-source passthrough paths exist in the build output.
|
|
64
|
+
* @param {boolean} [options.addTypes]
|
|
65
|
+
* @param {boolean} [options.isFlat]
|
|
66
|
+
* @param {boolean} [options.expand] - Whether to enumerate glob patterns into concrete entries.
|
|
67
|
+
* @param {'module' | 'commonjs'} [options.packageType]
|
|
68
|
+
* @returns {Promise<import('../cli/packageJson').PackageJson.Imports | undefined>}
|
|
51
69
|
*/
|
|
52
|
-
export declare function
|
|
53
|
-
|
|
70
|
+
export declare function createPackageImports(packageImports: import('../cli/packageJson').PackageJson['imports'], { bundles, cwd, outputDir, addTypes, isFlat, expand, packageType, }: {
|
|
71
|
+
bundles: {
|
|
72
|
+
type: BundleType;
|
|
73
|
+
dir: string;
|
|
74
|
+
}[];
|
|
75
|
+
cwd: string;
|
|
76
|
+
outputDir?: string;
|
|
77
|
+
addTypes?: boolean;
|
|
78
|
+
isFlat?: boolean;
|
|
79
|
+
expand?: boolean;
|
|
80
|
+
packageType?: 'module' | 'commonjs';
|
|
81
|
+
}): Promise<import('../cli/packageJson').PackageJson.Imports | undefined>;
|
|
82
|
+
/**
|
|
83
|
+
* @param {import('../cli/packageJson').PackageJson['bin']} bin
|
|
84
|
+
* @param {Object} options
|
|
85
|
+
* @param {{type: BundleType; dir: string}[]} options.bundles
|
|
86
|
+
* @param {string} options.cwd
|
|
87
|
+
* @param {boolean} [options.isFlat]
|
|
88
|
+
* @param {'module' | 'commonjs'} [options.packageType]
|
|
89
|
+
*/
|
|
90
|
+
export declare function createPackageBin(bin: import('../cli/packageJson').PackageJson['bin'], { bundles, cwd, isFlat, packageType }: {
|
|
54
91
|
bundles: {
|
|
55
92
|
type: BundleType;
|
|
56
93
|
dir: string;
|
|
@@ -84,7 +121,6 @@ export declare function markFn<F extends () => Promise<any>>(label: string, fn:
|
|
|
84
121
|
* @param {string} label
|
|
85
122
|
*/
|
|
86
123
|
export declare function measureFn(label: string): PerformanceMeasure;
|
|
87
|
-
export declare const BASE_IGNORES: string[];
|
|
88
124
|
/**
|
|
89
125
|
* A utility to map a function over an array of items in a worker pool.
|
|
90
126
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-code-infra",
|
|
3
|
-
"version": "0.0.4-canary.
|
|
3
|
+
"version": "0.0.4-canary.59",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Infra scripts and configs to be used across MUI repos.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -139,9 +139,9 @@
|
|
|
139
139
|
"unified-lint-rule": "^3.0.1",
|
|
140
140
|
"unist-util-visit": "^5.1.0",
|
|
141
141
|
"yargs": "^18.0.0",
|
|
142
|
-
"@mui/internal-babel-plugin-
|
|
142
|
+
"@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.27",
|
|
143
143
|
"@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.36",
|
|
144
|
-
"@mui/internal-babel-plugin-
|
|
144
|
+
"@mui/internal-babel-plugin-display-name": "1.0.4-canary.20"
|
|
145
145
|
},
|
|
146
146
|
"peerDependencies": {
|
|
147
147
|
"@next/eslint-plugin-next": "*",
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"publishConfig": {
|
|
192
192
|
"access": "public"
|
|
193
193
|
},
|
|
194
|
-
"gitSha": "
|
|
194
|
+
"gitSha": "030f835729dfcfc281a941f8806a6b703b4e5a4d",
|
|
195
195
|
"scripts": {
|
|
196
196
|
"build": "tsgo -p tsconfig.build.json",
|
|
197
197
|
"typescript": "tsgo -noEmit",
|
package/src/cli/cmdBuild.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import * as semver from 'semver';
|
|
|
10
10
|
import {
|
|
11
11
|
createPackageBin,
|
|
12
12
|
createPackageExports,
|
|
13
|
+
createPackageImports,
|
|
13
14
|
getOutExtension,
|
|
14
15
|
mapConcurrently,
|
|
15
16
|
validatePkgJson,
|
|
@@ -31,6 +32,7 @@ import {
|
|
|
31
32
|
* @property {boolean} [enableReactCompiler] - Whether to use the React compiler.
|
|
32
33
|
* @property {boolean} [tsgo] - Whether to build types using typescript native (tsgo).
|
|
33
34
|
* @property {boolean} [flat] - Builds the package in a flat structure without subdirectories for each module type.
|
|
35
|
+
* @property {boolean} expand - Whether to enumerate glob patterns in exports/imports into concrete entries.
|
|
34
36
|
*/
|
|
35
37
|
|
|
36
38
|
const validBundles = [
|
|
@@ -85,6 +87,7 @@ ${content}`,
|
|
|
85
87
|
* @param {string} param0.cwd
|
|
86
88
|
* @param {boolean} param0.addTypes - Whether to add type declarations for the package.
|
|
87
89
|
* @param {boolean} param0.isFlat - Whether the build is flat structure.
|
|
90
|
+
* @param {boolean} [param0.expand] - Whether to enumerate glob patterns into concrete entries.
|
|
88
91
|
* @param {'module' | 'commonjs'} param0.packageType - The package.json type field.
|
|
89
92
|
*/
|
|
90
93
|
async function writePackageJson({
|
|
@@ -94,36 +97,50 @@ async function writePackageJson({
|
|
|
94
97
|
cwd,
|
|
95
98
|
addTypes = false,
|
|
96
99
|
isFlat = false,
|
|
100
|
+
expand = true,
|
|
97
101
|
packageType,
|
|
98
102
|
}) {
|
|
99
103
|
delete packageJson.scripts;
|
|
100
104
|
delete packageJson.publishConfig?.directory;
|
|
101
105
|
delete packageJson.devDependencies;
|
|
102
|
-
delete packageJson.imports;
|
|
103
106
|
|
|
104
107
|
const resolvedPackageType = packageType || packageJson.type || 'commonjs';
|
|
105
108
|
packageJson.type = resolvedPackageType;
|
|
106
109
|
|
|
107
110
|
const originalExports = packageJson.exports;
|
|
108
111
|
delete packageJson.exports;
|
|
112
|
+
const originalImports = packageJson.imports;
|
|
113
|
+
delete packageJson.imports;
|
|
109
114
|
const originalBin = packageJson.bin;
|
|
110
115
|
delete packageJson.bin;
|
|
111
116
|
|
|
112
|
-
const {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
const [{ exports: packageExports, main, types }, packageImports] = await Promise.all([
|
|
118
|
+
createPackageExports(originalExports, {
|
|
119
|
+
bundles,
|
|
120
|
+
outputDir,
|
|
121
|
+
cwd,
|
|
122
|
+
addTypes,
|
|
123
|
+
isFlat,
|
|
124
|
+
expand,
|
|
125
|
+
packageType: resolvedPackageType,
|
|
126
|
+
}),
|
|
127
|
+
originalImports
|
|
128
|
+
? createPackageImports(originalImports, {
|
|
129
|
+
bundles,
|
|
130
|
+
cwd,
|
|
131
|
+
outputDir,
|
|
132
|
+
addTypes,
|
|
133
|
+
isFlat,
|
|
134
|
+
expand,
|
|
135
|
+
packageType: resolvedPackageType,
|
|
136
|
+
})
|
|
137
|
+
: Promise.resolve(undefined),
|
|
138
|
+
]);
|
|
125
139
|
|
|
126
140
|
packageJson.exports = packageExports;
|
|
141
|
+
if (packageImports) {
|
|
142
|
+
packageJson.imports = packageImports;
|
|
143
|
+
}
|
|
127
144
|
if (main) {
|
|
128
145
|
packageJson.main = main;
|
|
129
146
|
}
|
|
@@ -131,8 +148,7 @@ async function writePackageJson({
|
|
|
131
148
|
packageJson.types = types;
|
|
132
149
|
}
|
|
133
150
|
|
|
134
|
-
const bin = await createPackageBin({
|
|
135
|
-
bin: originalBin,
|
|
151
|
+
const bin = await createPackageBin(originalBin, {
|
|
136
152
|
bundles,
|
|
137
153
|
cwd,
|
|
138
154
|
isFlat,
|
|
@@ -228,6 +244,12 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
|
|
|
228
244
|
default: process.env.MUI_BUILD_FLAT === '1',
|
|
229
245
|
description:
|
|
230
246
|
'Builds the package in a flat structure without subdirectories for each module type.',
|
|
247
|
+
})
|
|
248
|
+
.option('expand', {
|
|
249
|
+
type: 'boolean',
|
|
250
|
+
default: true,
|
|
251
|
+
description:
|
|
252
|
+
'Enumerate glob patterns in the package.json "exports"/"imports" into concrete entries. Use --no-expand to keep them as Node runtime subpath patterns.',
|
|
231
253
|
});
|
|
232
254
|
},
|
|
233
255
|
async handler(args) {
|
|
@@ -416,6 +438,7 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
|
|
|
416
438
|
outputDir: buildDir,
|
|
417
439
|
addTypes: buildTypes,
|
|
418
440
|
isFlat: !!args.flat,
|
|
441
|
+
expand: args.expand,
|
|
419
442
|
packageType,
|
|
420
443
|
});
|
|
421
444
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import nextjs from '@next/eslint-plugin-next';
|
|
2
2
|
// TODO: change back to 'eslint/config' once https://github.com/eslint/rewrite/issues/425 is fixed
|
|
3
3
|
import { defineConfig } from '@eslint/config-helpers';
|
|
4
|
+
import { EXTENSION_TS } from './extensions.mjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @returns {import('eslint').Linter.Config[]}
|
|
@@ -25,7 +26,7 @@ export function createDocsConfig() {
|
|
|
25
26
|
rootDir: 'docs',
|
|
26
27
|
},
|
|
27
28
|
},
|
|
28
|
-
files: [
|
|
29
|
+
files: [`**/*${EXTENSION_TS}`],
|
|
29
30
|
rules: {
|
|
30
31
|
'compat/compat': 'off',
|
|
31
32
|
'jsx-a11y/anchor-is-valid': 'off',
|