@sse-ui/builder 1.0.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.
- package/bin/sse-tools.js +2 -0
- package/package.json +53 -0
- package/src/babel-config.ts +189 -0
- package/src/cli.ts +44 -0
- package/src/config.ts +10 -0
- package/src/core/build.ts +621 -0
- package/src/core/check-exports.ts +88 -0
- package/src/core/clean.ts +32 -0
- package/src/core/info.ts +65 -0
- package/src/core/link.ts +44 -0
- package/src/core/pack.ts +43 -0
- package/src/core/packageJson.d.ts +740 -0
- package/src/core/publish.ts +96 -0
- package/src/core/typecheck.ts +28 -0
- package/src/core/version.ts +45 -0
- package/src/core/watch.ts +50 -0
- package/src/untyped-plugins.d.ts +66 -0
- package/src/utils/babel.ts +167 -0
- package/src/utils/build.ts +609 -0
- package/src/utils/loadConfig.ts +22 -0
- package/src/utils/typescript.ts +330 -0
- package/tsconfig.json +18 -0
- package/tsup.config.ts +9 -0
package/bin/sse-tools.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sse-ui/builder",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Builder By SSE",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsup",
|
|
8
|
+
"prepublish": "npm run build"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"@sse-ui/builder": "./bin/sse-tools.js"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
"./babel-config": {
|
|
15
|
+
"import": "./dist/babel-config.js",
|
|
16
|
+
"types": "./dist/babel-config.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./config": {
|
|
19
|
+
"import": "./dist/config.js",
|
|
20
|
+
"types": "./dist/config.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"author": "SSE World",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/babel__core": "^7.20.5",
|
|
27
|
+
"@types/node": "^25.4.0",
|
|
28
|
+
"@types/resolve": "^1.20.6",
|
|
29
|
+
"@types/semver": "^7.7.1",
|
|
30
|
+
"tsup": "^8.5.1",
|
|
31
|
+
"typescript": "^5.9.3"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@babel/cli": "^7.28.6",
|
|
35
|
+
"@babel/core": "^7.29.0",
|
|
36
|
+
"@babel/preset-react": "^7.28.5",
|
|
37
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
38
|
+
"@ssets/babel": "*",
|
|
39
|
+
"babel-plugin-optimize-clsx": "^2.6.2",
|
|
40
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
41
|
+
"babel-plugin-transform-import-meta": "^2.3.3",
|
|
42
|
+
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
|
|
43
|
+
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
44
|
+
"c12": "^4.0.0-beta.3",
|
|
45
|
+
"commander": "^14.0.3",
|
|
46
|
+
"execa": "^9.6.1",
|
|
47
|
+
"find-workspaces": "^0.3.1",
|
|
48
|
+
"globby": "^16.1.1",
|
|
49
|
+
"minimatch": "^10.2.4",
|
|
50
|
+
"mismatch": "^1.2.0",
|
|
51
|
+
"semver": "^7.7.4"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import pluginTransformRuntime from "@ssets/babel/plugin/transform-runtime";
|
|
2
|
+
import presetEnv, { Options as EnvOptions } from "@ssets/babel/preset/env";
|
|
3
|
+
import presetReact from "@babel/preset-react";
|
|
4
|
+
import presetTypescript from "@babel/preset-typescript";
|
|
5
|
+
import pluginDisplayName from "@ssets/babel/plugin/display-name";
|
|
6
|
+
import pluginResolveImports from "@ssets/babel/plugin/resolve-imports";
|
|
7
|
+
import pluginOptimizeClsx from "babel-plugin-optimize-clsx";
|
|
8
|
+
import pluginReactCompiler, {
|
|
9
|
+
PluginOptions as BabelReactPluginOptions,
|
|
10
|
+
} from "babel-plugin-react-compiler";
|
|
11
|
+
import pluginTransformImportMeta from "babel-plugin-transform-import-meta";
|
|
12
|
+
import pluginTransformInlineEnvVars from "babel-plugin-transform-inline-environment-variables";
|
|
13
|
+
import pluginRemovePropTypes from "babel-plugin-transform-react-remove-prop-types";
|
|
14
|
+
import { BundleType } from "./utils/build";
|
|
15
|
+
import { TransformOptions, ConfigAPI } from "@babel/core";
|
|
16
|
+
|
|
17
|
+
interface GetBaseConfigOptions {
|
|
18
|
+
debug: boolean;
|
|
19
|
+
optimizeClsx: boolean;
|
|
20
|
+
removePropTypes: boolean;
|
|
21
|
+
noResolveImports: boolean;
|
|
22
|
+
bundle: BundleType;
|
|
23
|
+
outExtension: string | null;
|
|
24
|
+
runtimeVersion: string;
|
|
25
|
+
reactCompilerReactVersion?: string;
|
|
26
|
+
reactCompilerMode?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getBaseConfig({
|
|
30
|
+
debug = false,
|
|
31
|
+
optimizeClsx = false,
|
|
32
|
+
removePropTypes = false,
|
|
33
|
+
noResolveImports = false,
|
|
34
|
+
bundle,
|
|
35
|
+
runtimeVersion,
|
|
36
|
+
outExtension,
|
|
37
|
+
reactCompilerReactVersion,
|
|
38
|
+
reactCompilerMode,
|
|
39
|
+
}: GetBaseConfigOptions): TransformOptions {
|
|
40
|
+
const presetEnvOptions: EnvOptions = {
|
|
41
|
+
bugfixes: true,
|
|
42
|
+
debug,
|
|
43
|
+
modules: bundle === "esm" ? false : "commonjs",
|
|
44
|
+
// @TODO
|
|
45
|
+
browserslistEnv: bundle === "esm" ? "stable" : "node",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const plugins: TransformOptions["plugins"] = [
|
|
49
|
+
[
|
|
50
|
+
pluginTransformRuntime,
|
|
51
|
+
{
|
|
52
|
+
version: runtimeVersion,
|
|
53
|
+
regenerator: false,
|
|
54
|
+
useESModules: bundle === "esm",
|
|
55
|
+
},
|
|
56
|
+
"@babel/plugin-transform-runtime",
|
|
57
|
+
],
|
|
58
|
+
[pluginDisplayName, {}, "babel-plugin-display-name"],
|
|
59
|
+
[
|
|
60
|
+
pluginTransformInlineEnvVars,
|
|
61
|
+
{
|
|
62
|
+
include: [
|
|
63
|
+
"MUI_VERSION",
|
|
64
|
+
"MUI_MAJOR_VERSION",
|
|
65
|
+
"MUI_MINOR_VERSION",
|
|
66
|
+
"MUI_PATCH_VERSION",
|
|
67
|
+
"MUI_PRERELEASE",
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
"babel-plugin-transform-inline-environment-variables",
|
|
71
|
+
],
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
if (bundle !== "esm") {
|
|
75
|
+
plugins.push([
|
|
76
|
+
pluginTransformImportMeta,
|
|
77
|
+
{},
|
|
78
|
+
"babel-plugin-transform-import-meta",
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (reactCompilerReactVersion) {
|
|
83
|
+
const reactCompilerOptions: BabelReactPluginOptions = {
|
|
84
|
+
// comes from the package's peerDependencies
|
|
85
|
+
target: reactCompilerReactVersion.split(
|
|
86
|
+
".",
|
|
87
|
+
)[0] as BabelReactPluginOptions["target"],
|
|
88
|
+
enableReanimatedCheck: false,
|
|
89
|
+
compilationMode: reactCompilerMode ?? "annotation",
|
|
90
|
+
// Skip components with errors instead of failing the build
|
|
91
|
+
panicThreshold: "none",
|
|
92
|
+
};
|
|
93
|
+
// The plugin must be the first one to run
|
|
94
|
+
plugins.unshift([
|
|
95
|
+
pluginReactCompiler,
|
|
96
|
+
reactCompilerOptions,
|
|
97
|
+
"babel-plugin-react-compiler",
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (removePropTypes) {
|
|
102
|
+
plugins.push([
|
|
103
|
+
pluginRemovePropTypes,
|
|
104
|
+
{
|
|
105
|
+
mode: "unsafe-wrap",
|
|
106
|
+
},
|
|
107
|
+
"babel-plugin-transform-react-remove-prop-types",
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (optimizeClsx) {
|
|
112
|
+
plugins.push([pluginOptimizeClsx, {}, "babel-plugin-optimize-clsx"]);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (bundle === "esm" && !noResolveImports) {
|
|
116
|
+
plugins.push([
|
|
117
|
+
pluginResolveImports,
|
|
118
|
+
{ outExtension },
|
|
119
|
+
"babel-plugin-resolve-imports",
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
assumptions: {
|
|
125
|
+
noDocumentAll: true,
|
|
126
|
+
// With our case these assumptions are safe, and the
|
|
127
|
+
// resulting behavior is equivalent to spec mode.
|
|
128
|
+
setPublicClassFields: true,
|
|
129
|
+
privateFieldsAsProperties: true,
|
|
130
|
+
objectRestNoSymbols: true,
|
|
131
|
+
setSpreadProperties: true,
|
|
132
|
+
},
|
|
133
|
+
ignore: [
|
|
134
|
+
// Fix a Windows issue.
|
|
135
|
+
/@babel[\\|/]runtime/,
|
|
136
|
+
// Fix const foo = /{{(.+?)}}/gs; crashing.
|
|
137
|
+
/prettier/,
|
|
138
|
+
"**/*.template.js",
|
|
139
|
+
],
|
|
140
|
+
presets: [
|
|
141
|
+
[presetEnv, presetEnvOptions],
|
|
142
|
+
[
|
|
143
|
+
presetReact,
|
|
144
|
+
{
|
|
145
|
+
runtime: "automatic",
|
|
146
|
+
useBuiltIns: bundle === "esm",
|
|
147
|
+
useSpread: bundle === "esm",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
[presetTypescript],
|
|
151
|
+
],
|
|
152
|
+
plugins,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
interface GetBabelConfigOptions {
|
|
157
|
+
bundle: BundleType;
|
|
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
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { buildCommand } from "./core/build";
|
|
4
|
+
import { publishCommand } from "./core/publish";
|
|
5
|
+
import { cleanCommand } from "./core/clean";
|
|
6
|
+
import { typecheckCommand } from "./core/typecheck";
|
|
7
|
+
import { packCommand } from "./core/pack";
|
|
8
|
+
import { versionCommand } from "./core/version";
|
|
9
|
+
import { infoCommand } from "./core/info";
|
|
10
|
+
import { linkCommand } from "./core/link";
|
|
11
|
+
import { checkExportsCommand } from "./core/check-exports";
|
|
12
|
+
import { watchCommand } from "./core/watch";
|
|
13
|
+
|
|
14
|
+
async function main() {
|
|
15
|
+
const program = new Command();
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.name("sse-tools")
|
|
19
|
+
.description("CLI utilities for managing and building MUI packages")
|
|
20
|
+
.version("1.0.0");
|
|
21
|
+
|
|
22
|
+
program.addCommand(buildCommand);
|
|
23
|
+
program.addCommand(publishCommand);
|
|
24
|
+
program.addCommand(cleanCommand);
|
|
25
|
+
program.addCommand(typecheckCommand);
|
|
26
|
+
program.addCommand(packCommand);
|
|
27
|
+
program.addCommand(versionCommand);
|
|
28
|
+
program.addCommand(infoCommand);
|
|
29
|
+
program.addCommand(linkCommand);
|
|
30
|
+
program.addCommand(checkExportsCommand);
|
|
31
|
+
program.addCommand(watchCommand);
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
await program.parseAsync(process.argv);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error("Error executing command:");
|
|
37
|
+
if (error instanceof Error) {
|
|
38
|
+
console.error(error.message);
|
|
39
|
+
}
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
main();
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BuildOptions } from "./core/build";
|
|
2
|
+
|
|
3
|
+
export type { BuildOptions };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Helper to provide autocomplete and type checking for the sse-tools config.
|
|
7
|
+
*/
|
|
8
|
+
export function defineConfig(config: BuildOptions): BuildOptions {
|
|
9
|
+
return config;
|
|
10
|
+
}
|