@mui/internal-code-infra 0.0.3-canary.6 → 0.0.3-canary.7
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/package.json +2 -2
- package/src/babel-config.mjs +27 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-code-infra",
|
|
3
|
-
"version": "0.0.3-canary.
|
|
3
|
+
"version": "0.0.3-canary.7",
|
|
4
4
|
"description": "Infra scripts and configs to be used across MUI repos.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"gitSha": "
|
|
96
|
+
"gitSha": "509594de98a145e15241d136d9cd7b3fc4016f9a",
|
|
97
97
|
"scripts": {
|
|
98
98
|
"typescript": "tsc -p tsconfig.json",
|
|
99
99
|
"test": "pnpm -w test --project @mui/internal-code-infra",
|
package/src/babel-config.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import pluginRemovePropTypes from 'babel-plugin-transform-react-remove-prop-type
|
|
|
13
13
|
* @param {boolean} [param0.debug]
|
|
14
14
|
* @param {boolean} [param0.optimizeClsx]
|
|
15
15
|
* @param {boolean} [param0.removePropTypes]
|
|
16
|
-
* @param {boolean} [param0.
|
|
16
|
+
* @param {boolean} [param0.noResolveImports]
|
|
17
17
|
* @param {'cjs' | 'esm'} param0.bundle
|
|
18
18
|
* @param {string | null} param0.outExtension - Specify the output file extension.
|
|
19
19
|
* @param {string} param0.runtimeVersion
|
|
@@ -23,7 +23,7 @@ export function getBaseConfig({
|
|
|
23
23
|
debug = false,
|
|
24
24
|
optimizeClsx = false,
|
|
25
25
|
removePropTypes = false,
|
|
26
|
-
|
|
26
|
+
noResolveImports = false,
|
|
27
27
|
bundle,
|
|
28
28
|
runtimeVersion,
|
|
29
29
|
outExtension,
|
|
@@ -81,7 +81,7 @@ export function getBaseConfig({
|
|
|
81
81
|
plugins.push([pluginOptimizeClsx, {}, 'babel-plugin-optimize-clsx']);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
if (bundle === 'esm' && !
|
|
84
|
+
if (bundle === 'esm' && !noResolveImports) {
|
|
85
85
|
plugins.push([
|
|
86
86
|
pluginResolveImports,
|
|
87
87
|
{ outExtension },
|
|
@@ -119,20 +119,39 @@ export function getBaseConfig({
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* @
|
|
122
|
+
* @typedef {Object} Options
|
|
123
|
+
* @prop {'esm' | 'cjs'} [Options.bundle]
|
|
124
|
+
* @prop {boolean} [Options.noResolveImports]
|
|
125
|
+
* @prop {undefined} [options.env]
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @param {import('@babel/core').ConfigAPI | Options} api
|
|
130
|
+
* @returns {import('@babel/core').TransformOptions}
|
|
123
131
|
*/
|
|
124
132
|
export default function getBabelConfig(api) {
|
|
125
|
-
|
|
126
|
-
|
|
133
|
+
/** @type {'esm' | 'cjs'} */
|
|
134
|
+
let bundle;
|
|
135
|
+
/** @type {boolean} */
|
|
136
|
+
let noResolveImports;
|
|
137
|
+
|
|
138
|
+
if (api.env) {
|
|
139
|
+
// legacy
|
|
140
|
+
bundle = api.env(['regressions', 'stable']) ? 'esm' : 'cjs';
|
|
141
|
+
noResolveImports = api.env('test') || process.env.NODE_ENV === 'test';
|
|
142
|
+
} else {
|
|
143
|
+
bundle = api.bundle || 'esm';
|
|
144
|
+
noResolveImports = api.noResolveImports || false;
|
|
145
|
+
}
|
|
127
146
|
|
|
128
147
|
return getBaseConfig({
|
|
129
148
|
debug: process.env.MUI_BUILD_VERBOSE === 'true',
|
|
130
|
-
bundle
|
|
149
|
+
bundle,
|
|
131
150
|
outExtension: process.env.MUI_OUT_FILE_EXTENSION || null,
|
|
132
151
|
// any package needs to declare 7.25.0 as a runtime dependency. default is ^7.0.0
|
|
133
152
|
runtimeVersion: process.env.MUI_BABEL_RUNTIME_VERSION || '^7.25.0',
|
|
134
153
|
optimizeClsx: process.env.MUI_OPTIMIZE_CLSX === 'true',
|
|
135
154
|
removePropTypes: process.env.MUI_REMOVE_PROP_TYPES === 'true',
|
|
136
|
-
|
|
155
|
+
noResolveImports,
|
|
137
156
|
});
|
|
138
157
|
}
|