@sse-ui/builder 1.0.0 → 1.0.2
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/dist/babel-VTL3CZAT.js +110 -0
- package/dist/babel-config.d.ts +23 -0
- package/{src/babel-config.ts → dist/babel-config.js} +157 -189
- package/dist/build-DZbrXe0V.d.ts +3 -0
- package/{src/utils/build.ts → dist/chunk-5S2N5WDQ.js} +401 -609
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +2628 -0
- package/dist/config.d.ts +39 -0
- package/dist/config.js +7 -0
- package/dist/typescript-CS6YZCMJ.js +217 -0
- package/package.json +4 -2
- package/src/cli.ts +0 -44
- package/src/config.ts +0 -10
- package/src/core/build.ts +0 -621
- package/src/core/check-exports.ts +0 -88
- package/src/core/clean.ts +0 -32
- package/src/core/info.ts +0 -65
- package/src/core/link.ts +0 -44
- package/src/core/pack.ts +0 -43
- package/src/core/packageJson.d.ts +0 -740
- package/src/core/publish.ts +0 -96
- package/src/core/typecheck.ts +0 -28
- package/src/core/version.ts +0 -45
- package/src/core/watch.ts +0 -50
- package/src/untyped-plugins.d.ts +0 -66
- package/src/utils/babel.ts +0 -167
- package/src/utils/loadConfig.ts +0 -22
- package/src/utils/typescript.ts +0 -330
- package/tsconfig.json +0 -18
- package/tsup.config.ts +0 -9
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BASE_IGNORES
|
|
3
|
+
} from "./chunk-5S2N5WDQ.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/babel.ts
|
|
6
|
+
import { findWorkspacesRoot } from "find-workspaces";
|
|
7
|
+
import { $ } from "execa";
|
|
8
|
+
import { globby } from "globby";
|
|
9
|
+
import * as fs from "fs/promises";
|
|
10
|
+
import * as path from "path";
|
|
11
|
+
var TO_TRANSFORM_EXTENSIONS = [".js", ".ts", ".tsx"];
|
|
12
|
+
function getVersionEnvVariables(pkgVersion) {
|
|
13
|
+
if (!pkgVersion) {
|
|
14
|
+
throw new Error("No version found in package.json");
|
|
15
|
+
}
|
|
16
|
+
const [versionNumber, prerelease] = pkgVersion.split("-");
|
|
17
|
+
const [major, minor, patch] = versionNumber.split(".");
|
|
18
|
+
if (!major || !minor || !patch) {
|
|
19
|
+
throw new Error(`Couldn't parse version from package.json`);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
MUI_VERSION: pkgVersion,
|
|
23
|
+
MUI_MAJOR_VERSION: major,
|
|
24
|
+
MUI_MINOR_VERSION: minor,
|
|
25
|
+
MUI_PATCH_VERSION: patch,
|
|
26
|
+
MUI_PRERELEASE: prerelease
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function cjsCopy({ from, to }) {
|
|
30
|
+
const exists = await fs.stat(to).then(() => true).catch(() => false);
|
|
31
|
+
if (!exists) {
|
|
32
|
+
console.warn(`path ${to} does not exists`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const files = await globby("**/*.cjs", { cwd: from });
|
|
36
|
+
const cmds = files.map(
|
|
37
|
+
(file) => fs.cp(path.resolve(from, file), path.resolve(to, file))
|
|
38
|
+
);
|
|
39
|
+
await Promise.all(cmds);
|
|
40
|
+
}
|
|
41
|
+
async function build({
|
|
42
|
+
cwd,
|
|
43
|
+
sourceDir,
|
|
44
|
+
outDir,
|
|
45
|
+
babelRuntimeVersion,
|
|
46
|
+
hasLargeFiles,
|
|
47
|
+
bundle,
|
|
48
|
+
pkgVersion,
|
|
49
|
+
outExtension,
|
|
50
|
+
optimizeClsx = false,
|
|
51
|
+
removePropTypes = false,
|
|
52
|
+
verbose = false,
|
|
53
|
+
ignores = [],
|
|
54
|
+
reactCompiler
|
|
55
|
+
}) {
|
|
56
|
+
console.log(
|
|
57
|
+
`Transpiling files to "${path.relative(path.dirname(sourceDir), outDir)}" for "${bundle}" bundle.`
|
|
58
|
+
);
|
|
59
|
+
const workspaceDir = await findWorkspacesRoot(cwd);
|
|
60
|
+
const rootDir = workspaceDir ? workspaceDir.location : cwd;
|
|
61
|
+
let configFile = path.join(rootDir, "babel.config.js");
|
|
62
|
+
const exists = await fs.stat(configFile).then(() => true).catch(() => false);
|
|
63
|
+
if (!exists) {
|
|
64
|
+
configFile = path.join(rootDir, "babel.config.mjs");
|
|
65
|
+
}
|
|
66
|
+
const reactVersion = reactCompiler?.reactVersion;
|
|
67
|
+
const env = {
|
|
68
|
+
NODE_ENV: "production",
|
|
69
|
+
BABEL_ENV: bundle === "esm" ? "stable" : "node",
|
|
70
|
+
MUI_BUILD_VERBOSE: verbose ? "true" : void 0,
|
|
71
|
+
MUI_OPTIMIZE_CLSX: optimizeClsx ? "true" : void 0,
|
|
72
|
+
MUI_REMOVE_PROP_TYPES: removePropTypes ? "true" : void 0,
|
|
73
|
+
MUI_BABEL_RUNTIME_VERSION: babelRuntimeVersion,
|
|
74
|
+
MUI_OUT_FILE_EXTENSION: outExtension ?? ".js",
|
|
75
|
+
...getVersionEnvVariables(pkgVersion),
|
|
76
|
+
MUI_REACT_COMPILER: reactVersion ? "1" : "0",
|
|
77
|
+
MUI_REACT_COMPILER_REACT_VERSION: reactVersion
|
|
78
|
+
};
|
|
79
|
+
const resolvedOutExtension = outExtension ?? ".js";
|
|
80
|
+
const res = await $({
|
|
81
|
+
stdio: "inherit",
|
|
82
|
+
preferLocal: true,
|
|
83
|
+
localDir: import.meta.dirname,
|
|
84
|
+
env: {
|
|
85
|
+
...process.env,
|
|
86
|
+
...env
|
|
87
|
+
}
|
|
88
|
+
})`babel --config-file ${configFile} --extensions ${TO_TRANSFORM_EXTENSIONS.join(
|
|
89
|
+
","
|
|
90
|
+
)} ${sourceDir} --out-dir ${outDir} --ignore ${BASE_IGNORES.concat(
|
|
91
|
+
ignores
|
|
92
|
+
).join(",")} --out-file-extension ${resolvedOutExtension !== ".js" ? resolvedOutExtension : ".js"} --compact ${hasLargeFiles ? "false" : "auto"}`;
|
|
93
|
+
if (res.stderr) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
`Command: '${res.escapedCommand}' failed with
|
|
96
|
+
${res.stderr}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (verbose) {
|
|
100
|
+
console.log(
|
|
101
|
+
`Command: '${res.escapedCommand}' succeeded with
|
|
102
|
+
${res.stdout}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
build,
|
|
108
|
+
cjsCopy,
|
|
109
|
+
getVersionEnvVariables
|
|
110
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { B as BundleType } from './build-DZbrXe0V.js';
|
|
2
|
+
import { ConfigAPI, TransformOptions } from '@babel/core';
|
|
3
|
+
|
|
4
|
+
interface GetBaseConfigOptions {
|
|
5
|
+
debug: boolean;
|
|
6
|
+
optimizeClsx: boolean;
|
|
7
|
+
removePropTypes: boolean;
|
|
8
|
+
noResolveImports: boolean;
|
|
9
|
+
bundle: BundleType;
|
|
10
|
+
outExtension: string | null;
|
|
11
|
+
runtimeVersion: string;
|
|
12
|
+
reactCompilerReactVersion?: string;
|
|
13
|
+
reactCompilerMode?: string;
|
|
14
|
+
}
|
|
15
|
+
declare function getBaseConfig({ debug, optimizeClsx, removePropTypes, noResolveImports, bundle, runtimeVersion, outExtension, reactCompilerReactVersion, reactCompilerMode, }: GetBaseConfigOptions): TransformOptions;
|
|
16
|
+
interface GetBabelConfigOptions {
|
|
17
|
+
bundle: BundleType;
|
|
18
|
+
noResolveImports: boolean;
|
|
19
|
+
env: any;
|
|
20
|
+
}
|
|
21
|
+
declare function getBabelConfig(api: ConfigAPI | GetBabelConfigOptions): TransformOptions;
|
|
22
|
+
|
|
23
|
+
export { getBabelConfig as default, getBaseConfig };
|
|
@@ -1,189 +1,157 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
noResolveImports: boolean;
|
|
159
|
-
env: any;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export default function getBabelConfig(
|
|
163
|
-
api: ConfigAPI | GetBabelConfigOptions,
|
|
164
|
-
): TransformOptions {
|
|
165
|
-
let bundle: BundleType;
|
|
166
|
-
let noResolveImports: boolean;
|
|
167
|
-
|
|
168
|
-
if (api.env) {
|
|
169
|
-
// legacy
|
|
170
|
-
bundle = api.env(["regressions", "stable"]) ? "esm" : "cjs";
|
|
171
|
-
noResolveImports = api.env("test") || process.env.NODE_ENV === "test";
|
|
172
|
-
} else {
|
|
173
|
-
bundle = (api as GetBabelConfigOptions).bundle || "esm";
|
|
174
|
-
noResolveImports = (api as GetBabelConfigOptions).noResolveImports || false;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return getBaseConfig({
|
|
178
|
-
debug: process.env.MUI_BUILD_VERBOSE === "true",
|
|
179
|
-
bundle,
|
|
180
|
-
outExtension: process.env.MUI_OUT_FILE_EXTENSION || null,
|
|
181
|
-
// any package needs to declare 7.25.0 as a runtime dependency. default is ^7.0.0
|
|
182
|
-
runtimeVersion: process.env.MUI_BABEL_RUNTIME_VERSION || "^7.25.0",
|
|
183
|
-
optimizeClsx: process.env.MUI_OPTIMIZE_CLSX === "true",
|
|
184
|
-
removePropTypes: process.env.MUI_REMOVE_PROP_TYPES === "true",
|
|
185
|
-
noResolveImports,
|
|
186
|
-
reactCompilerReactVersion: process.env.MUI_REACT_COMPILER_REACT_VERSION,
|
|
187
|
-
reactCompilerMode: process.env.MUI_REACT_COMPILER_MODE,
|
|
188
|
-
});
|
|
189
|
-
}
|
|
1
|
+
// src/babel-config.ts
|
|
2
|
+
import pluginTransformRuntime from "@ssets/babel/plugin/transform-runtime";
|
|
3
|
+
import presetEnv from "@ssets/babel/preset/env";
|
|
4
|
+
import presetReact from "@babel/preset-react";
|
|
5
|
+
import presetTypescript from "@babel/preset-typescript";
|
|
6
|
+
import pluginDisplayName from "@ssets/babel/plugin/display-name";
|
|
7
|
+
import pluginResolveImports from "@ssets/babel/plugin/resolve-imports";
|
|
8
|
+
import pluginOptimizeClsx from "babel-plugin-optimize-clsx";
|
|
9
|
+
import pluginReactCompiler from "babel-plugin-react-compiler";
|
|
10
|
+
import pluginTransformImportMeta from "babel-plugin-transform-import-meta";
|
|
11
|
+
import pluginTransformInlineEnvVars from "babel-plugin-transform-inline-environment-variables";
|
|
12
|
+
import pluginRemovePropTypes from "babel-plugin-transform-react-remove-prop-types";
|
|
13
|
+
function getBaseConfig({
|
|
14
|
+
debug = false,
|
|
15
|
+
optimizeClsx = false,
|
|
16
|
+
removePropTypes = false,
|
|
17
|
+
noResolveImports = false,
|
|
18
|
+
bundle,
|
|
19
|
+
runtimeVersion,
|
|
20
|
+
outExtension,
|
|
21
|
+
reactCompilerReactVersion,
|
|
22
|
+
reactCompilerMode
|
|
23
|
+
}) {
|
|
24
|
+
const presetEnvOptions = {
|
|
25
|
+
bugfixes: true,
|
|
26
|
+
debug,
|
|
27
|
+
modules: bundle === "esm" ? false : "commonjs",
|
|
28
|
+
// @TODO
|
|
29
|
+
browserslistEnv: bundle === "esm" ? "stable" : "node"
|
|
30
|
+
};
|
|
31
|
+
const plugins = [
|
|
32
|
+
[
|
|
33
|
+
pluginTransformRuntime,
|
|
34
|
+
{
|
|
35
|
+
version: runtimeVersion,
|
|
36
|
+
regenerator: false,
|
|
37
|
+
useESModules: bundle === "esm"
|
|
38
|
+
},
|
|
39
|
+
"@babel/plugin-transform-runtime"
|
|
40
|
+
],
|
|
41
|
+
[pluginDisplayName, {}, "babel-plugin-display-name"],
|
|
42
|
+
[
|
|
43
|
+
pluginTransformInlineEnvVars,
|
|
44
|
+
{
|
|
45
|
+
include: [
|
|
46
|
+
"MUI_VERSION",
|
|
47
|
+
"MUI_MAJOR_VERSION",
|
|
48
|
+
"MUI_MINOR_VERSION",
|
|
49
|
+
"MUI_PATCH_VERSION",
|
|
50
|
+
"MUI_PRERELEASE"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"babel-plugin-transform-inline-environment-variables"
|
|
54
|
+
]
|
|
55
|
+
];
|
|
56
|
+
if (bundle !== "esm") {
|
|
57
|
+
plugins.push([
|
|
58
|
+
pluginTransformImportMeta,
|
|
59
|
+
{},
|
|
60
|
+
"babel-plugin-transform-import-meta"
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
if (reactCompilerReactVersion) {
|
|
64
|
+
const reactCompilerOptions = {
|
|
65
|
+
// comes from the package's peerDependencies
|
|
66
|
+
target: reactCompilerReactVersion.split(
|
|
67
|
+
"."
|
|
68
|
+
)[0],
|
|
69
|
+
enableReanimatedCheck: false,
|
|
70
|
+
compilationMode: reactCompilerMode ?? "annotation",
|
|
71
|
+
// Skip components with errors instead of failing the build
|
|
72
|
+
panicThreshold: "none"
|
|
73
|
+
};
|
|
74
|
+
plugins.unshift([
|
|
75
|
+
pluginReactCompiler,
|
|
76
|
+
reactCompilerOptions,
|
|
77
|
+
"babel-plugin-react-compiler"
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
if (removePropTypes) {
|
|
81
|
+
plugins.push([
|
|
82
|
+
pluginRemovePropTypes,
|
|
83
|
+
{
|
|
84
|
+
mode: "unsafe-wrap"
|
|
85
|
+
},
|
|
86
|
+
"babel-plugin-transform-react-remove-prop-types"
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
if (optimizeClsx) {
|
|
90
|
+
plugins.push([pluginOptimizeClsx, {}, "babel-plugin-optimize-clsx"]);
|
|
91
|
+
}
|
|
92
|
+
if (bundle === "esm" && !noResolveImports) {
|
|
93
|
+
plugins.push([
|
|
94
|
+
pluginResolveImports,
|
|
95
|
+
{ outExtension },
|
|
96
|
+
"babel-plugin-resolve-imports"
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
assumptions: {
|
|
101
|
+
noDocumentAll: true,
|
|
102
|
+
// With our case these assumptions are safe, and the
|
|
103
|
+
// resulting behavior is equivalent to spec mode.
|
|
104
|
+
setPublicClassFields: true,
|
|
105
|
+
privateFieldsAsProperties: true,
|
|
106
|
+
objectRestNoSymbols: true,
|
|
107
|
+
setSpreadProperties: true
|
|
108
|
+
},
|
|
109
|
+
ignore: [
|
|
110
|
+
// Fix a Windows issue.
|
|
111
|
+
/@babel[\\|/]runtime/,
|
|
112
|
+
// Fix const foo = /{{(.+?)}}/gs; crashing.
|
|
113
|
+
/prettier/,
|
|
114
|
+
"**/*.template.js"
|
|
115
|
+
],
|
|
116
|
+
presets: [
|
|
117
|
+
[presetEnv, presetEnvOptions],
|
|
118
|
+
[
|
|
119
|
+
presetReact,
|
|
120
|
+
{
|
|
121
|
+
runtime: "automatic",
|
|
122
|
+
useBuiltIns: bundle === "esm",
|
|
123
|
+
useSpread: bundle === "esm"
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
[presetTypescript]
|
|
127
|
+
],
|
|
128
|
+
plugins
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function getBabelConfig(api) {
|
|
132
|
+
let bundle;
|
|
133
|
+
let noResolveImports;
|
|
134
|
+
if (api.env) {
|
|
135
|
+
bundle = api.env(["regressions", "stable"]) ? "esm" : "cjs";
|
|
136
|
+
noResolveImports = api.env("test") || process.env.NODE_ENV === "test";
|
|
137
|
+
} else {
|
|
138
|
+
bundle = api.bundle || "esm";
|
|
139
|
+
noResolveImports = api.noResolveImports || false;
|
|
140
|
+
}
|
|
141
|
+
return getBaseConfig({
|
|
142
|
+
debug: process.env.MUI_BUILD_VERBOSE === "true",
|
|
143
|
+
bundle,
|
|
144
|
+
outExtension: process.env.MUI_OUT_FILE_EXTENSION || null,
|
|
145
|
+
// any package needs to declare 7.25.0 as a runtime dependency. default is ^7.0.0
|
|
146
|
+
runtimeVersion: process.env.MUI_BABEL_RUNTIME_VERSION || "^7.25.0",
|
|
147
|
+
optimizeClsx: process.env.MUI_OPTIMIZE_CLSX === "true",
|
|
148
|
+
removePropTypes: process.env.MUI_REMOVE_PROP_TYPES === "true",
|
|
149
|
+
noResolveImports,
|
|
150
|
+
reactCompilerReactVersion: process.env.MUI_REACT_COMPILER_REACT_VERSION,
|
|
151
|
+
reactCompilerMode: process.env.MUI_REACT_COMPILER_MODE
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
getBabelConfig as default,
|
|
156
|
+
getBaseConfig
|
|
157
|
+
};
|