@xylabs/ts-scripts-yarn3 6.5.18 → 7.0.0-rc.10
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/actions/index.mjs +110 -130
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package/compile/buildEntries.mjs +8 -1
- package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +87 -107
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +88 -108
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsc.mjs +9 -35
- package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +29 -102
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +96 -135
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/index.mjs +100 -120
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +87 -107
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/bin/package/build-only.mjs +89 -109
- package/dist/bin/package/build-only.mjs.map +1 -1
- package/dist/bin/package/build.mjs +89 -109
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/compile-only.mjs +89 -109
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +101 -140
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +89 -109
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +89 -109
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/index.d.ts +24 -7
- package/dist/index.mjs +122 -142
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -5
- package/dist/actions/package/compile/compileTypes.mjs +0 -138
- package/dist/actions/package/compile/compileTypes.mjs.map +0 -1
- package/dist/bin/package/compile-types.mjs +0 -150
- package/dist/bin/package/compile-types.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/actions/package/compile/compile.ts
|
|
2
|
-
import
|
|
2
|
+
import chalk4 from "chalk";
|
|
3
3
|
|
|
4
4
|
// src/lib/loadConfig.ts
|
|
5
5
|
import chalk from "chalk";
|
|
@@ -74,7 +74,7 @@ var getAllInputs = (folder) => {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
// src/actions/package/compile/buildEntries.ts
|
|
77
|
-
var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true, verbose = false) => {
|
|
77
|
+
var buildEntries = (folder, entryMode = "single", options, excludeSpecAndStories = true, verbose = false) => {
|
|
78
78
|
let entries = [];
|
|
79
79
|
switch (entryMode) {
|
|
80
80
|
case "platform": {
|
|
@@ -85,16 +85,46 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
85
85
|
entries = excludeSpecAndStories ? getAllInputs(folder).filter((entry) => !entry.includes(".spec.") && !entry.includes(".stories.")) : getAllInputs(folder);
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
88
|
+
case "custom": {
|
|
89
|
+
entries = [];
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
88
92
|
default: {
|
|
89
93
|
entries = [`${folder}/index.ts`];
|
|
90
94
|
break;
|
|
91
95
|
}
|
|
92
96
|
}
|
|
97
|
+
if (typeof options !== "boolean" && Array.isArray(options?.entry)) {
|
|
98
|
+
entries.push(...options.entry);
|
|
99
|
+
}
|
|
93
100
|
if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`);
|
|
94
101
|
return entries;
|
|
95
102
|
};
|
|
96
103
|
|
|
97
|
-
// src/actions/package/compile/
|
|
104
|
+
// src/actions/package/compile/deepMerge.ts
|
|
105
|
+
function deepMerge(target, source) {
|
|
106
|
+
if (!source || typeof source !== "object") return target;
|
|
107
|
+
for (const key of Object.keys(source)) {
|
|
108
|
+
if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
|
|
109
|
+
if (!target[key] || typeof target[key] !== "object") {
|
|
110
|
+
target[key] = {};
|
|
111
|
+
}
|
|
112
|
+
deepMerge(target[key], source[key]);
|
|
113
|
+
} else {
|
|
114
|
+
target[key] = source[key];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return target;
|
|
118
|
+
}
|
|
119
|
+
function deepMergeObjects(objects) {
|
|
120
|
+
const result = {};
|
|
121
|
+
for (const obj of objects) {
|
|
122
|
+
deepMerge(result, obj);
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/actions/package/compile/packageCompileTsc.ts
|
|
98
128
|
import { cwd } from "process";
|
|
99
129
|
import chalk3 from "chalk";
|
|
100
130
|
import { createProgramFromConfig } from "tsc-prog";
|
|
@@ -131,33 +161,33 @@ var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
|
|
|
131
161
|
return deepmerge2(configFileCompilerOptions, options);
|
|
132
162
|
};
|
|
133
163
|
|
|
134
|
-
// src/actions/package/compile/
|
|
135
|
-
var
|
|
164
|
+
// src/actions/package/compile/packageCompileTsc.ts
|
|
165
|
+
var packageCompileTsc = (entries, folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
136
166
|
const pkg = process.env.INIT_CWD ?? cwd();
|
|
137
167
|
const verbose = config2?.verbose ?? false;
|
|
138
168
|
const compilerOptions = {
|
|
139
169
|
...getCompilerOptions({
|
|
140
|
-
|
|
141
|
-
outDir: config2.compile?.tsup?.options?.outDir ?? "dist/types",
|
|
170
|
+
outDir: "dist/types",
|
|
142
171
|
removeComments: false,
|
|
143
172
|
skipDefaultLibCheck: true,
|
|
144
173
|
skipLibCheck: true,
|
|
145
174
|
sourceMap: false
|
|
146
175
|
}),
|
|
147
176
|
...compilerOptionsParam,
|
|
148
|
-
emitDeclarationOnly:
|
|
149
|
-
noEmit:
|
|
177
|
+
emitDeclarationOnly: false,
|
|
178
|
+
noEmit: true
|
|
150
179
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
180
|
+
console.log(chalk3.green(`Validating Files: ${entries.length}`));
|
|
181
|
+
if (verbose) {
|
|
182
|
+
for (const entry of entries) {
|
|
183
|
+
console.log(chalk3.grey(`Validating: ${entry}`));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (entries.length > 0) {
|
|
156
187
|
const program = createProgramFromConfig({
|
|
157
188
|
basePath: pkg ?? cwd(),
|
|
158
189
|
compilerOptions,
|
|
159
|
-
|
|
160
|
-
files
|
|
190
|
+
files: entries
|
|
161
191
|
});
|
|
162
192
|
const diagnostics = getPreEmitDiagnostics(program);
|
|
163
193
|
if (diagnostics.length > 0) {
|
|
@@ -177,102 +207,54 @@ var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam
|
|
|
177
207
|
return 0;
|
|
178
208
|
};
|
|
179
209
|
|
|
180
|
-
// src/actions/package/compile/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
deepMerge(target[key], source[key]);
|
|
195
|
-
} else {
|
|
196
|
-
target[key] = source[key];
|
|
210
|
+
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
211
|
+
import { cwd as cwd2 } from "process";
|
|
212
|
+
import { rollup } from "rollup";
|
|
213
|
+
import dts from "rollup-plugin-dts";
|
|
214
|
+
import nodeExternals from "rollup-plugin-node-externals";
|
|
215
|
+
async function bundleDts(inputPath, outputPath, platform) {
|
|
216
|
+
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
217
|
+
const bundle = await rollup({
|
|
218
|
+
input: inputPath,
|
|
219
|
+
plugins: [dts(), ...nodePlugIns],
|
|
220
|
+
onwarn(warning, warn) {
|
|
221
|
+
if (warning.code === "UNUSED_EXTERNAL_IMPORT") return;
|
|
222
|
+
warn(warning);
|
|
197
223
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
deepMerge(result, obj);
|
|
205
|
-
}
|
|
206
|
-
return result;
|
|
224
|
+
});
|
|
225
|
+
await bundle.write({
|
|
226
|
+
file: outputPath,
|
|
227
|
+
format: "es"
|
|
228
|
+
});
|
|
229
|
+
console.log(`Bundled declarations written to ${outputPath}`);
|
|
207
230
|
}
|
|
208
|
-
|
|
209
|
-
// src/actions/package/compile/packageCompileTsc.ts
|
|
210
|
-
import { cwd as cwd2 } from "process";
|
|
211
|
-
import chalk4 from "chalk";
|
|
212
|
-
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
213
|
-
import {
|
|
214
|
-
DiagnosticCategory as DiagnosticCategory2,
|
|
215
|
-
formatDiagnosticsWithColorAndContext as formatDiagnosticsWithColorAndContext2,
|
|
216
|
-
getPreEmitDiagnostics as getPreEmitDiagnostics2,
|
|
217
|
-
sys as sys3
|
|
218
|
-
} from "typescript";
|
|
219
|
-
var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
231
|
+
var packageCompileTscTypes = async (entries, outDir, platform, folder = "src") => {
|
|
220
232
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
221
|
-
const
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
skipDefaultLibCheck: true,
|
|
227
|
-
skipLibCheck: true,
|
|
228
|
-
sourceMap: false
|
|
229
|
-
}),
|
|
230
|
-
...compilerOptionsParam,
|
|
231
|
-
emitDeclarationOnly: false,
|
|
232
|
-
noEmit: true
|
|
233
|
+
const srcRoot = `${pkg}/${folder}`;
|
|
234
|
+
const entryNameToTypeName = (entry) => {
|
|
235
|
+
const splitEntryName = entry.split(".");
|
|
236
|
+
const newEntryExtension = "d." + splitEntryName.at(-1);
|
|
237
|
+
return [...splitEntryName.slice(0, -1), newEntryExtension].join(".");
|
|
233
238
|
};
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (files.length > 0) {
|
|
239
|
-
const program = createProgramFromConfig2({
|
|
240
|
-
basePath: pkg ?? cwd2(),
|
|
241
|
-
compilerOptions,
|
|
242
|
-
exclude: ["dist", "docs"],
|
|
243
|
-
files
|
|
244
|
-
});
|
|
245
|
-
const diagnostics = getPreEmitDiagnostics2(program);
|
|
246
|
-
if (diagnostics.length > 0) {
|
|
247
|
-
const formattedDiagnostics = formatDiagnosticsWithColorAndContext2(
|
|
248
|
-
diagnostics,
|
|
249
|
-
{
|
|
250
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
251
|
-
getCurrentDirectory: () => folder,
|
|
252
|
-
getNewLine: () => sys3.newLine
|
|
253
|
-
}
|
|
254
|
-
);
|
|
255
|
-
console.error(formattedDiagnostics);
|
|
256
|
-
}
|
|
257
|
-
program.emit();
|
|
258
|
-
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory2.Error ? 1 : 0), 0);
|
|
259
|
-
}
|
|
239
|
+
const entryNames = entries.map((entry) => entry.split(`${folder}/`).at(-1) ?? entry);
|
|
240
|
+
await Promise.all(entryNames.map(async (entryName) => {
|
|
241
|
+
await bundleDts(`${srcRoot}/${entryName}`, outDir + "/" + entryNameToTypeName(entryName), platform);
|
|
242
|
+
}));
|
|
260
243
|
return 0;
|
|
261
244
|
};
|
|
262
245
|
|
|
263
246
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
264
|
-
var compileFolder = async (folder,
|
|
247
|
+
var compileFolder = async (folder, entries, options, verbose) => {
|
|
265
248
|
const outDir = options?.outDir ?? "dist";
|
|
266
249
|
if (verbose) {
|
|
267
250
|
console.log(`compileFolder [${folder}]`);
|
|
268
251
|
}
|
|
269
|
-
const entry = buildEntries(folder, entryMode);
|
|
270
252
|
const optionsResult = defineConfig({
|
|
271
253
|
bundle: true,
|
|
272
254
|
cjsInterop: true,
|
|
273
255
|
clean: true,
|
|
274
256
|
dts: false,
|
|
275
|
-
entry,
|
|
257
|
+
entry: entries,
|
|
276
258
|
format: ["esm"],
|
|
277
259
|
outDir,
|
|
278
260
|
silent: true,
|
|
@@ -281,6 +263,11 @@ var compileFolder = async (folder, entryMode = "single", options, verbose) => {
|
|
|
281
263
|
tsconfig: "tsconfig.json",
|
|
282
264
|
...options
|
|
283
265
|
});
|
|
266
|
+
const validationResult = packageCompileTsc(entries);
|
|
267
|
+
if (validationResult !== 0) {
|
|
268
|
+
console.error(`Compile:Validation had ${validationResult} errors`);
|
|
269
|
+
return validationResult;
|
|
270
|
+
}
|
|
284
271
|
const optionsList = (await Promise.all(
|
|
285
272
|
(Array.isArray(optionsResult) ? optionsResult : [optionsResult]).flatMap(async (options2) => {
|
|
286
273
|
const result = typeof options2 === "function" ? await options2({}) : [options2];
|
|
@@ -294,6 +281,7 @@ var compileFolder = async (folder, entryMode = "single", options, verbose) => {
|
|
|
294
281
|
if (verbose) {
|
|
295
282
|
console.log(`TSUP:build:stop [${folder}]`);
|
|
296
283
|
}
|
|
284
|
+
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", folder);
|
|
297
285
|
return 0;
|
|
298
286
|
};
|
|
299
287
|
var tsupOptions = (options = []) => {
|
|
@@ -326,21 +314,13 @@ var packageCompileTsup = async (config2) => {
|
|
|
326
314
|
const compileForNode = compile?.node ?? { src: {} };
|
|
327
315
|
const compileForBrowser = compile?.browser ?? { src: {} };
|
|
328
316
|
const compileForNeutral = compile?.neutral ?? { src: {} };
|
|
329
|
-
if (verbose) {
|
|
330
|
-
console.log("Calling packageCompileTscTypes");
|
|
331
|
-
}
|
|
332
|
-
let errors = await packageCompileTypes(config2);
|
|
333
|
-
errors = errors + packageCompileTsc(void 0, config2);
|
|
334
|
-
if (errors > 0) {
|
|
335
|
-
return errors;
|
|
336
|
-
}
|
|
337
317
|
return (await Promise.all(
|
|
338
318
|
Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
339
319
|
const optionsObject = typeof options === "object" ? options : {};
|
|
340
320
|
const inEsBuildOptions = typeof compile?.node?.esbuildOptions === "object" ? compile?.node?.esbuildOptions : {};
|
|
341
321
|
return typeof folder === "string" ? await compileFolder(
|
|
342
322
|
folder,
|
|
343
|
-
compile?.entryMode,
|
|
323
|
+
buildEntries(folder, compile?.entryMode, options, true, verbose),
|
|
344
324
|
tsupOptions([
|
|
345
325
|
inEsBuildOptions,
|
|
346
326
|
compile?.tsup?.options ?? {},
|
|
@@ -356,7 +336,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
356
336
|
const inEsBuildOptions = typeof compile?.browser?.esbuildOptions === "object" ? compile?.browser?.esbuildOptions : {};
|
|
357
337
|
return typeof folder === "string" ? await compileFolder(
|
|
358
338
|
folder,
|
|
359
|
-
compile?.entryMode,
|
|
339
|
+
buildEntries(folder, compile?.entryMode, options, true, verbose),
|
|
360
340
|
tsupOptions([
|
|
361
341
|
inEsBuildOptions,
|
|
362
342
|
compile?.tsup?.options ?? {},
|
|
@@ -372,7 +352,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
372
352
|
const inEsBuildOptions = typeof compile?.neutral?.esbuildOptions === "object" ? compile?.neutral?.esbuildOptions : {};
|
|
373
353
|
return typeof folder === "string" ? await compileFolder(
|
|
374
354
|
folder,
|
|
375
|
-
compile?.entryMode,
|
|
355
|
+
buildEntries(folder, compile?.entryMode, options, true, verbose),
|
|
376
356
|
tsupOptions([
|
|
377
357
|
inEsBuildOptions,
|
|
378
358
|
compile?.tsup?.options ?? {},
|
|
@@ -388,7 +368,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
388
368
|
// src/actions/package/compile/compile.ts
|
|
389
369
|
var packageCompile = async (inConfig = {}) => {
|
|
390
370
|
const pkg = process.env.INIT_CWD;
|
|
391
|
-
console.log(
|
|
371
|
+
console.log(chalk4.green(`Compiling ${pkg}`));
|
|
392
372
|
const config2 = await loadConfig(inConfig);
|
|
393
373
|
const publint = config2.publint;
|
|
394
374
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -398,11 +378,11 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
398
378
|
return publint ? await packagePublint(config2) : 0;
|
|
399
379
|
};
|
|
400
380
|
export {
|
|
381
|
+
bundleDts,
|
|
401
382
|
packageCompile,
|
|
402
383
|
packageCompileTsc,
|
|
403
384
|
packageCompileTscTypes,
|
|
404
385
|
packageCompileTsup,
|
|
405
|
-
packageCompileTypes,
|
|
406
386
|
tsupOptions
|
|
407
387
|
};
|
|
408
388
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/package/compile/compile.ts","../../../../src/lib/loadConfig.ts","../../../../src/actions/package/publint.ts","../../../../src/actions/package/compile/packageCompileTsup.ts","../../../../src/actions/package/compile/inputs.ts","../../../../src/actions/package/compile/buildEntries.ts","../../../../src/actions/package/compile/packageCompileTscTypes.ts","../../../../src/actions/package/compile/getCompilerOptions.ts","../../../../src/actions/package/compile/compileTypes.ts","../../../../src/actions/package/compile/deepMerge.ts","../../../../src/actions/package/compile/packageCompileTsc.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { loadConfig } from '../../../lib/index.ts'\nimport { packagePublint } from '../publint.ts'\nimport { packageCompileTsup } from './packageCompileTsup.ts'\nimport type { XyConfig } from './XyConfig.ts'\n\nexport const packageCompile = async (inConfig: XyConfig = {}): Promise<number> => {\n const pkg = process.env.INIT_CWD\n console.log(chalk.green(`Compiling ${pkg}`))\n const config = await loadConfig(inConfig)\n const publint = config.publint\n\n const tsupResults = await packageCompileTsup(config)\n\n if (tsupResults > 0) {\n return tsupResults\n }\n\n return (publint ? await packagePublint(config) : 0)\n}\n","import chalk from 'chalk'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { TypeScriptLoader } from 'cosmiconfig-typescript-loader'\nimport deepmerge from 'deepmerge'\n\nlet config: Record<string, unknown>\n\nexport const loadConfig = async <T extends object>(params?: T): Promise<T> => {\n if (config) {\n return deepmerge(config, params ?? {}) as T\n }\n\n const cosmicConfigResult = await cosmiconfig('xy', { cache: true, loaders: { '.ts': TypeScriptLoader() } }).search()\n config = cosmicConfigResult?.config\n const configFilePath = cosmicConfigResult?.filepath\n if (configFilePath) {\n console.log(chalk.gray(`Loading config from ${configFilePath}`))\n }\n return deepmerge(config, params ?? {}) as T\n}\n","import { promises as fs } from 'node:fs'\n\nimport chalk from 'chalk'\nimport type { Message } from 'publint'\nimport sortPackageJson from 'sort-package-json'\n\nexport interface PackagePublintParams { verbose?: boolean }\n\nexport const packagePublint = async (params?: PackagePublintParams) => {\n const pkgDir = process.env.INIT_CWD\n\n const sortedPkg = sortPackageJson(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n await fs.writeFile(`${pkgDir}/package.json`, sortedPkg)\n\n const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n\n console.log(chalk.green(`Publint: ${pkg.name}`))\n console.log(chalk.gray(pkgDir))\n\n const { publint } = await import('publint')\n\n const { messages } = await publint({\n level: 'suggestion',\n pkgDir,\n strict: true,\n })\n\n // eslint-disable-next-line import-x/no-internal-modules\n const { formatMessage } = await import('publint/utils')\n\n const validMessage = (_message: Message): boolean => {\n return true\n /* try {\n const value = getValueFromPath(pkg, message.path)\n switch (message.code) {\n case 'FILE_INVALID_FORMAT':\n return !message.args?.actualFilePath?.includes('dist/browser') && !value?.includes('dist/browser')\n case 'EXPORT_TYPES_INVALID_FORMAT':\n return !`${value}`.includes('dist/browser')\n default:\n return true\n }\n } catch (ex) {\n const error = ex as Error\n console.error(chalk.red(`validMessage Excepted: ${error.message}`))\n console.error(chalk.gray(JSON.stringify(error.stack)))\n return true\n } */\n }\n\n // we filter out invalid file formats for the esm folder since it is intentionally done\n const validMessages = messages.filter(validMessage)\n for (const message of validMessages) {\n switch (message.type) {\n case 'error': {\n console.error(chalk.red(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n case 'warning': {\n console.warn(chalk.yellow(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n default: {\n console.log(chalk.white(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n }\n }\n\n if (params?.verbose) {\n console.log(chalk.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`))\n }\n\n return validMessages.filter(message => message.type === 'error').length\n}\n","import type { Loader } from 'esbuild'\nimport type { Options } from 'tsup'\nimport { build, defineConfig } from 'tsup'\n\nimport { buildEntries } from './buildEntries.ts'\nimport { packageCompileTypes } from './compileTypes.ts'\nimport { deepMergeObjects } from './deepMerge.ts'\nimport { packageCompileTsc } from './packageCompileTsc.ts'\nimport type { EntryMode, XyTsupConfig } from './XyConfig.ts'\n\nconst compileFolder = async (\n folder: string,\n entryMode: EntryMode = 'single',\n options?: Options,\n verbose?: boolean,\n): Promise<number> => {\n const outDir = options?.outDir ?? 'dist'\n\n if (verbose) {\n console.log(`compileFolder [${folder}]`)\n }\n\n const entry = buildEntries(folder, entryMode)\n const optionsResult = defineConfig({\n bundle: true,\n cjsInterop: true,\n clean: true,\n dts: false,\n entry,\n format: ['esm'],\n outDir,\n silent: true,\n sourcemap: true,\n splitting: false,\n tsconfig: 'tsconfig.json',\n ...options,\n })\n const optionsList = (\n await Promise.all(\n (Array.isArray(optionsResult) ? optionsResult : [optionsResult]).flatMap<Promise<Options[]>>(async (options) => {\n const result = typeof options === 'function' ? await options({}) : [options]\n return Array.isArray(result) ? result : [result]\n }),\n )\n ).flat()\n\n if (verbose) {\n console.log(`TSUP:build:start [${folder}]`)\n }\n\n await Promise.all(optionsList.map(options => build(options)))\n\n if (verbose) {\n console.log(`TSUP:build:stop [${folder}]`)\n }\n\n return 0\n}\n\nexport const tsupOptions = (options: Options[] = []): Options => {\n const standardLoaders: Record<string, Loader> = {\n '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy',\n }\n\n const standardOptions: Options = {\n bundle: true,\n format: ['esm'],\n loader: standardLoaders,\n outExtension: ({ format }) => (format === 'esm' ? { js: '.mjs' } : { js: '.cjs' }),\n skipNodeModulesBundle: true,\n sourcemap: true,\n target: 'esnext',\n }\n\n return deepMergeObjects([standardOptions, ...options])\n}\n\nexport const packageCompileTsup = async (config?: XyTsupConfig) => {\n const compile = config?.compile\n const verbose = config?.verbose ?? false\n if (verbose) {\n console.log(`Compiling with TSUP [Depth: ${compile?.depth}]`)\n }\n\n const compileForNode = compile?.node ?? { src: {} }\n const compileForBrowser = compile?.browser ?? { src: {} }\n const compileForNeutral = compile?.neutral ?? { src: {} }\n\n if (verbose) {\n console.log('Calling packageCompileTscTypes')\n }\n\n let errors = await packageCompileTypes(config)\n errors = errors + packageCompileTsc(undefined, config)\n if (errors > 0) {\n return errors\n }\n\n return (\n (\n await Promise.all(\n Object.entries(compileForNode).map(async ([folder, options]) => {\n const optionsObject: Options = typeof options === 'object' ? options : {}\n const inEsBuildOptions = typeof compile?.node?.esbuildOptions === 'object' ? compile?.node?.esbuildOptions : {}\n return typeof folder === 'string'\n ? await compileFolder(\n folder,\n compile?.entryMode,\n tsupOptions([inEsBuildOptions,\n compile?.tsup?.options ?? {},\n (typeof options === 'object' ? options : {}),\n { platform: 'node', outDir: optionsObject.outDir ?? 'dist/node' }]),\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n + (\n await Promise.all(\n Object.entries(compileForBrowser).map(async ([folder, options]) => {\n const optionsObject: Options = typeof options === 'object' ? options : {}\n const inEsBuildOptions = typeof compile?.browser?.esbuildOptions === 'object' ? compile?.browser?.esbuildOptions : {}\n return typeof folder === 'string'\n ? await compileFolder(\n folder,\n compile?.entryMode,\n tsupOptions([inEsBuildOptions,\n compile?.tsup?.options ?? {},\n (typeof options === 'object' ? options : {}),\n { platform: 'browser', outDir: optionsObject.outDir ?? 'dist/browser' }]),\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n + (\n await Promise.all(\n Object.entries(compileForNeutral).map(async ([folder, options]) => {\n const optionsObject: Options = typeof options === 'object' ? options : {}\n const inEsBuildOptions = typeof compile?.neutral?.esbuildOptions === 'object' ? compile?.neutral?.esbuildOptions : {}\n return typeof folder === 'string'\n ? await compileFolder(\n folder,\n compile?.entryMode,\n tsupOptions([inEsBuildOptions,\n compile?.tsup?.options ?? {},\n (typeof options === 'object' ? options : {}),\n { platform: 'neutral', outDir: optionsObject.outDir ?? 'dist/neutral' }]),\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n + 0\n )\n}\n","import { glob } from 'glob'\n\nexport const getAllInputs = (folder: string) => {\n /* tsup wants posix paths */\n return glob.sync(`${folder}/**/*.*`, { posix: true })\n}\n","import { getAllInputs } from './inputs.ts'\nimport type { EntryMode } from './XyConfig.ts'\n\nexport const buildEntries = (folder: string, entryMode: EntryMode = 'single', excludeSpecAndStories = true, verbose = false) => {\n let entries: string[] = []\n switch (entryMode) {\n case 'platform': {\n entries = [`${folder}/index-node.ts`, `${folder}/index-browser.ts`]\n break\n }\n case 'all': {\n entries = excludeSpecAndStories ? getAllInputs(folder).filter(entry => !entry.includes('.spec.') && !entry.includes('.stories.')) : getAllInputs(folder)\n break\n }\n default: {\n entries = [`${folder}/index.ts`]\n break\n }\n }\n if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`)\n return entries\n}\n","import { cwd } from 'node:process'\n\nimport chalk from 'chalk'\nimport type { TsConfigCompilerOptions } from 'tsc-prog'\nimport { createProgramFromConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n DiagnosticCategory, formatDiagnosticsWithColorAndContext, getPreEmitDiagnostics, sys,\n} from 'typescript'\n\nimport { buildEntries } from './buildEntries.ts'\nimport { getCompilerOptions } from './getCompilerOptions.ts'\nimport type { XyConfig, XyTsupConfig } from './XyConfig.ts'\n\nexport const packageCompileTscTypes = (\n folder: string = 'src',\n config: XyConfig = {},\n compilerOptionsParam?: CompilerOptions,\n): number => {\n const pkg = process.env.INIT_CWD ?? cwd()\n const verbose = config?.verbose ?? false\n\n const compilerOptions = {\n ...(getCompilerOptions({\n emitDeclarationOnly: true,\n outDir: (config as XyTsupConfig).compile?.tsup?.options?.outDir ?? 'dist/types',\n removeComments: false,\n skipDefaultLibCheck: true,\n skipLibCheck: true,\n sourceMap: false,\n })),\n ...compilerOptionsParam,\n emitDeclarationOnly: true,\n noEmit: false,\n } as TsConfigCompilerOptions\n\n const validTsExt = ['.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts']\n const excludes = ['.stories.', '.spec.', '/stories/', '/spec/']\n\n // calling all here since the types do not get rolled up\n const files = buildEntries(folder, 'all', verbose)\n .filter(file => validTsExt.find(ext => file.endsWith(ext)) && !(excludes.some(exclude => file.includes(exclude))))\n\n console.log(chalk.green(`Compiling Types ${pkg}: ${files.length}`))\n\n if (files.length > 0) {\n const program = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n exclude: ['build', 'dist', 'docs', '**/*.spec.*', '**/*.stories.*', 'src/**/spec/**/*'],\n files,\n })\n\n const diagnostics = getPreEmitDiagnostics(program)\n\n if (diagnostics.length > 0) {\n const formattedDiagnostics = formatDiagnosticsWithColorAndContext(\n diagnostics,\n {\n getCanonicalFileName: fileName => fileName,\n getCurrentDirectory: () => folder,\n getNewLine: () => sys.newLine,\n },\n )\n console.error(formattedDiagnostics)\n }\n\n program.emit()\n return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0)\n }\n return 0\n}\n","import { createRequire } from 'node:module'\n\nimport deepmerge from 'deepmerge'\nimport type { TsConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n findConfigFile, readConfigFile, sys,\n} from 'typescript'\n\nconst getNested = (config: TsConfig): CompilerOptions => {\n if (config.extends) {\n const require = createRequire(import.meta.url)\n const opts = require(config.extends)\n return deepmerge(getNested(opts), config.compilerOptions ?? {}) as CompilerOptions\n }\n\n return config.compilerOptions as CompilerOptions\n}\n\nconst getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {\n const config = readConfigFile(filename, sys.readFile).config\n return getNested(config)\n}\n\nexport const getCompilerOptions = (options: CompilerOptions = {}, tsconfig: string = 'tsconfig.json'): CompilerOptions => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined) ?? {}\n\n return deepmerge(configFileCompilerOptions, options)\n}\n","import { loadConfig } from '../../../lib/index.ts'\nimport { packageCompileTscTypes } from './packageCompileTscTypes.ts'\nimport type { XyConfig, XyTscConfig } from './XyConfig.ts'\n\nexport const packageCompileTypes = async (inConfig: XyConfig = {}): Promise<number> => {\n const config = await loadConfig(inConfig)\n\n return packageCompileTscTypes(undefined, config as XyTscConfig)\n}\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyObject = Record<any, any>\n\nfunction deepMerge<T extends AnyObject>(target: AnyObject, source: AnyObject): T {\n if (!source || typeof source !== 'object') return target\n\n for (const key of Object.keys(source)) {\n if (\n typeof source[key] === 'object'\n && source[key] !== null\n && !Array.isArray(source[key])\n ) {\n // Recursively merge nested objects\n if (!target[key] || typeof target[key] !== 'object') {\n target[key] = {} as T[typeof key]\n }\n deepMerge(target[key], source[key])\n } else {\n // Overwrite with non-object values\n target[key] = source[key]\n }\n }\n\n return target\n}\n\nexport function deepMergeObjects<T extends AnyObject>(objects: T[]): T {\n const result = {} as T\n for (const obj of objects) {\n deepMerge(result, obj)\n }\n return result\n}\n","import { cwd } from 'node:process'\n\nimport chalk from 'chalk'\nimport type { TsConfigCompilerOptions } from 'tsc-prog'\nimport { createProgramFromConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n DiagnosticCategory, formatDiagnosticsWithColorAndContext, getPreEmitDiagnostics, sys,\n} from 'typescript'\n\nimport { buildEntries } from './buildEntries.ts'\nimport { getCompilerOptions } from './getCompilerOptions.ts'\nimport type { XyConfig } from './XyConfig.ts'\n\nexport const packageCompileTsc = (\n folder: string = 'src',\n config: XyConfig = {},\n compilerOptionsParam?: CompilerOptions,\n): number => {\n const pkg = process.env.INIT_CWD ?? cwd()\n const verbose = config?.verbose ?? false\n\n const compilerOptions = {\n ...(getCompilerOptions({\n outDir: 'dist/types',\n removeComments: false,\n skipDefaultLibCheck: true,\n skipLibCheck: true,\n sourceMap: false,\n })),\n ...compilerOptionsParam,\n emitDeclarationOnly: false,\n noEmit: true,\n } as TsConfigCompilerOptions\n\n const validTsExt = ['.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts']\n const includes = ['.stories.', '.spec.', '.d.ts', '.d.cts', '.d.mts']\n\n // calling all here since the types do not get rolled up\n const files = buildEntries(folder, 'all', verbose)\n .filter(file => validTsExt.find(ext => file.endsWith(ext)) && (includes.find(include => file.includes(include))))\n\n console.log(chalk.green(`Compiling Files ${pkg}: ${files.length}`))\n\n if (files.length > 0) {\n const program = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n exclude: ['dist', 'docs'],\n files,\n })\n\n const diagnostics = getPreEmitDiagnostics(program)\n\n if (diagnostics.length > 0) {\n const formattedDiagnostics = formatDiagnosticsWithColorAndContext(\n diagnostics,\n {\n getCanonicalFileName: fileName => fileName,\n getCurrentDirectory: () => folder,\n getNewLine: () => sys.newLine,\n },\n )\n console.error(formattedDiagnostics)\n }\n\n program.emit()\n return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0)\n }\n return 0\n}\n"],"mappings":";AAAA,OAAOA,YAAW;;;ACAlB,OAAO,WAAW;AAClB,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,O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["chalk","chalk","chalk","sys","deepmerge","config","require","config","chalk","sys","config","cwd","chalk","createProgramFromConfig","DiagnosticCategory","formatDiagnosticsWithColorAndContext","getPreEmitDiagnostics","sys","config","cwd","chalk","createProgramFromConfig","getPreEmitDiagnostics","formatDiagnosticsWithColorAndContext","sys","DiagnosticCategory","options","config","chalk","config"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/package/compile/compile.ts","../../../../src/lib/loadConfig.ts","../../../../src/actions/package/publint.ts","../../../../src/actions/package/compile/packageCompileTsup.ts","../../../../src/actions/package/compile/inputs.ts","../../../../src/actions/package/compile/buildEntries.ts","../../../../src/actions/package/compile/deepMerge.ts","../../../../src/actions/package/compile/packageCompileTsc.ts","../../../../src/actions/package/compile/getCompilerOptions.ts","../../../../src/actions/package/compile/packageCompileTscTypes.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { loadConfig } from '../../../lib/index.ts'\nimport { packagePublint } from '../publint.ts'\nimport { packageCompileTsup } from './packageCompileTsup.ts'\nimport type { XyConfig } from './XyConfig.ts'\n\nexport const packageCompile = async (inConfig: XyConfig = {}): Promise<number> => {\n const pkg = process.env.INIT_CWD\n console.log(chalk.green(`Compiling ${pkg}`))\n const config = await loadConfig(inConfig)\n const publint = config.publint\n\n const tsupResults = await packageCompileTsup(config)\n\n if (tsupResults > 0) {\n return tsupResults\n }\n\n return (publint ? await packagePublint(config) : 0)\n}\n","import chalk from 'chalk'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { TypeScriptLoader } from 'cosmiconfig-typescript-loader'\nimport deepmerge from 'deepmerge'\n\nlet config: Record<string, unknown>\n\nexport const loadConfig = async <T extends object>(params?: T): Promise<T> => {\n if (config) {\n return deepmerge(config, params ?? {}) as T\n }\n\n const cosmicConfigResult = await cosmiconfig('xy', { cache: true, loaders: { '.ts': TypeScriptLoader() } }).search()\n config = cosmicConfigResult?.config\n const configFilePath = cosmicConfigResult?.filepath\n if (configFilePath) {\n console.log(chalk.gray(`Loading config from ${configFilePath}`))\n }\n return deepmerge(config, params ?? {}) as T\n}\n","import { promises as fs } from 'node:fs'\n\nimport chalk from 'chalk'\nimport type { Message } from 'publint'\nimport sortPackageJson from 'sort-package-json'\n\nexport interface PackagePublintParams { verbose?: boolean }\n\nexport const packagePublint = async (params?: PackagePublintParams) => {\n const pkgDir = process.env.INIT_CWD\n\n const sortedPkg = sortPackageJson(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n await fs.writeFile(`${pkgDir}/package.json`, sortedPkg)\n\n const pkg = JSON.parse(await fs.readFile(`${pkgDir}/package.json`, 'utf8'))\n\n console.log(chalk.green(`Publint: ${pkg.name}`))\n console.log(chalk.gray(pkgDir))\n\n const { publint } = await import('publint')\n\n const { messages } = await publint({\n level: 'suggestion',\n pkgDir,\n strict: true,\n })\n\n // eslint-disable-next-line import-x/no-internal-modules\n const { formatMessage } = await import('publint/utils')\n\n const validMessage = (_message: Message): boolean => {\n return true\n /* try {\n const value = getValueFromPath(pkg, message.path)\n switch (message.code) {\n case 'FILE_INVALID_FORMAT':\n return !message.args?.actualFilePath?.includes('dist/browser') && !value?.includes('dist/browser')\n case 'EXPORT_TYPES_INVALID_FORMAT':\n return !`${value}`.includes('dist/browser')\n default:\n return true\n }\n } catch (ex) {\n const error = ex as Error\n console.error(chalk.red(`validMessage Excepted: ${error.message}`))\n console.error(chalk.gray(JSON.stringify(error.stack)))\n return true\n } */\n }\n\n // we filter out invalid file formats for the esm folder since it is intentionally done\n const validMessages = messages.filter(validMessage)\n for (const message of validMessages) {\n switch (message.type) {\n case 'error': {\n console.error(chalk.red(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n case 'warning': {\n console.warn(chalk.yellow(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n default: {\n console.log(chalk.white(`[${message.code}] ${formatMessage(message, pkg)}`))\n break\n }\n }\n }\n\n if (params?.verbose) {\n console.log(chalk.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`))\n }\n\n return validMessages.filter(message => message.type === 'error').length\n}\n","import type { Loader } from 'esbuild'\nimport type { Options } from 'tsup'\nimport { build, defineConfig } from 'tsup'\n\nimport { buildEntries } from './buildEntries.ts'\nimport { deepMergeObjects } from './deepMerge.ts'\nimport { packageCompileTsc } from './packageCompileTsc.ts'\nimport { packageCompileTscTypes } from './packageCompileTscTypes.ts'\nimport type { XyTsupConfig } from './XyConfig.ts'\n\nconst compileFolder = async (\n folder: string,\n entries: string[],\n options?: Options,\n verbose?: boolean,\n): Promise<number> => {\n const outDir = options?.outDir ?? 'dist'\n\n if (verbose) {\n console.log(`compileFolder [${folder}]`)\n }\n\n const optionsResult = defineConfig({\n bundle: true,\n cjsInterop: true,\n clean: true,\n dts: false,\n entry: entries,\n format: ['esm'],\n outDir,\n silent: true,\n sourcemap: true,\n splitting: false,\n tsconfig: 'tsconfig.json',\n ...options,\n })\n\n const validationResult = packageCompileTsc(entries)\n if (validationResult !== 0) {\n console.error(`Compile:Validation had ${validationResult} errors`)\n return validationResult\n }\n\n const optionsList = (\n await Promise.all(\n (Array.isArray(optionsResult) ? optionsResult : [optionsResult]).flatMap<Promise<Options[]>>(async (options) => {\n const result = typeof options === 'function' ? await options({}) : [options]\n return Array.isArray(result) ? result : [result]\n }),\n )\n ).flat()\n\n if (verbose) {\n console.log(`TSUP:build:start [${folder}]`)\n }\n\n await Promise.all(optionsList.map(options => build(options)))\n\n if (verbose) {\n console.log(`TSUP:build:stop [${folder}]`)\n }\n\n await packageCompileTscTypes(entries, outDir, options?.platform ?? 'neutral', folder)\n\n return 0\n}\n\nexport const tsupOptions = (options: Options[] = []): Options => {\n const standardLoaders: Record<string, Loader> = {\n '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy',\n }\n\n const standardOptions: Options = {\n bundle: true,\n format: ['esm'],\n loader: standardLoaders,\n outExtension: ({ format }) => (format === 'esm' ? { js: '.mjs' } : { js: '.cjs' }),\n skipNodeModulesBundle: true,\n sourcemap: true,\n target: 'esnext',\n }\n\n return deepMergeObjects([standardOptions, ...options])\n}\n\nexport const packageCompileTsup = async (config?: XyTsupConfig) => {\n const compile = config?.compile\n const verbose = config?.verbose ?? false\n if (verbose) {\n console.log(`Compiling with TSUP [Depth: ${compile?.depth}]`)\n }\n\n const compileForNode = compile?.node ?? { src: {} }\n const compileForBrowser = compile?.browser ?? { src: {} }\n const compileForNeutral = compile?.neutral ?? { src: {} }\n\n return (\n (\n await Promise.all(\n Object.entries(compileForNode).map(async ([folder, options]) => {\n const optionsObject: Options = typeof options === 'object' ? options : {}\n const inEsBuildOptions = typeof compile?.node?.esbuildOptions === 'object' ? compile?.node?.esbuildOptions : {}\n return typeof folder === 'string'\n ? await compileFolder(\n folder,\n buildEntries(folder, compile?.entryMode, options, true, verbose),\n tsupOptions([inEsBuildOptions,\n compile?.tsup?.options ?? {},\n (typeof options === 'object' ? options : {}),\n { platform: 'node', outDir: optionsObject.outDir ?? 'dist/node' }]),\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n + (\n await Promise.all(\n Object.entries(compileForBrowser).map(async ([folder, options]) => {\n const optionsObject: Options = typeof options === 'object' ? options : {}\n const inEsBuildOptions = typeof compile?.browser?.esbuildOptions === 'object' ? compile?.browser?.esbuildOptions : {}\n return typeof folder === 'string'\n ? await compileFolder(\n folder,\n buildEntries(folder, compile?.entryMode, options, true, verbose),\n tsupOptions([inEsBuildOptions,\n compile?.tsup?.options ?? {},\n (typeof options === 'object' ? options : {}),\n { platform: 'browser', outDir: optionsObject.outDir ?? 'dist/browser' }]),\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n + (\n await Promise.all(\n Object.entries(compileForNeutral).map(async ([folder, options]) => {\n const optionsObject: Options = typeof options === 'object' ? options : {}\n const inEsBuildOptions = typeof compile?.neutral?.esbuildOptions === 'object' ? compile?.neutral?.esbuildOptions : {}\n return typeof folder === 'string'\n ? await compileFolder(\n folder,\n buildEntries(folder, compile?.entryMode, options, true, verbose),\n tsupOptions([inEsBuildOptions,\n compile?.tsup?.options ?? {},\n (typeof options === 'object' ? options : {}),\n { platform: 'neutral', outDir: optionsObject.outDir ?? 'dist/neutral' }]),\n verbose,\n )\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0)\n + 0\n )\n}\n","import { glob } from 'glob'\n\nexport const getAllInputs = (folder: string) => {\n /* tsup wants posix paths */\n return glob.sync(`${folder}/**/*.*`, { posix: true })\n}\n","import type { Options } from 'tsup'\n\nimport { getAllInputs } from './inputs.ts'\nimport type { EntryMode } from './XyConfig.ts'\n\nexport const buildEntries = (folder: string, entryMode: EntryMode = 'single', options?: Options | boolean, excludeSpecAndStories = true, verbose = false) => {\n let entries: string[] = []\n switch (entryMode) {\n case 'platform': {\n entries = [`${folder}/index-node.ts`, `${folder}/index-browser.ts`]\n break\n }\n case 'all': {\n entries = excludeSpecAndStories ? getAllInputs(folder).filter(entry => !entry.includes('.spec.') && !entry.includes('.stories.')) : getAllInputs(folder)\n break\n }\n case 'custom': {\n entries = []\n break\n }\n default: {\n entries = [`${folder}/index.ts`]\n break\n }\n }\n\n if (typeof options !== 'boolean' && Array.isArray(options?.entry)) {\n entries.push(...options.entry)\n }\n\n if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`)\n return entries\n}\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyObject = Record<any, any>\n\nfunction deepMerge<T extends AnyObject>(target: AnyObject, source: AnyObject): T {\n if (!source || typeof source !== 'object') return target\n\n for (const key of Object.keys(source)) {\n if (\n typeof source[key] === 'object'\n && source[key] !== null\n && !Array.isArray(source[key])\n ) {\n // Recursively merge nested objects\n if (!target[key] || typeof target[key] !== 'object') {\n target[key] = {} as T[typeof key]\n }\n deepMerge(target[key], source[key])\n } else {\n // Overwrite with non-object values\n target[key] = source[key]\n }\n }\n\n return target\n}\n\nexport function deepMergeObjects<T extends AnyObject>(objects: T[]): T {\n const result = {} as T\n for (const obj of objects) {\n deepMerge(result, obj)\n }\n return result\n}\n","import { cwd } from 'node:process'\n\nimport chalk from 'chalk'\nimport type { TsConfigCompilerOptions } from 'tsc-prog'\nimport { createProgramFromConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n DiagnosticCategory, formatDiagnosticsWithColorAndContext, getPreEmitDiagnostics, sys,\n} from 'typescript'\n\nimport { getCompilerOptions } from './getCompilerOptions.ts'\nimport type { XyConfig } from './XyConfig.ts'\n\nexport const packageCompileTsc = (\n entries: string[],\n folder: string = 'src',\n config: XyConfig = {},\n compilerOptionsParam?: CompilerOptions,\n): number => {\n const pkg = process.env.INIT_CWD ?? cwd()\n const verbose = config?.verbose ?? false\n\n const compilerOptions = {\n ...(getCompilerOptions({\n outDir: 'dist/types',\n removeComments: false,\n skipDefaultLibCheck: true,\n skipLibCheck: true,\n sourceMap: false,\n })),\n ...compilerOptionsParam,\n emitDeclarationOnly: false,\n noEmit: true,\n } as TsConfigCompilerOptions\n\n console.log(chalk.green(`Validating Files: ${entries.length}`))\n if (verbose) {\n for (const entry of entries) {\n console.log(chalk.grey(`Validating: ${entry}`))\n }\n }\n\n if (entries.length > 0) {\n const program = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n files: entries,\n })\n\n const diagnostics = getPreEmitDiagnostics(program)\n\n if (diagnostics.length > 0) {\n const formattedDiagnostics = formatDiagnosticsWithColorAndContext(\n diagnostics,\n {\n getCanonicalFileName: fileName => fileName,\n getCurrentDirectory: () => folder,\n getNewLine: () => sys.newLine,\n },\n )\n console.error(formattedDiagnostics)\n }\n\n program.emit()\n return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0)\n }\n return 0\n}\n","import { createRequire } from 'node:module'\n\nimport deepmerge from 'deepmerge'\nimport type { TsConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n findConfigFile, readConfigFile, sys,\n} from 'typescript'\n\nconst getNested = (config: TsConfig): CompilerOptions => {\n if (config.extends) {\n const require = createRequire(import.meta.url)\n const opts = require(config.extends)\n return deepmerge(getNested(opts), config.compilerOptions ?? {}) as CompilerOptions\n }\n\n return config.compilerOptions as CompilerOptions\n}\n\nconst getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {\n const config = readConfigFile(filename, sys.readFile).config\n return getNested(config)\n}\n\nexport const getCompilerOptions = (options: CompilerOptions = {}, tsconfig: string = 'tsconfig.json'): CompilerOptions => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined) ?? {}\n\n return deepmerge(configFileCompilerOptions, options)\n}\n","import { cwd } from 'node:process'\n\nimport { rollup } from 'rollup'\nimport dts from 'rollup-plugin-dts'\nimport nodeExternals from 'rollup-plugin-node-externals'\n\nexport async function bundleDts(inputPath: string, outputPath: string, platform: 'node' | 'browser' | 'neutral') {\n const nodePlugIns = platform === 'node' ? [nodeExternals()] : []\n const bundle = await rollup({\n input: inputPath,\n plugins: [dts(), ...nodePlugIns],\n onwarn(warning, warn) {\n // Ignore certain warnings if needed\n if (warning.code === 'UNUSED_EXTERNAL_IMPORT') return\n warn(warning)\n },\n })\n\n await bundle.write({\n file: outputPath,\n format: 'es',\n })\n\n console.log(`Bundled declarations written to ${outputPath}`)\n}\n\nexport const packageCompileTscTypes = async (\n entries: string[],\n outDir: string,\n platform: 'node' | 'browser' | 'neutral',\n folder: string = 'src',\n): Promise<number> => {\n const pkg = process.env.INIT_CWD ?? cwd()\n const srcRoot = `${pkg}/${folder}`\n\n const entryNameToTypeName = (entry: string): string => {\n const splitEntryName = entry.split('.')\n const newEntryExtension = 'd.' + splitEntryName.at(-1)\n return [...splitEntryName.slice(0, -1), newEntryExtension].join('.')\n }\n\n const entryNames = entries.map(entry => entry.split(`${folder}/`).at(-1) ?? entry)\n\n await Promise.all(entryNames.map(async (entryName) => {\n await bund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,IAAI,OAAO,CAAC,QAAQ,OAAO,MAAM;AACjE,YAAM,gBAAyB,OAAO,YAAY,WAAW,UAAU,CAAC;AACxE,YAAM,mBAAmB,OAAO,SAAS,SAAS,mBAAmB,WAAW,SAAS,SAAS,iBAAiB,CAAC;AACpH,aAAO,OAAO,WAAW,WACrB,MAAM;AAAA,QACJ;AAAA,QACA,aAAa,QAAQ,SAAS,WAAW,SAAS,MAAM,OAAO;AAAA,QAC/D,YAAY;AAAA,UAAC;AAAA,UACX,SAAS,MAAM,WAAW,CAAC;AAAA,UAC1B,OAAO,YAAY,WAAW,UAAU,CAAC;AAAA,UAC1C,EAAE,UAAU,WAAW,QAAQ,cAAc,UAAU,eAAe;AAAA,QAAC,CAAC;AAAA,QAC1E;AAAA,MACF,IACA;AAAA,IACN,CAAC;AAAA,EACH,GACA,OAAO,CAAC,MAAM,UAAU,OAAO,OAAO,CAAC,IACvC;AAEN;;;AHrJO,IAAM,iBAAiB,OAAO,WAAqB,CAAC,MAAuB;AAChF,QAAM,MAAM,QAAQ,IAAI;AACxB,UAAQ,IAAIC,OAAM,MAAM,aAAa,GAAG,EAAE,CAAC;AAC3C,QAAMC,UAAS,MAAM,WAAW,QAAQ;AACxC,QAAM,UAAUA,QAAO;AAEvB,QAAM,cAAc,MAAM,mBAAmBA,OAAM;AAEnD,MAAI,cAAc,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,SAAQ,UAAU,MAAM,eAAeA,OAAM,IAAI;AACnD;","names":["chalk","chalk","chalk","sys","deepmerge","config","require","config","chalk","sys","cwd","options","config","chalk","config"]}
|
|
@@ -9,33 +9,6 @@ import {
|
|
|
9
9
|
sys as sys2
|
|
10
10
|
} from "typescript";
|
|
11
11
|
|
|
12
|
-
// src/actions/package/compile/inputs.ts
|
|
13
|
-
import { glob } from "glob";
|
|
14
|
-
var getAllInputs = (folder) => {
|
|
15
|
-
return glob.sync(`${folder}/**/*.*`, { posix: true });
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// src/actions/package/compile/buildEntries.ts
|
|
19
|
-
var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true, verbose = false) => {
|
|
20
|
-
let entries = [];
|
|
21
|
-
switch (entryMode) {
|
|
22
|
-
case "platform": {
|
|
23
|
-
entries = [`${folder}/index-node.ts`, `${folder}/index-browser.ts`];
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
case "all": {
|
|
27
|
-
entries = excludeSpecAndStories ? getAllInputs(folder).filter((entry) => !entry.includes(".spec.") && !entry.includes(".stories.")) : getAllInputs(folder);
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
default: {
|
|
31
|
-
entries = [`${folder}/index.ts`];
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`);
|
|
36
|
-
return entries;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
12
|
// src/actions/package/compile/getCompilerOptions.ts
|
|
40
13
|
import { createRequire } from "module";
|
|
41
14
|
import deepmerge from "deepmerge";
|
|
@@ -63,7 +36,7 @@ var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
|
|
|
63
36
|
};
|
|
64
37
|
|
|
65
38
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
66
|
-
var packageCompileTsc = (folder = "src", config = {}, compilerOptionsParam) => {
|
|
39
|
+
var packageCompileTsc = (entries, folder = "src", config = {}, compilerOptionsParam) => {
|
|
67
40
|
const pkg = process.env.INIT_CWD ?? cwd();
|
|
68
41
|
const verbose = config?.verbose ?? false;
|
|
69
42
|
const compilerOptions = {
|
|
@@ -78,16 +51,17 @@ var packageCompileTsc = (folder = "src", config = {}, compilerOptionsParam) => {
|
|
|
78
51
|
emitDeclarationOnly: false,
|
|
79
52
|
noEmit: true
|
|
80
53
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
54
|
+
console.log(chalk.green(`Validating Files: ${entries.length}`));
|
|
55
|
+
if (verbose) {
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
console.log(chalk.grey(`Validating: ${entry}`));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (entries.length > 0) {
|
|
86
61
|
const program = createProgramFromConfig({
|
|
87
62
|
basePath: pkg ?? cwd(),
|
|
88
63
|
compilerOptions,
|
|
89
|
-
|
|
90
|
-
files
|
|
64
|
+
files: entries
|
|
91
65
|
});
|
|
92
66
|
const diagnostics = getPreEmitDiagnostics(program);
|
|
93
67
|
if (diagnostics.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/package/compile/packageCompileTsc.ts","../../../../src/actions/package/compile/
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/package/compile/packageCompileTsc.ts","../../../../src/actions/package/compile/getCompilerOptions.ts"],"sourcesContent":["import { cwd } from 'node:process'\n\nimport chalk from 'chalk'\nimport type { TsConfigCompilerOptions } from 'tsc-prog'\nimport { createProgramFromConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n DiagnosticCategory, formatDiagnosticsWithColorAndContext, getPreEmitDiagnostics, sys,\n} from 'typescript'\n\nimport { getCompilerOptions } from './getCompilerOptions.ts'\nimport type { XyConfig } from './XyConfig.ts'\n\nexport const packageCompileTsc = (\n entries: string[],\n folder: string = 'src',\n config: XyConfig = {},\n compilerOptionsParam?: CompilerOptions,\n): number => {\n const pkg = process.env.INIT_CWD ?? cwd()\n const verbose = config?.verbose ?? false\n\n const compilerOptions = {\n ...(getCompilerOptions({\n outDir: 'dist/types',\n removeComments: false,\n skipDefaultLibCheck: true,\n skipLibCheck: true,\n sourceMap: false,\n })),\n ...compilerOptionsParam,\n emitDeclarationOnly: false,\n noEmit: true,\n } as TsConfigCompilerOptions\n\n console.log(chalk.green(`Validating Files: ${entries.length}`))\n if (verbose) {\n for (const entry of entries) {\n console.log(chalk.grey(`Validating: ${entry}`))\n }\n }\n\n if (entries.length > 0) {\n const program = createProgramFromConfig({\n basePath: pkg ?? cwd(),\n compilerOptions,\n files: entries,\n })\n\n const diagnostics = getPreEmitDiagnostics(program)\n\n if (diagnostics.length > 0) {\n const formattedDiagnostics = formatDiagnosticsWithColorAndContext(\n diagnostics,\n {\n getCanonicalFileName: fileName => fileName,\n getCurrentDirectory: () => folder,\n getNewLine: () => sys.newLine,\n },\n )\n console.error(formattedDiagnostics)\n }\n\n program.emit()\n return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0)\n }\n return 0\n}\n","import { createRequire } from 'node:module'\n\nimport deepmerge from 'deepmerge'\nimport type { TsConfig } from 'tsc-prog'\nimport type { CompilerOptions } from 'typescript'\nimport {\n findConfigFile, readConfigFile, sys,\n} from 'typescript'\n\nconst getNested = (config: TsConfig): CompilerOptions => {\n if (config.extends) {\n const require = createRequire(import.meta.url)\n const opts = require(config.extends)\n return deepmerge(getNested(opts), config.compilerOptions ?? {}) as CompilerOptions\n }\n\n return config.compilerOptions as CompilerOptions\n}\n\nconst getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {\n const config = readConfigFile(filename, sys.readFile).config\n return getNested(config)\n}\n\nexport const getCompilerOptions = (options: CompilerOptions = {}, tsconfig: string = 'tsconfig.json'): CompilerOptions => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined) ?? {}\n\n return deepmerge(configFileCompilerOptions, options)\n}\n"],"mappings":";AAAA,SAAS,WAAW;AAEpB,OAAO,WAAW;AAElB,SAAS,+BAA+B;AAExC;AAAA,EACE;AAAA,EAAoB;AAAA,EAAsC;AAAA,EAAuB,OAAAA;AAAA,OAC5E;;;ACRP,SAAS,qBAAqB;AAE9B,OAAO,eAAe;AAGtB;AAAA,EACE;AAAA,EAAgB;AAAA,EAAgB;AAAA,OAC3B;AAEP,IAAM,YA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