@sse-ui/builder 1.3.0 → 1.3.1
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/README.md +76 -0
- package/dist/{babel-6NHCDM3A.js → babel-2PBTAJV6.js} +0 -1
- package/dist/babel-config.js +0 -2
- package/dist/cli.js +2 -3
- package/dist/config.js +0 -2
- package/dist/typescript-2XUZHHI2.js +286 -0
- package/package.json +2 -3
- package/dist/acorn-RZKYEOCN.js +0 -3130
- package/dist/angular-65ZVA2AO.js +0 -3070
- package/dist/babel-6NAC7UZ3.js +0 -7296
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/estree-SLPC3MKU.js +0 -4612
- package/dist/flow-JKSA2WQA.js +0 -27546
- package/dist/glimmer-KH4FHVWK.js +0 -2894
- package/dist/graphql-X7RDVKKC.js +0 -1266
- package/dist/html-A2DZMMEZ.js +0 -2933
- package/dist/markdown-35RS3VXW.js +0 -3553
- package/dist/meriyah-UIMGFPH2.js +0 -2684
- package/dist/postcss-CITECRUH.js +0 -5080
- package/dist/typescript-42L4XZEH.js +0 -20538
- package/dist/typescript-CFZSZQGQ.js +0 -13203
- package/dist/yaml-RAY3ED75.js +0 -4224
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @sse-ui/builder (sse-tools)
|
|
2
|
+
|
|
3
|
+
`sse-tools` is a high-performance CLI utility designed for managing, building, and publishing software packages within the SSE ecosystem. It provides a unified interface for library development, supporting both Babel for individual file transpilation and esbuild for high-speed bundling.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- **Hybrid Builder Engine**: Seamlessly switch between Babel for detailed transpilation or esbuild for rapid bundling via simple configuration.
|
|
8
|
+
- **Vite-style Watch Mode**: Features an incremental watcher that rebuilds only the specific files you change, significantly speeding up development loops.
|
|
9
|
+
- **Intelligent Export Management**: Automatically generates and optimizes your package.json exports field based on your build output, supporting both flat and nested structures.
|
|
10
|
+
- **TypeScript-First**: Built-in support for generating and bundling .d.ts declaration files using either standard tsc or the high-performance tsgo compiler.
|
|
11
|
+
- **React Compiler Support**: Integrated support for the React compiler, including automatic environment configuration and peer-dependency validation.
|
|
12
|
+
- **Interactive Versioning**: A CLI-guided versioning system that helps you bump package versions safely using SemVer standards.
|
|
13
|
+
|
|
14
|
+
## 🚀 Installation
|
|
15
|
+
|
|
16
|
+
Install the package as a development dependency:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install --save-dev @sse-ui/builder
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 🛠 Usage
|
|
23
|
+
|
|
24
|
+
Once installed, you can access the utility via the `sse-tools` command.
|
|
25
|
+
|
|
26
|
+
### Core Commands
|
|
27
|
+
|
|
28
|
+
| Command | Description |
|
|
29
|
+
| --------------- | ------------------------------------------------------------------------------------ |
|
|
30
|
+
| `build` | Compiles the package for production using Babel or esbuild. |
|
|
31
|
+
| `watch` | Starts an incremental rebuild watcher for rapid development. |
|
|
32
|
+
| `typecheck` | Validates TypeScript types across the project without emitting files. |
|
|
33
|
+
| `check-exports` | Verifies that all files declared in package.json actually exist in the build folder. |
|
|
34
|
+
| `version` | Interactively bumps the package version (patch, minor, major). |
|
|
35
|
+
| `publish` | Publishes the built package directly from your specified build directory. |
|
|
36
|
+
| `info` | Displays size and file statistics for your built package. |
|
|
37
|
+
| `clean` | Safely removes the build directory to ensure a fresh start. |
|
|
38
|
+
|
|
39
|
+
## ⚙️ Configuration
|
|
40
|
+
|
|
41
|
+
`sse-tools` uses `c12` for robust configuration loading. You can define your configuration in `sse.config.ts`, `sse.config.js`, or within your `package.json`.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { defineConfig } from "@sse-ui/builder/config";
|
|
45
|
+
|
|
46
|
+
export default defineConfig({
|
|
47
|
+
bundle: ["esm", "cjs"],
|
|
48
|
+
buildTypes: true,
|
|
49
|
+
flat: false,
|
|
50
|
+
|
|
51
|
+
// Use esbuild for bundling single files
|
|
52
|
+
esbuild: {
|
|
53
|
+
entry: "src/index.ts",
|
|
54
|
+
target: "es2022",
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Build Options
|
|
60
|
+
|
|
61
|
+
- `bundle`: Specify output formats, such as `["esm", "cjs"]`.
|
|
62
|
+
- `flat`: When enabled, builds a flat structure instead of using format-specific subdirectories.
|
|
63
|
+
- `copy`: Define an array of glob patterns to copy static assets or documentation into the build folder.
|
|
64
|
+
- `tsgo`: Toggle between `tsc` and `tsgo` for faster type generation.
|
|
65
|
+
|
|
66
|
+
## Docs
|
|
67
|
+
|
|
68
|
+
Go to the Docs [click here](./docs)
|
|
69
|
+
|
|
70
|
+
## Example
|
|
71
|
+
|
|
72
|
+
Go to the Example [Click Here](./example)
|
|
73
|
+
|
|
74
|
+
## 📄 License
|
|
75
|
+
|
|
76
|
+
This project is licensed under the `MIT` License.
|
package/dist/babel-config.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
validatePkgJson,
|
|
10
10
|
writePackageJson
|
|
11
11
|
} from "./chunk-N46AJ2OI.js";
|
|
12
|
-
import "./chunk-MLKGABMK.js";
|
|
13
12
|
|
|
14
13
|
// src/cli.ts
|
|
15
14
|
import chalk11 from "chalk";
|
|
@@ -248,7 +247,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
248
247
|
} else {
|
|
249
248
|
if (isVerbose)
|
|
250
249
|
console.log(chalk.green("\u{1F4E6} Transpiling package via Babel..."));
|
|
251
|
-
const { build: babelBuild, cjsCopy } = await import("./babel-
|
|
250
|
+
const { build: babelBuild, cjsCopy } = await import("./babel-2PBTAJV6.js");
|
|
252
251
|
const hasLargeFiles = cliOptions.hasLargeFiles ?? fileConfig.babel?.hasLargeFiles ?? false;
|
|
253
252
|
const extraIgnores = [
|
|
254
253
|
...fileConfig.babel?.ignore || [],
|
|
@@ -316,7 +315,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
|
|
|
316
315
|
if (buildTypes === true) {
|
|
317
316
|
if (isVerbose)
|
|
318
317
|
console.log(chalk.cyan("\u{1F4DD} Generating TypeScript declarations..."));
|
|
319
|
-
const tsMod = await import("./typescript-
|
|
318
|
+
const tsMod = await import("./typescript-2XUZHHI2.js");
|
|
320
319
|
const bundleMap = bundles.map((type) => ({
|
|
321
320
|
type,
|
|
322
321
|
dir: relativeOutDirs[type]
|
package/dist/config.js
CHANGED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getOutExtension,
|
|
3
|
+
mapConcurrently
|
|
4
|
+
} from "./chunk-N46AJ2OI.js";
|
|
5
|
+
|
|
6
|
+
// src/utils/typescript.ts
|
|
7
|
+
import * as babel from "@babel/core";
|
|
8
|
+
import pluginTypescriptSyntax from "@ssets/babel/plugin/syntax-typescript";
|
|
9
|
+
import pluginResolveImports from "@ssets/babel/plugin/resolve-imports";
|
|
10
|
+
import { findWorkspacesRoot } from "find-workspaces";
|
|
11
|
+
import pluginRemoveImports from "@ssets/babel/plugin/transform-remove-imports";
|
|
12
|
+
import { $ } from "execa";
|
|
13
|
+
import { globby } from "globby";
|
|
14
|
+
import { generateDtsBundle } from "@ssets/dts";
|
|
15
|
+
import * as fs from "fs/promises";
|
|
16
|
+
import * as os from "os";
|
|
17
|
+
import * as path from "path";
|
|
18
|
+
import chalk from "chalk";
|
|
19
|
+
var $$ = $({ stdio: "inherit" });
|
|
20
|
+
async function findTsgo(cwd) {
|
|
21
|
+
const workspaceDir = await findWorkspacesRoot(cwd);
|
|
22
|
+
if (!workspaceDir) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const tsgoPath = path.join(
|
|
26
|
+
workspaceDir.location,
|
|
27
|
+
"node_modules",
|
|
28
|
+
".bin",
|
|
29
|
+
"tsgo"
|
|
30
|
+
);
|
|
31
|
+
const exists = await fs.stat(tsgoPath).then(
|
|
32
|
+
(stat2) => stat2.isFile(),
|
|
33
|
+
() => false
|
|
34
|
+
);
|
|
35
|
+
return exists ? tsgoPath : null;
|
|
36
|
+
}
|
|
37
|
+
async function emitDeclarations(tsconfig, outDir, options = {}) {
|
|
38
|
+
const { useTsgo = false } = options ?? {};
|
|
39
|
+
const tsconfigDir = path.dirname(tsconfig);
|
|
40
|
+
const rootDir = path.resolve(tsconfigDir, "./src");
|
|
41
|
+
const tsgoPath = useTsgo ? await findTsgo(tsconfigDir) : null;
|
|
42
|
+
if (useTsgo && !tsgoPath) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
'--tsgo flag was passed or SSE_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.'
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (tsgoPath) {
|
|
48
|
+
console.log(chalk.cyan("Using tsgo for declaration emit"));
|
|
49
|
+
await $$`${tsgoPath}
|
|
50
|
+
-p ${tsconfig}
|
|
51
|
+
--rootDir ${rootDir}
|
|
52
|
+
--outDir ${outDir}
|
|
53
|
+
--declaration
|
|
54
|
+
--emitDeclarationOnly
|
|
55
|
+
--noEmit false
|
|
56
|
+
--composite false
|
|
57
|
+
--incremental false
|
|
58
|
+
--declarationMap false`;
|
|
59
|
+
} else {
|
|
60
|
+
await $$`tsc
|
|
61
|
+
-p ${tsconfig}
|
|
62
|
+
--rootDir ${rootDir}
|
|
63
|
+
--outDir ${outDir}
|
|
64
|
+
--declaration
|
|
65
|
+
--emitDeclarationOnly
|
|
66
|
+
--noEmit false
|
|
67
|
+
--composite false
|
|
68
|
+
--incremental false
|
|
69
|
+
--declarationMap false`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function copyDeclarations(sourceDirectory, destinationDirectory, options = {}) {
|
|
73
|
+
const fullSourceDirectory = path.resolve(sourceDirectory);
|
|
74
|
+
const fullDestinationDirectory = path.resolve(destinationDirectory);
|
|
75
|
+
if (options.verbose) {
|
|
76
|
+
console.log(
|
|
77
|
+
chalk.gray(
|
|
78
|
+
`Copying declarations from ${fullSourceDirectory} to ${fullDestinationDirectory}`
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
await fs.cp(fullSourceDirectory, fullDestinationDirectory, {
|
|
83
|
+
recursive: true,
|
|
84
|
+
filter: async (src) => {
|
|
85
|
+
if (path.basename(src).startsWith(".")) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const stats = await fs.stat(src);
|
|
89
|
+
if (stats.isDirectory()) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return src.endsWith(".d.ts") || src.endsWith(".d.mts") || src.endsWith(".d.cts");
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async function moveAndTransformDeclarations({
|
|
97
|
+
inputDir,
|
|
98
|
+
buildDir,
|
|
99
|
+
bundles,
|
|
100
|
+
isFlat,
|
|
101
|
+
packageType
|
|
102
|
+
}) {
|
|
103
|
+
const toCopyDir = bundles.length === 1 ? path.join(buildDir, bundles[0].dir) : buildDir;
|
|
104
|
+
await fs.cp(inputDir, toCopyDir, {
|
|
105
|
+
recursive: true,
|
|
106
|
+
force: false
|
|
107
|
+
});
|
|
108
|
+
const dtsFiles = await globby("**/*.d.ts", {
|
|
109
|
+
absolute: true,
|
|
110
|
+
cwd: toCopyDir
|
|
111
|
+
});
|
|
112
|
+
if (dtsFiles.length === 0) {
|
|
113
|
+
console.log(
|
|
114
|
+
chalk.yellow(
|
|
115
|
+
`No d.ts files found in ${toCopyDir}. Skipping transformation.`
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
await mapConcurrently(
|
|
121
|
+
dtsFiles,
|
|
122
|
+
async (dtsFile) => {
|
|
123
|
+
const nativeDtsFile = path.normalize(dtsFile);
|
|
124
|
+
const content = await fs.readFile(nativeDtsFile, "utf8");
|
|
125
|
+
const relativePath = path.relative(toCopyDir, nativeDtsFile);
|
|
126
|
+
const writesToOriginalPath = isFlat && bundles.some((bundle) => {
|
|
127
|
+
const newFileExtension = getOutExtension(bundle.type, {
|
|
128
|
+
isFlat,
|
|
129
|
+
isType: true,
|
|
130
|
+
packageType
|
|
131
|
+
});
|
|
132
|
+
const outFileRelative = relativePath.replace(
|
|
133
|
+
/\.d\.ts$/,
|
|
134
|
+
newFileExtension
|
|
135
|
+
);
|
|
136
|
+
const outFilePath = path.join(buildDir, bundle.dir, outFileRelative);
|
|
137
|
+
return path.resolve(outFilePath) === path.resolve(nativeDtsFile);
|
|
138
|
+
});
|
|
139
|
+
await Promise.all(
|
|
140
|
+
bundles.map(async (bundle) => {
|
|
141
|
+
const importExtension = getOutExtension(bundle.type, {
|
|
142
|
+
isFlat,
|
|
143
|
+
packageType
|
|
144
|
+
});
|
|
145
|
+
const newFileExtension = getOutExtension(bundle.type, {
|
|
146
|
+
isFlat,
|
|
147
|
+
isType: true,
|
|
148
|
+
packageType
|
|
149
|
+
});
|
|
150
|
+
const outFileRelative = isFlat ? relativePath.replace(/\.d\.ts$/, newFileExtension) : relativePath;
|
|
151
|
+
const outFilePath = path.join(buildDir, bundle.dir, outFileRelative);
|
|
152
|
+
const babelPlugins = [
|
|
153
|
+
[pluginTypescriptSyntax, { dts: true }],
|
|
154
|
+
[pluginResolveImports, { outExtension: importExtension }],
|
|
155
|
+
[pluginRemoveImports, { test: /\.css$/ }]
|
|
156
|
+
];
|
|
157
|
+
const result = await babel.transformAsync(content, {
|
|
158
|
+
configFile: false,
|
|
159
|
+
plugins: babelPlugins,
|
|
160
|
+
filename: nativeDtsFile
|
|
161
|
+
});
|
|
162
|
+
if (typeof result?.code === "string") {
|
|
163
|
+
await fs.mkdir(path.dirname(outFilePath), { recursive: true });
|
|
164
|
+
await fs.writeFile(outFilePath, result.code);
|
|
165
|
+
} else {
|
|
166
|
+
console.error(
|
|
167
|
+
chalk.red("failed to transform"),
|
|
168
|
+
chalk.gray(dtsFile)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
if (isFlat && !writesToOriginalPath) {
|
|
174
|
+
await fs.unlink(nativeDtsFile);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
30
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
async function createTypes({
|
|
181
|
+
bundles,
|
|
182
|
+
srcDir,
|
|
183
|
+
buildDir,
|
|
184
|
+
cwd,
|
|
185
|
+
skipTsc,
|
|
186
|
+
useTsgo = false,
|
|
187
|
+
isFlat = false,
|
|
188
|
+
packageType,
|
|
189
|
+
verbose,
|
|
190
|
+
builder,
|
|
191
|
+
entryPoints
|
|
192
|
+
}) {
|
|
193
|
+
if (builder === "esbuild" && entryPoints && !skipTsc) {
|
|
194
|
+
if (verbose) console.log(chalk.blue("\u{1F4E6} Bundling TypeScript declarations"));
|
|
195
|
+
const tmpDir2 = await fs.mkdtemp(path.join(os.tmpdir(), "sse-dts-bundle-"));
|
|
196
|
+
try {
|
|
197
|
+
const tsconfigPath = path.join(cwd, "tsconfig.build.json");
|
|
198
|
+
await emitDeclarations(tsconfigPath, tmpDir2, { useTsgo });
|
|
199
|
+
await Promise.all(
|
|
200
|
+
entryPoints.map(async (entry) => {
|
|
201
|
+
const absoluteEntryPath = path.resolve(cwd, entry);
|
|
202
|
+
const entryName = path.basename(entry, path.extname(entry));
|
|
203
|
+
const [bundledTypes] = generateDtsBundle(
|
|
204
|
+
[
|
|
205
|
+
{
|
|
206
|
+
filePath: absoluteEntryPath,
|
|
207
|
+
output: {
|
|
208
|
+
noBanner: false,
|
|
209
|
+
inlineDeclareGlobals: true
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
{
|
|
214
|
+
preferredConfigPath: tsconfigPath
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
await Promise.all(
|
|
218
|
+
bundles.map(async (bundleItem) => {
|
|
219
|
+
const outExt = getOutExtension(bundleItem.type, {
|
|
220
|
+
isFlat,
|
|
221
|
+
isType: true,
|
|
222
|
+
packageType
|
|
223
|
+
});
|
|
224
|
+
const outFilePath = path.join(
|
|
225
|
+
buildDir,
|
|
226
|
+
bundleItem.dir,
|
|
227
|
+
`${entryName}${outExt}`
|
|
228
|
+
);
|
|
229
|
+
await fs.mkdir(path.dirname(outFilePath), { recursive: true });
|
|
230
|
+
await fs.writeFile(outFilePath, bundledTypes, "utf-8");
|
|
231
|
+
if (verbose) {
|
|
232
|
+
console.log(
|
|
233
|
+
chalk.green(
|
|
234
|
+
`\u2705 Generated bundled types for ${bundleItem.type}: ${outFilePath}`
|
|
235
|
+
)
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
);
|
|
240
|
+
})
|
|
241
|
+
);
|
|
242
|
+
} catch (err) {
|
|
243
|
+
console.error(
|
|
244
|
+
chalk.red(`\u274C Failed to bundle types for ${entryPoints.join(", ")}`)
|
|
245
|
+
);
|
|
246
|
+
console.error(chalk.red(err.message));
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "sse-build-tsc-"));
|
|
251
|
+
try {
|
|
252
|
+
await copyDeclarations(srcDir, tmpDir, { verbose });
|
|
253
|
+
const tsconfigPath = path.join(cwd, "tsconfig.build.json");
|
|
254
|
+
const tsconfigExists = await fs.stat(tsconfigPath).then(
|
|
255
|
+
(file) => file.isFile(),
|
|
256
|
+
() => false
|
|
257
|
+
);
|
|
258
|
+
if (!skipTsc) {
|
|
259
|
+
if (!tsconfigExists) {
|
|
260
|
+
throw new Error(
|
|
261
|
+
`Unable to find a tsconfig to build this project. The package root needs to contain a 'tsconfig.build.json'. The package root is '${cwd}'`
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
if (verbose)
|
|
265
|
+
console.log(
|
|
266
|
+
chalk.cyan(`Building types for ${tsconfigPath} in ${tmpDir}`)
|
|
267
|
+
);
|
|
268
|
+
await emitDeclarations(tsconfigPath, tmpDir, { useTsgo });
|
|
269
|
+
}
|
|
270
|
+
await moveAndTransformDeclarations({
|
|
271
|
+
inputDir: tmpDir,
|
|
272
|
+
buildDir,
|
|
273
|
+
bundles,
|
|
274
|
+
isFlat,
|
|
275
|
+
packageType
|
|
276
|
+
});
|
|
277
|
+
} finally {
|
|
278
|
+
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
export {
|
|
282
|
+
copyDeclarations,
|
|
283
|
+
createTypes,
|
|
284
|
+
emitDeclarations,
|
|
285
|
+
moveAndTransformDeclarations
|
|
286
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sse-ui/builder",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Builder By SSE",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -30,8 +30,6 @@
|
|
|
30
30
|
"@types/node": "^25.4.0",
|
|
31
31
|
"@types/resolve": "^1.20.6",
|
|
32
32
|
"@types/semver": "^7.7.1",
|
|
33
|
-
"prettier": "^3.8.1",
|
|
34
|
-
"tsup": "^8.5.1",
|
|
35
33
|
"typescript": "^5.9.3"
|
|
36
34
|
},
|
|
37
35
|
"dependencies": {
|
|
@@ -40,6 +38,7 @@
|
|
|
40
38
|
"@babel/preset-react": "^7.28.5",
|
|
41
39
|
"@babel/preset-typescript": "^7.28.5",
|
|
42
40
|
"@ssets/babel": "*",
|
|
41
|
+
"@ssets/dts": "*",
|
|
43
42
|
"babel-plugin-optimize-clsx": "^2.6.2",
|
|
44
43
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
45
44
|
"babel-plugin-transform-import-meta": "^2.3.3",
|