@xylabs/ts-scripts-yarn3 3.1.10 → 3.1.12
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/package/compile/copyTypeFiles.js +18 -14
- package/dist/actions/package/compile/copyTypeFiles.js.map +1 -1
- package/dist/actions/package/compile/copyTypeFiles.mjs +18 -14
- package/dist/actions/package/compile/copyTypeFiles.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.js +23 -8
- package/dist/actions/package/compile/packageCompileTsup.js.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +23 -8
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/package.json +21 -20
- package/src/actions/package/compile/copyTypeFiles.ts +21 -15
- package/src/actions/package/compile/packageCompileTsup.ts +18 -3
|
@@ -21,7 +21,9 @@ __export(copyTypeFiles_exports, {
|
|
|
21
21
|
copyTypeFiles: () => copyTypeFiles
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(copyTypeFiles_exports);
|
|
24
|
+
var import_async_mutex = require("async-mutex");
|
|
24
25
|
var import_promises = require("fs/promises");
|
|
26
|
+
const copyFileMutex = new import_async_mutex.Mutex();
|
|
25
27
|
const getDistTypeFiles = async (compilerOptions) => {
|
|
26
28
|
const outDir = compilerOptions.outDir ?? "dist";
|
|
27
29
|
return (await (0, import_promises.readdir)(outDir, { recursive: true })).filter((file) => file.endsWith("d.ts")).map((file) => `${outDir}/${file}`);
|
|
@@ -31,20 +33,22 @@ const getDistTypeMapFiles = async (compilerOptions) => {
|
|
|
31
33
|
return (await (0, import_promises.readdir)(outDir, { recursive: true })).filter((file) => file.endsWith("d.ts.map")).map((file) => `${outDir}/${file}`);
|
|
32
34
|
};
|
|
33
35
|
const copyTypeFiles = async (compilerOptions) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
await copyFileMutex.runExclusive(async () => {
|
|
37
|
+
const distTypeFiles = await getDistTypeFiles(compilerOptions);
|
|
38
|
+
await Promise.all(
|
|
39
|
+
distTypeFiles.map(async (file) => {
|
|
40
|
+
await (0, import_promises.copyFile)(file, file.replace("d.ts", "d.mts"));
|
|
41
|
+
await (0, import_promises.copyFile)(file, file.replace("d.ts", "d.cts"));
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
const distTypeMapFiles = await getDistTypeMapFiles(compilerOptions);
|
|
45
|
+
await Promise.all(
|
|
46
|
+
distTypeMapFiles.map(async (file) => {
|
|
47
|
+
await (0, import_promises.copyFile)(file, file.replace("d.ts.map", "d.mts.map"));
|
|
48
|
+
await (0, import_promises.copyFile)(file, file.replace("d.ts.map", "d.cts.map"));
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
});
|
|
48
52
|
};
|
|
49
53
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
54
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/package/compile/copyTypeFiles.ts"],"sourcesContent":["import { copyFile, readdir } from 'fs/promises'\nimport { TsConfigCompilerOptions } from 'tsc-prog'\n\nconst getDistTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n const outDir = compilerOptions.outDir ?? 'dist'\n return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith('d.ts')).map((file) => `${outDir}/${file}`)\n}\n\nconst getDistTypeMapFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n const outDir = compilerOptions.outDir ?? 'dist'\n return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith('d.ts.map')).map((file) => `${outDir}/${file}`)\n}\n\nexport const copyTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n //hybrid packages want two copies of the types\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/package/compile/copyTypeFiles.ts"],"sourcesContent":["import { Mutex } from 'async-mutex'\nimport { copyFile, readdir } from 'fs/promises'\nimport { TsConfigCompilerOptions } from 'tsc-prog'\n\nconst copyFileMutex = new Mutex()\n\nconst getDistTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n const outDir = compilerOptions.outDir ?? 'dist'\n return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith('d.ts')).map((file) => `${outDir}/${file}`)\n}\n\nconst getDistTypeMapFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n const outDir = compilerOptions.outDir ?? 'dist'\n return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith('d.ts.map')).map((file) => `${outDir}/${file}`)\n}\n\nexport const copyTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n //using a mutex since sometimes two compiles are running at once and cause a lock on windows\n await copyFileMutex.runExclusive(async () => {\n //hybrid packages want two copies of the types\n const distTypeFiles = await getDistTypeFiles(compilerOptions)\n await Promise.all(\n distTypeFiles.map(async (file) => {\n await copyFile(file, file.replace('d.ts', 'd.mts'))\n await copyFile(file, file.replace('d.ts', 'd.cts'))\n }),\n )\n\n const distTypeMapFiles = await getDistTypeMapFiles(compilerOptions)\n await Promise.all(\n distTypeMapFiles.map(async (file) => {\n await copyFile(file, file.replace('d.ts.map', 'd.mts.map'))\n await copyFile(file, file.replace('d.ts.map', 'd.cts.map'))\n }),\n )\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAsB;AACtB,sBAAkC;AAGlC,MAAM,gBAAgB,IAAI,yBAAM;AAEhC,MAAM,mBAAmB,OAAO,oBAA6C;AAC3E,QAAM,SAAS,gBAAgB,UAAU;AACzC,UAAQ,UAAM,yBAAQ,QAAQ,EAAE,WAAW,KAAK,CAAC,GAAG,OAAO,CAAC,SAAS,KAAK,SAAS,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,IAAI,EAAE;AAC/H;AAEA,MAAM,sBAAsB,OAAO,oBAA6C;AAC9E,QAAM,SAAS,gBAAgB,UAAU;AACzC,UAAQ,UAAM,yBAAQ,QAAQ,EAAE,WAAW,KAAK,CAAC,GAAG,OAAO,CAAC,SAAS,KAAK,SAAS,UAAU,CAAC,EAAE,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,IAAI,EAAE;AACnI;AAEO,MAAM,gBAAgB,OAAO,oBAA6C;AAE/E,QAAM,cAAc,aAAa,YAAY;AAE3C,UAAM,gBAAgB,MAAM,iBAAiB,eAAe;AAC5D,UAAM,QAAQ;AAAA,MACZ,cAAc,IAAI,OAAO,SAAS;AAChC,kBAAM,0BAAS,MAAM,KAAK,QAAQ,QAAQ,OAAO,CAAC;AAClD,kBAAM,0BAAS,MAAM,KAAK,QAAQ,QAAQ,OAAO,CAAC;AAAA,MACpD,CAAC;AAAA,IACH;AAEA,UAAM,mBAAmB,MAAM,oBAAoB,eAAe;AAClE,UAAM,QAAQ;AAAA,MACZ,iBAAiB,IAAI,OAAO,SAAS;AACnC,kBAAM,0BAAS,MAAM,KAAK,QAAQ,YAAY,WAAW,CAAC;AAC1D,kBAAM,0BAAS,MAAM,KAAK,QAAQ,YAAY,WAAW,CAAC;AAAA,MAC5D,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Mutex } from "async-mutex";
|
|
1
2
|
import { copyFile, readdir } from "fs/promises";
|
|
3
|
+
const copyFileMutex = new Mutex();
|
|
2
4
|
const getDistTypeFiles = async (compilerOptions) => {
|
|
3
5
|
const outDir = compilerOptions.outDir ?? "dist";
|
|
4
6
|
return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith("d.ts")).map((file) => `${outDir}/${file}`);
|
|
@@ -8,20 +10,22 @@ const getDistTypeMapFiles = async (compilerOptions) => {
|
|
|
8
10
|
return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith("d.ts.map")).map((file) => `${outDir}/${file}`);
|
|
9
11
|
};
|
|
10
12
|
const copyTypeFiles = async (compilerOptions) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
await copyFileMutex.runExclusive(async () => {
|
|
14
|
+
const distTypeFiles = await getDistTypeFiles(compilerOptions);
|
|
15
|
+
await Promise.all(
|
|
16
|
+
distTypeFiles.map(async (file) => {
|
|
17
|
+
await copyFile(file, file.replace("d.ts", "d.mts"));
|
|
18
|
+
await copyFile(file, file.replace("d.ts", "d.cts"));
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
const distTypeMapFiles = await getDistTypeMapFiles(compilerOptions);
|
|
22
|
+
await Promise.all(
|
|
23
|
+
distTypeMapFiles.map(async (file) => {
|
|
24
|
+
await copyFile(file, file.replace("d.ts.map", "d.mts.map"));
|
|
25
|
+
await copyFile(file, file.replace("d.ts.map", "d.cts.map"));
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
});
|
|
25
29
|
};
|
|
26
30
|
export {
|
|
27
31
|
copyTypeFiles
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/package/compile/copyTypeFiles.ts"],"sourcesContent":["import { copyFile, readdir } from 'fs/promises'\nimport { TsConfigCompilerOptions } from 'tsc-prog'\n\nconst getDistTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n const outDir = compilerOptions.outDir ?? 'dist'\n return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith('d.ts')).map((file) => `${outDir}/${file}`)\n}\n\nconst getDistTypeMapFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n const outDir = compilerOptions.outDir ?? 'dist'\n return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith('d.ts.map')).map((file) => `${outDir}/${file}`)\n}\n\nexport const copyTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n //hybrid packages want two copies of the types\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/package/compile/copyTypeFiles.ts"],"sourcesContent":["import { Mutex } from 'async-mutex'\nimport { copyFile, readdir } from 'fs/promises'\nimport { TsConfigCompilerOptions } from 'tsc-prog'\n\nconst copyFileMutex = new Mutex()\n\nconst getDistTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n const outDir = compilerOptions.outDir ?? 'dist'\n return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith('d.ts')).map((file) => `${outDir}/${file}`)\n}\n\nconst getDistTypeMapFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n const outDir = compilerOptions.outDir ?? 'dist'\n return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith('d.ts.map')).map((file) => `${outDir}/${file}`)\n}\n\nexport const copyTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {\n //using a mutex since sometimes two compiles are running at once and cause a lock on windows\n await copyFileMutex.runExclusive(async () => {\n //hybrid packages want two copies of the types\n const distTypeFiles = await getDistTypeFiles(compilerOptions)\n await Promise.all(\n distTypeFiles.map(async (file) => {\n await copyFile(file, file.replace('d.ts', 'd.mts'))\n await copyFile(file, file.replace('d.ts', 'd.cts'))\n }),\n )\n\n const distTypeMapFiles = await getDistTypeMapFiles(compilerOptions)\n await Promise.all(\n distTypeMapFiles.map(async (file) => {\n await copyFile(file, file.replace('d.ts.map', 'd.mts.map'))\n await copyFile(file, file.replace('d.ts.map', 'd.cts.map'))\n }),\n )\n })\n}\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAAS,UAAU,eAAe;AAGlC,MAAM,gBAAgB,IAAI,MAAM;AAEhC,MAAM,mBAAmB,OAAO,oBAA6C;AAC3E,QAAM,SAAS,gBAAgB,UAAU;AACzC,UAAQ,MAAM,QAAQ,QAAQ,EAAE,WAAW,KAAK,CAAC,GAAG,OAAO,CAAC,SAAS,KAAK,SAAS,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,IAAI,EAAE;AAC/H;AAEA,MAAM,sBAAsB,OAAO,oBAA6C;AAC9E,QAAM,SAAS,gBAAgB,UAAU;AACzC,UAAQ,MAAM,QAAQ,QAAQ,EAAE,WAAW,KAAK,CAAC,GAAG,OAAO,CAAC,SAAS,KAAK,SAAS,UAAU,CAAC,EAAE,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,IAAI,EAAE;AACnI;AAEO,MAAM,gBAAgB,OAAO,oBAA6C;AAE/E,QAAM,cAAc,aAAa,YAAY;AAE3C,UAAM,gBAAgB,MAAM,iBAAiB,eAAe;AAC5D,UAAM,QAAQ;AAAA,MACZ,cAAc,IAAI,OAAO,SAAS;AAChC,cAAM,SAAS,MAAM,KAAK,QAAQ,QAAQ,OAAO,CAAC;AAClD,cAAM,SAAS,MAAM,KAAK,QAAQ,QAAQ,OAAO,CAAC;AAAA,MACpD,CAAC;AAAA,IACH;AAEA,UAAM,mBAAmB,MAAM,oBAAoB,eAAe;AAClE,UAAM,QAAQ;AAAA,MACZ,iBAAiB,IAAI,OAAO,SAAS;AACnC,cAAM,SAAS,MAAM,KAAK,QAAQ,YAAY,WAAW,CAAC;AAC1D,cAAM,SAAS,MAAM,KAAK,QAAQ,YAAY,WAAW,CAAC;AAAA,MAC5D,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -21,6 +21,7 @@ __export(packageCompileTsup_exports, {
|
|
|
21
21
|
packageCompileTsup: () => packageCompileTsup
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(packageCompileTsup_exports);
|
|
24
|
+
var import_lodash = require("lodash");
|
|
24
25
|
var import_tsup = require("tsup");
|
|
25
26
|
var import_publint = require("../publint");
|
|
26
27
|
var import_buildEntries = require("./buildEntries");
|
|
@@ -64,19 +65,24 @@ const packageCompileTsup = async (config) => {
|
|
|
64
65
|
const compileForBrowser = (compile == null ? void 0 : compile.browser) ?? { src: {} };
|
|
65
66
|
return await (0, import_packageCompileTsc.packageCompileTsc)(true, { publint: false, verbose }) || (await Promise.all(
|
|
66
67
|
Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
67
|
-
var _a;
|
|
68
|
+
var _a, _b, _c;
|
|
69
|
+
const inEsBuildOptions = typeof ((_a = compile == null ? void 0 : compile.node) == null ? void 0 : _a.esbuildOptions) === "object" ? (_b = compile == null ? void 0 : compile.node) == null ? void 0 : _b.esbuildOptions : {};
|
|
68
70
|
return folder ? await compileFolder(
|
|
69
71
|
folder,
|
|
70
72
|
compile == null ? void 0 : compile.entryMode,
|
|
71
73
|
{
|
|
72
74
|
bundle: true,
|
|
73
75
|
format: ["cjs", "esm"],
|
|
74
|
-
loader:
|
|
76
|
+
loader: (0, import_lodash.merge)(
|
|
77
|
+
{},
|
|
78
|
+
{ ".gif": "copy", ".html": "copy", ".jpg": "copy", ".json": "json", ".png": "copy", ".svg": "copy", ".webp": "copy" },
|
|
79
|
+
inEsBuildOptions == null ? void 0 : inEsBuildOptions.loader
|
|
80
|
+
),
|
|
75
81
|
outDir: "dist/node",
|
|
76
82
|
platform: "node",
|
|
77
83
|
skipNodeModulesBundle: true,
|
|
78
84
|
target: "node16",
|
|
79
|
-
...((
|
|
85
|
+
...((_c = compile == null ? void 0 : compile.tsup) == null ? void 0 : _c.options) ?? {},
|
|
80
86
|
...typeof options === "object" ? options : {}
|
|
81
87
|
},
|
|
82
88
|
verbose
|
|
@@ -84,7 +90,8 @@ const packageCompileTsup = async (config) => {
|
|
|
84
90
|
})
|
|
85
91
|
)).reduce((prev, value) => prev + value, 0) || (await Promise.all(
|
|
86
92
|
Object.entries(compileForBrowser).map(async ([folder, options]) => {
|
|
87
|
-
var _a, _b;
|
|
93
|
+
var _a, _b, _c, _d;
|
|
94
|
+
const inEsBuildOptions = typeof ((_a = compile == null ? void 0 : compile.browser) == null ? void 0 : _a.esbuildOptions) === "object" ? (_b = compile == null ? void 0 : compile.browser) == null ? void 0 : _b.esbuildOptions : {};
|
|
88
95
|
return folder ? (await Promise.all([
|
|
89
96
|
compileFolder(
|
|
90
97
|
folder,
|
|
@@ -92,13 +99,17 @@ const packageCompileTsup = async (config) => {
|
|
|
92
99
|
{
|
|
93
100
|
bundle: true,
|
|
94
101
|
format: ["cjs"],
|
|
95
|
-
loader:
|
|
102
|
+
loader: (0, import_lodash.merge)(
|
|
103
|
+
{},
|
|
104
|
+
{ ".gif": "copy", ".html": "copy", ".jpg": "copy", ".json": "json", ".png": "copy", ".svg": "copy", ".webp": "copy" },
|
|
105
|
+
inEsBuildOptions == null ? void 0 : inEsBuildOptions.loader
|
|
106
|
+
),
|
|
96
107
|
outDir: "dist/browser",
|
|
97
108
|
outExtension: ({ format }) => format === "esm" ? { js: ".js" } : { js: ".cjs" },
|
|
98
109
|
platform: "browser",
|
|
99
110
|
skipNodeModulesBundle: true,
|
|
100
111
|
target: "esnext",
|
|
101
|
-
...((
|
|
112
|
+
...((_c = compile == null ? void 0 : compile.tsup) == null ? void 0 : _c.options) ?? {},
|
|
102
113
|
...typeof options === "object" ? options : {}
|
|
103
114
|
},
|
|
104
115
|
verbose
|
|
@@ -109,13 +120,17 @@ const packageCompileTsup = async (config) => {
|
|
|
109
120
|
{
|
|
110
121
|
bundle: true,
|
|
111
122
|
format: ["esm"],
|
|
112
|
-
loader:
|
|
123
|
+
loader: (0, import_lodash.merge)(
|
|
124
|
+
{},
|
|
125
|
+
{ ".gif": "copy", ".html": "copy", ".jpg": "copy", ".json": "json", ".png": "copy", ".svg": "copy", ".webp": "copy" },
|
|
126
|
+
inEsBuildOptions == null ? void 0 : inEsBuildOptions.loader
|
|
127
|
+
),
|
|
113
128
|
outDir: "dist/browser",
|
|
114
129
|
outExtension: ({ format }) => format === "esm" ? { js: ".js" } : { js: ".cjs" },
|
|
115
130
|
platform: "browser",
|
|
116
131
|
skipNodeModulesBundle: true,
|
|
117
132
|
target: "esnext",
|
|
118
|
-
...((
|
|
133
|
+
...((_d = compile == null ? void 0 : compile.tsup) == null ? void 0 : _d.options) ?? {},
|
|
119
134
|
...typeof options === "object" ? options : {}
|
|
120
135
|
},
|
|
121
136
|
verbose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/package/compile/packageCompileTsup.ts"],"sourcesContent":["import { build, defineConfig, Options } from 'tsup'\n\nimport { packagePublint } from '../publint'\nimport { buildEntries } from './buildEntries'\nimport { packageCompileTsc } from './packageCompileTsc'\nimport { packageCompileTscTypes } from './packageCompileTscTypes'\nimport { EntryMode, XyTsupConfig } from './XyConfig'\n\nconst compileFolder = async (folder: string, entryMode: EntryMode = 'single', options?: Options, verbose?: boolean) => {\n const outDir = options?.outDir ?? 'dist'\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: ['cjs', '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])\n .map<Promise<Options[]>>(async (options) => {\n const result = typeof options === 'function' ? await options({}) : [options]\n return Array.isArray(result) ? result : [result]\n })\n .flat(),\n )\n ).flat()\n\n await Promise.all(optionsList.map((options) => build(options)))\n await packageCompileTscTypes(folder, { verbose }, { outDir })\n\n return 0\n}\n\nexport const packageCompileTsup = async (config?: XyTsupConfig) => {\n const compile = config?.compile\n const publint = config?.publint ?? true\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\n return (\n (await packageCompileTsc(true, { publint: false, verbose })) ||\n (\n await Promise.all(\n Object.entries(compileForNode).map(async ([folder, options]) => {\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['cjs', 'esm'],\n loader: { '.gif': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n outDir: 'dist/node',\n platform: 'node',\n skipNodeModulesBundle: true,\n target: 'node16',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\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 return folder\n ? (\n await Promise.all([\n compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['cjs'],\n loader: { '.gif': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n outDir: 'dist/browser',\n outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),\n platform: 'browser',\n skipNodeModulesBundle: true,\n target: 'esnext',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n ),\n compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['esm'],\n loader: { '.gif': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n outDir: 'dist/browser',\n outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),\n platform: 'browser',\n skipNodeModulesBundle: true,\n target: 'esnext',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n ),\n ])\n ).reduce((prev, value) => prev + value, 0)\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0) ||\n (publint ? await packagePublint() : 0)\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6C;AAE7C,qBAA+B;AAC/B,0BAA6B;AAC7B,+BAAkC;AAClC,oCA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,QAAQ,CAAC,MAExD,MAAM,QAAQ;AAAA,IACZ,OAAO,QAAQ,cAAc,EAAE,IAAI,OAAO,CAAC,QAAQ,OAAO,MAAM;
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/package/compile/packageCompileTsup.ts"],"sourcesContent":["import { merge } from 'lodash'\nimport { build, defineConfig, Options } from 'tsup'\n\nimport { packagePublint } from '../publint'\nimport { buildEntries } from './buildEntries'\nimport { packageCompileTsc } from './packageCompileTsc'\nimport { packageCompileTscTypes } from './packageCompileTscTypes'\nimport { EntryMode, XyTsupConfig } from './XyConfig'\n\nconst compileFolder = async (folder: string, entryMode: EntryMode = 'single', options?: Options, verbose?: boolean) => {\n const outDir = options?.outDir ?? 'dist'\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: ['cjs', '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])\n .map<Promise<Options[]>>(async (options) => {\n const result = typeof options === 'function' ? await options({}) : [options]\n return Array.isArray(result) ? result : [result]\n })\n .flat(),\n )\n ).flat()\n\n await Promise.all(optionsList.map((options) => build(options)))\n await packageCompileTscTypes(folder, { verbose }, { outDir })\n\n return 0\n}\n\nexport const packageCompileTsup = async (config?: XyTsupConfig) => {\n const compile = config?.compile\n const publint = config?.publint ?? true\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\n return (\n (await packageCompileTsc(true, { publint: false, verbose })) ||\n (\n await Promise.all(\n Object.entries(compileForNode).map(async ([folder, options]) => {\n const inEsBuildOptions = typeof compile?.node?.esbuildOptions === 'object' ? compile?.node?.esbuildOptions : {}\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['cjs', 'esm'],\n loader: merge(\n {},\n { '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n inEsBuildOptions?.loader,\n ),\n outDir: 'dist/node',\n platform: 'node',\n skipNodeModulesBundle: true,\n target: 'node16',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\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 inEsBuildOptions = typeof compile?.browser?.esbuildOptions === 'object' ? compile?.browser?.esbuildOptions : {}\n return folder\n ? (\n await Promise.all([\n compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['cjs'],\n loader: merge(\n {},\n { '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n inEsBuildOptions?.loader,\n ),\n outDir: 'dist/browser',\n outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),\n platform: 'browser',\n skipNodeModulesBundle: true,\n target: 'esnext',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n ),\n compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['esm'],\n loader: merge(\n {},\n { '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n inEsBuildOptions?.loader,\n ),\n outDir: 'dist/browser',\n outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),\n platform: 'browser',\n skipNodeModulesBundle: true,\n target: 'esnext',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n ),\n ])\n ).reduce((prev, value) => pr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OAAO,CAAC,MAAM,UAAU,OAAO,OAAO,CAAC,IACzC;AAAA,IACN,CAAC;AAAA,EACH,GACA,OAAO,CAAC,MAAM,UAAU,OAAO,OAAO,CAAC,MACxC,UAAU,UAAM,+BAAe,IAAI;AAExC;","names":["options"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { merge } from "lodash";
|
|
1
2
|
import { build, defineConfig } from "tsup";
|
|
2
3
|
import { packagePublint } from "../publint";
|
|
3
4
|
import { buildEntries } from "./buildEntries";
|
|
@@ -41,19 +42,24 @@ const packageCompileTsup = async (config) => {
|
|
|
41
42
|
const compileForBrowser = (compile == null ? void 0 : compile.browser) ?? { src: {} };
|
|
42
43
|
return await packageCompileTsc(true, { publint: false, verbose }) || (await Promise.all(
|
|
43
44
|
Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
44
|
-
var _a;
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
const inEsBuildOptions = typeof ((_a = compile == null ? void 0 : compile.node) == null ? void 0 : _a.esbuildOptions) === "object" ? (_b = compile == null ? void 0 : compile.node) == null ? void 0 : _b.esbuildOptions : {};
|
|
45
47
|
return folder ? await compileFolder(
|
|
46
48
|
folder,
|
|
47
49
|
compile == null ? void 0 : compile.entryMode,
|
|
48
50
|
{
|
|
49
51
|
bundle: true,
|
|
50
52
|
format: ["cjs", "esm"],
|
|
51
|
-
loader:
|
|
53
|
+
loader: merge(
|
|
54
|
+
{},
|
|
55
|
+
{ ".gif": "copy", ".html": "copy", ".jpg": "copy", ".json": "json", ".png": "copy", ".svg": "copy", ".webp": "copy" },
|
|
56
|
+
inEsBuildOptions == null ? void 0 : inEsBuildOptions.loader
|
|
57
|
+
),
|
|
52
58
|
outDir: "dist/node",
|
|
53
59
|
platform: "node",
|
|
54
60
|
skipNodeModulesBundle: true,
|
|
55
61
|
target: "node16",
|
|
56
|
-
...((
|
|
62
|
+
...((_c = compile == null ? void 0 : compile.tsup) == null ? void 0 : _c.options) ?? {},
|
|
57
63
|
...typeof options === "object" ? options : {}
|
|
58
64
|
},
|
|
59
65
|
verbose
|
|
@@ -61,7 +67,8 @@ const packageCompileTsup = async (config) => {
|
|
|
61
67
|
})
|
|
62
68
|
)).reduce((prev, value) => prev + value, 0) || (await Promise.all(
|
|
63
69
|
Object.entries(compileForBrowser).map(async ([folder, options]) => {
|
|
64
|
-
var _a, _b;
|
|
70
|
+
var _a, _b, _c, _d;
|
|
71
|
+
const inEsBuildOptions = typeof ((_a = compile == null ? void 0 : compile.browser) == null ? void 0 : _a.esbuildOptions) === "object" ? (_b = compile == null ? void 0 : compile.browser) == null ? void 0 : _b.esbuildOptions : {};
|
|
65
72
|
return folder ? (await Promise.all([
|
|
66
73
|
compileFolder(
|
|
67
74
|
folder,
|
|
@@ -69,13 +76,17 @@ const packageCompileTsup = async (config) => {
|
|
|
69
76
|
{
|
|
70
77
|
bundle: true,
|
|
71
78
|
format: ["cjs"],
|
|
72
|
-
loader:
|
|
79
|
+
loader: merge(
|
|
80
|
+
{},
|
|
81
|
+
{ ".gif": "copy", ".html": "copy", ".jpg": "copy", ".json": "json", ".png": "copy", ".svg": "copy", ".webp": "copy" },
|
|
82
|
+
inEsBuildOptions == null ? void 0 : inEsBuildOptions.loader
|
|
83
|
+
),
|
|
73
84
|
outDir: "dist/browser",
|
|
74
85
|
outExtension: ({ format }) => format === "esm" ? { js: ".js" } : { js: ".cjs" },
|
|
75
86
|
platform: "browser",
|
|
76
87
|
skipNodeModulesBundle: true,
|
|
77
88
|
target: "esnext",
|
|
78
|
-
...((
|
|
89
|
+
...((_c = compile == null ? void 0 : compile.tsup) == null ? void 0 : _c.options) ?? {},
|
|
79
90
|
...typeof options === "object" ? options : {}
|
|
80
91
|
},
|
|
81
92
|
verbose
|
|
@@ -86,13 +97,17 @@ const packageCompileTsup = async (config) => {
|
|
|
86
97
|
{
|
|
87
98
|
bundle: true,
|
|
88
99
|
format: ["esm"],
|
|
89
|
-
loader:
|
|
100
|
+
loader: merge(
|
|
101
|
+
{},
|
|
102
|
+
{ ".gif": "copy", ".html": "copy", ".jpg": "copy", ".json": "json", ".png": "copy", ".svg": "copy", ".webp": "copy" },
|
|
103
|
+
inEsBuildOptions == null ? void 0 : inEsBuildOptions.loader
|
|
104
|
+
),
|
|
90
105
|
outDir: "dist/browser",
|
|
91
106
|
outExtension: ({ format }) => format === "esm" ? { js: ".js" } : { js: ".cjs" },
|
|
92
107
|
platform: "browser",
|
|
93
108
|
skipNodeModulesBundle: true,
|
|
94
109
|
target: "esnext",
|
|
95
|
-
...((
|
|
110
|
+
...((_d = compile == null ? void 0 : compile.tsup) == null ? void 0 : _d.options) ?? {},
|
|
96
111
|
...typeof options === "object" ? options : {}
|
|
97
112
|
},
|
|
98
113
|
verbose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/package/compile/packageCompileTsup.ts"],"sourcesContent":["import { build, defineConfig, Options } from 'tsup'\n\nimport { packagePublint } from '../publint'\nimport { buildEntries } from './buildEntries'\nimport { packageCompileTsc } from './packageCompileTsc'\nimport { packageCompileTscTypes } from './packageCompileTscTypes'\nimport { EntryMode, XyTsupConfig } from './XyConfig'\n\nconst compileFolder = async (folder: string, entryMode: EntryMode = 'single', options?: Options, verbose?: boolean) => {\n const outDir = options?.outDir ?? 'dist'\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: ['cjs', '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])\n .map<Promise<Options[]>>(async (options) => {\n const result = typeof options === 'function' ? await options({}) : [options]\n return Array.isArray(result) ? result : [result]\n })\n .flat(),\n )\n ).flat()\n\n await Promise.all(optionsList.map((options) => build(options)))\n await packageCompileTscTypes(folder, { verbose }, { outDir })\n\n return 0\n}\n\nexport const packageCompileTsup = async (config?: XyTsupConfig) => {\n const compile = config?.compile\n const publint = config?.publint ?? true\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\n return (\n (await packageCompileTsc(true, { publint: false, verbose })) ||\n (\n await Promise.all(\n Object.entries(compileForNode).map(async ([folder, options]) => {\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['cjs', 'esm'],\n loader: { '.gif': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n outDir: 'dist/node',\n platform: 'node',\n skipNodeModulesBundle: true,\n target: 'node16',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\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 return folder\n ? (\n await Promise.all([\n compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['cjs'],\n loader: { '.gif': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n outDir: 'dist/browser',\n outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),\n platform: 'browser',\n skipNodeModulesBundle: true,\n target: 'esnext',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n ),\n compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['esm'],\n loader: { '.gif': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n outDir: 'dist/browser',\n outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),\n platform: 'browser',\n skipNodeModulesBundle: true,\n target: 'esnext',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n ),\n ])\n ).reduce((prev, value) => prev + value, 0)\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0) ||\n (publint ? await packagePublint() : 0)\n )\n}\n"],"mappings":"AAAA,SAAS,OAAO,oBAA6B;AAE7C,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAGvC,MAAM,gBAAgB,OAAO,QAAgB,YAAuB,UAAU,SAAmB,YAAsB;AACrH,QAAM,UAAS,mCAAS,WAAU;AAClC,QAAM,QAAQ,aAAa,QAAQ,SAAS;AAC5C,QAAM,gBAAgB,aAAa;AAAA,IACjC,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,KAAK;AAAA,IACL;AAAA,IACA,QAAQ,CAAC,OAAO,KAAK;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,GAAG;AAAA,EACL,CAAC;AACD,QAAM,eACJ,MAAM,QAAQ;AAAA,KACX,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa,GAC3D,IAAwB,OAAOA,aAAY;AAC1C,YAAM,SAAS,OAAOA,aAAY,aAAa,MAAMA,SAAQ,CAAC,CAAC,IAAI,CAACA,QAAO;AAC3E,aAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AAAA,IACjD,CAAC,EACA,KAAK;AAAA,EACV,GACA,KAAK;AAEP,QAAM,QAAQ,IAAI,YAAY,IAAI,CAACA,aAAY,MAAMA,QAAO,CAAC,CAAC;AAC9D,QAAM,uBAAuB,QAAQ,EAAE,QAAQ,GAAG,EAAE,OAAO,CAAC;AAE5D,SAAO;AACT;AAEO,MAAM,qBAAqB,OAAO,WAA0B;AACjE,QAAM,UAAU,iCAAQ;AACxB,QAAM,WAAU,iCAAQ,YAAW;AACnC,QAAM,WAAU,iCAAQ,YAAW;AACnC,MAAI,SAAS;AACX,YAAQ,IAAI,+BAA+B,mCAAS,KAAK,GAAG;AAAA,EAC9D;AAEA,QAAM,kBAAiB,mCAAS,SAAQ,EAAE,KAAK,CAAC,EAAE;AAClD,QAAM,qBAAoB,mCAAS,YAAW,EAAE,KAAK,CAAC,EAAE;AAExD,SACG,MAAM,kBAAkB,MAAM,EAAE,SAAS,OAAO,QAAQ,CAAC,MAExD,MAAM,QAAQ;AAAA,IACZ,OAAO,QAAQ,cAAc,EAAE,IAAI,OAAO,CAAC,QAAQ,OAAO,MAAM;
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/package/compile/packageCompileTsup.ts"],"sourcesContent":["import { merge } from 'lodash'\nimport { build, defineConfig, Options } from 'tsup'\n\nimport { packagePublint } from '../publint'\nimport { buildEntries } from './buildEntries'\nimport { packageCompileTsc } from './packageCompileTsc'\nimport { packageCompileTscTypes } from './packageCompileTscTypes'\nimport { EntryMode, XyTsupConfig } from './XyConfig'\n\nconst compileFolder = async (folder: string, entryMode: EntryMode = 'single', options?: Options, verbose?: boolean) => {\n const outDir = options?.outDir ?? 'dist'\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: ['cjs', '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])\n .map<Promise<Options[]>>(async (options) => {\n const result = typeof options === 'function' ? await options({}) : [options]\n return Array.isArray(result) ? result : [result]\n })\n .flat(),\n )\n ).flat()\n\n await Promise.all(optionsList.map((options) => build(options)))\n await packageCompileTscTypes(folder, { verbose }, { outDir })\n\n return 0\n}\n\nexport const packageCompileTsup = async (config?: XyTsupConfig) => {\n const compile = config?.compile\n const publint = config?.publint ?? true\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\n return (\n (await packageCompileTsc(true, { publint: false, verbose })) ||\n (\n await Promise.all(\n Object.entries(compileForNode).map(async ([folder, options]) => {\n const inEsBuildOptions = typeof compile?.node?.esbuildOptions === 'object' ? compile?.node?.esbuildOptions : {}\n return folder\n ? await compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['cjs', 'esm'],\n loader: merge(\n {},\n { '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n inEsBuildOptions?.loader,\n ),\n outDir: 'dist/node',\n platform: 'node',\n skipNodeModulesBundle: true,\n target: 'node16',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\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 inEsBuildOptions = typeof compile?.browser?.esbuildOptions === 'object' ? compile?.browser?.esbuildOptions : {}\n return folder\n ? (\n await Promise.all([\n compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['cjs'],\n loader: merge(\n {},\n { '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n inEsBuildOptions?.loader,\n ),\n outDir: 'dist/browser',\n outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),\n platform: 'browser',\n skipNodeModulesBundle: true,\n target: 'esnext',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n ),\n compileFolder(\n folder,\n compile?.entryMode,\n {\n bundle: true,\n format: ['esm'],\n loader: merge(\n {},\n { '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },\n inEsBuildOptions?.loader,\n ),\n outDir: 'dist/browser',\n outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),\n platform: 'browser',\n skipNodeModulesBundle: true,\n target: 'esnext',\n ...(compile?.tsup?.options ?? {}),\n ...(typeof options === 'object' ? options : {}),\n },\n verbose,\n ),\n ])\n ).reduce((prev, value) => prev + value, 0)\n : 0\n }),\n )\n ).reduce((prev, value) => prev + value, 0) ||\n (publint ? await packagePublint() : 0)\n )\n}\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAAS,OAAO,oBAA6B;AAE7C,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAGvC,MAAM,gBAAgB,OAAO,QAAgB,YAAuB,UAAU,SAAmB,YAAsB;AACrH,QAAM,UAAS,mCAAS,WAAU;AAClC,QAAM,QAAQ,aAAa,QAAQ,SAAS;AAC5C,QAAM,gBAAgB,aAAa;AAAA,IACjC,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,KAAK;AAAA,IACL;AAAA,IACA,QAAQ,CAAC,OAAO,KAAK;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,GAAG;AAAA,EACL,CAAC;AACD,QAAM,eACJ,MAAM,QAAQ;AAAA,KACX,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa,GAC3D,IAAwB,OAAOA,aAAY;AAC1C,YAAM,SAAS,OAAOA,aAAY,aAAa,MAAMA,SAAQ,CAAC,CAAC,IAAI,CAACA,QAAO;AAC3E,aAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AAAA,IACjD,CAAC,EACA,KAAK;AAAA,EACV,GACA,KAAK;AAEP,QAAM,QAAQ,IAAI,YAAY,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AW,QAAQ,EAAE,IAAI,MAAM,IAAI,EAAE,IAAI,OAAO;AAAA,YAC/E,UAAU;AAAA,YACV,uBAAuB;AAAA,YACvB,QAAQ;AAAA,YACR,KAAI,wCAAS,SAAT,mBAAe,YAAW,CAAC;AAAA,YAC/B,GAAI,OAAO,YAAY,WAAW,UAAU,CAAC;AAAA,UAC/C;AAAA,UACA;AAAA,QACF;AAAA,MACF,CAAC,GACD,OAAO,CAAC,MAAM,UAAU,OAAO,OAAO,CAAC,IACzC;AAAA,IACN,CAAC;AAAA,EACH,GACA,OAAO,CAAC,MAAM,UAAU,OAAO,OAAO,CAAC,MACxC,UAAU,MAAM,eAAe,IAAI;AAExC;","names":["options"]}
|
package/package.json
CHANGED
|
@@ -57,37 +57,38 @@
|
|
|
57
57
|
"url": "https://github.com/xylabs/config/issues"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
61
|
-
"@rollup/plugin-json": "^6.0.
|
|
62
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
63
|
-
"@types/node": "^20.
|
|
64
|
-
"@types/yargs": "^17.0.
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^6.7.
|
|
66
|
-
"@typescript-eslint/parser": "^6.7.
|
|
67
|
-
"@xylabs/tsconfig": "~3.1.
|
|
60
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
61
|
+
"@rollup/plugin-json": "^6.0.1",
|
|
62
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
63
|
+
"@types/node": "^20.8.6",
|
|
64
|
+
"@types/yargs": "^17.0.28",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
66
|
+
"@typescript-eslint/parser": "^6.7.5",
|
|
67
|
+
"@xylabs/tsconfig": "~3.1.12",
|
|
68
|
+
"async-mutex": "^0.4.0",
|
|
68
69
|
"chalk": "^4.1.2",
|
|
69
70
|
"cosmiconfig": "^8.3.6",
|
|
70
71
|
"cosmiconfig-typescript-loader": "^5.0.0",
|
|
71
72
|
"cpy": "^8.1.2",
|
|
72
73
|
"depcheck": "^1.4.6",
|
|
73
|
-
"eslint": "^8.
|
|
74
|
+
"eslint": "^8.51.0",
|
|
74
75
|
"eslint-config-prettier": "^9.0.0",
|
|
75
|
-
"eslint-plugin-prettier": "^5.0.
|
|
76
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
76
77
|
"eslint-plugin-sonarjs": "^0.21.0",
|
|
77
78
|
"glob": "^10.3.10",
|
|
78
79
|
"jest": "^29.7.0",
|
|
79
|
-
"jest-extended": "^4.0.
|
|
80
|
+
"jest-extended": "^4.0.2",
|
|
80
81
|
"jest-mock-extended": "^3.0.5",
|
|
81
82
|
"jest-sorted": "^1.0.14",
|
|
82
83
|
"license-checker": "^25.0.1",
|
|
83
84
|
"lodash": "^4.17.21",
|
|
84
85
|
"node-cmd": "^5.0.0",
|
|
85
|
-
"npm-check-updates": "^16.14.
|
|
86
|
+
"npm-check-updates": "^16.14.6",
|
|
86
87
|
"npm-package-json-lint": "^7.0.0",
|
|
87
88
|
"npm-package-json-lint-config-default": "^6.0.0",
|
|
88
89
|
"parse-git-config": "^3.0.0",
|
|
89
90
|
"prettier": "^3.0.3",
|
|
90
|
-
"publint": "^0.2.
|
|
91
|
+
"publint": "^0.2.4",
|
|
91
92
|
"reflect-metadata": "^0.1.13",
|
|
92
93
|
"rimraf": "^4.4.1",
|
|
93
94
|
"rollup": "^3.29.4",
|
|
@@ -100,19 +101,19 @@
|
|
|
100
101
|
"tsc-prog": "^2.3.0",
|
|
101
102
|
"tslib": "^2.6.2",
|
|
102
103
|
"tsup": "^7.2.0",
|
|
103
|
-
"typedoc": "^0.25.
|
|
104
|
+
"typedoc": "^0.25.2",
|
|
104
105
|
"types-package-json": "^2.0.39",
|
|
105
106
|
"yargs": "^17.7.2"
|
|
106
107
|
},
|
|
107
108
|
"description": "TypeScript project scripts",
|
|
108
109
|
"devDependencies": {
|
|
109
|
-
"@types/eslint": "^8.44.
|
|
110
|
+
"@types/eslint": "^8.44.4",
|
|
110
111
|
"@types/license-checker": "^25.0.4",
|
|
111
112
|
"@types/lodash": "^4.14.199",
|
|
112
113
|
"@types/parse-git-config": "^3.0.2",
|
|
113
|
-
"@xylabs/eslint-config": "^3.1.
|
|
114
|
-
"@xylabs/tsconfig": "^3.1.
|
|
115
|
-
"publint": "^0.2.
|
|
114
|
+
"@xylabs/eslint-config": "^3.1.12",
|
|
115
|
+
"@xylabs/tsconfig": "^3.1.12",
|
|
116
|
+
"publint": "^0.2.4",
|
|
116
117
|
"typescript": "^5.2.2"
|
|
117
118
|
},
|
|
118
119
|
"peerDependencies": {
|
|
@@ -124,7 +125,7 @@
|
|
|
124
125
|
"utility",
|
|
125
126
|
"typescript"
|
|
126
127
|
],
|
|
127
|
-
"license": "LGPL-3.0",
|
|
128
|
+
"license": "LGPL-3.0-only",
|
|
128
129
|
"publishConfig": {
|
|
129
130
|
"access": "public"
|
|
130
131
|
},
|
|
@@ -167,5 +168,5 @@
|
|
|
167
168
|
"package-clean": "echo Not cleaning..."
|
|
168
169
|
},
|
|
169
170
|
"sideEffects": false,
|
|
170
|
-
"version": "3.1.
|
|
171
|
+
"version": "3.1.12"
|
|
171
172
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { Mutex } from 'async-mutex'
|
|
1
2
|
import { copyFile, readdir } from 'fs/promises'
|
|
2
3
|
import { TsConfigCompilerOptions } from 'tsc-prog'
|
|
3
4
|
|
|
5
|
+
const copyFileMutex = new Mutex()
|
|
6
|
+
|
|
4
7
|
const getDistTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {
|
|
5
8
|
const outDir = compilerOptions.outDir ?? 'dist'
|
|
6
9
|
return (await readdir(outDir, { recursive: true })).filter((file) => file.endsWith('d.ts')).map((file) => `${outDir}/${file}`)
|
|
@@ -12,20 +15,23 @@ const getDistTypeMapFiles = async (compilerOptions: TsConfigCompilerOptions) =>
|
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
export const copyTypeFiles = async (compilerOptions: TsConfigCompilerOptions) => {
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
distTypeFiles
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
//using a mutex since sometimes two compiles are running at once and cause a lock on windows
|
|
19
|
+
await copyFileMutex.runExclusive(async () => {
|
|
20
|
+
//hybrid packages want two copies of the types
|
|
21
|
+
const distTypeFiles = await getDistTypeFiles(compilerOptions)
|
|
22
|
+
await Promise.all(
|
|
23
|
+
distTypeFiles.map(async (file) => {
|
|
24
|
+
await copyFile(file, file.replace('d.ts', 'd.mts'))
|
|
25
|
+
await copyFile(file, file.replace('d.ts', 'd.cts'))
|
|
26
|
+
}),
|
|
27
|
+
)
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const distTypeMapFiles = await getDistTypeMapFiles(compilerOptions)
|
|
30
|
+
await Promise.all(
|
|
31
|
+
distTypeMapFiles.map(async (file) => {
|
|
32
|
+
await copyFile(file, file.replace('d.ts.map', 'd.mts.map'))
|
|
33
|
+
await copyFile(file, file.replace('d.ts.map', 'd.cts.map'))
|
|
34
|
+
}),
|
|
35
|
+
)
|
|
36
|
+
})
|
|
31
37
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { merge } from 'lodash'
|
|
1
2
|
import { build, defineConfig, Options } from 'tsup'
|
|
2
3
|
|
|
3
4
|
import { packagePublint } from '../publint'
|
|
@@ -56,6 +57,7 @@ export const packageCompileTsup = async (config?: XyTsupConfig) => {
|
|
|
56
57
|
(
|
|
57
58
|
await Promise.all(
|
|
58
59
|
Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
60
|
+
const inEsBuildOptions = typeof compile?.node?.esbuildOptions === 'object' ? compile?.node?.esbuildOptions : {}
|
|
59
61
|
return folder
|
|
60
62
|
? await compileFolder(
|
|
61
63
|
folder,
|
|
@@ -63,7 +65,11 @@ export const packageCompileTsup = async (config?: XyTsupConfig) => {
|
|
|
63
65
|
{
|
|
64
66
|
bundle: true,
|
|
65
67
|
format: ['cjs', 'esm'],
|
|
66
|
-
loader:
|
|
68
|
+
loader: merge(
|
|
69
|
+
{},
|
|
70
|
+
{ '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },
|
|
71
|
+
inEsBuildOptions?.loader,
|
|
72
|
+
),
|
|
67
73
|
outDir: 'dist/node',
|
|
68
74
|
platform: 'node',
|
|
69
75
|
skipNodeModulesBundle: true,
|
|
@@ -80,6 +86,7 @@ export const packageCompileTsup = async (config?: XyTsupConfig) => {
|
|
|
80
86
|
(
|
|
81
87
|
await Promise.all(
|
|
82
88
|
Object.entries(compileForBrowser).map(async ([folder, options]) => {
|
|
89
|
+
const inEsBuildOptions = typeof compile?.browser?.esbuildOptions === 'object' ? compile?.browser?.esbuildOptions : {}
|
|
83
90
|
return folder
|
|
84
91
|
? (
|
|
85
92
|
await Promise.all([
|
|
@@ -89,7 +96,11 @@ export const packageCompileTsup = async (config?: XyTsupConfig) => {
|
|
|
89
96
|
{
|
|
90
97
|
bundle: true,
|
|
91
98
|
format: ['cjs'],
|
|
92
|
-
loader:
|
|
99
|
+
loader: merge(
|
|
100
|
+
{},
|
|
101
|
+
{ '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },
|
|
102
|
+
inEsBuildOptions?.loader,
|
|
103
|
+
),
|
|
93
104
|
outDir: 'dist/browser',
|
|
94
105
|
outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),
|
|
95
106
|
platform: 'browser',
|
|
@@ -106,7 +117,11 @@ export const packageCompileTsup = async (config?: XyTsupConfig) => {
|
|
|
106
117
|
{
|
|
107
118
|
bundle: true,
|
|
108
119
|
format: ['esm'],
|
|
109
|
-
loader:
|
|
120
|
+
loader: merge(
|
|
121
|
+
{},
|
|
122
|
+
{ '.gif': 'copy', '.html': 'copy', '.jpg': 'copy', '.json': 'json', '.png': 'copy', '.svg': 'copy', '.webp': 'copy' },
|
|
123
|
+
inEsBuildOptions?.loader,
|
|
124
|
+
),
|
|
110
125
|
outDir: 'dist/browser',
|
|
111
126
|
outExtension: ({ format }) => (format === 'esm' ? { js: '.js' } : { js: '.cjs' }),
|
|
112
127
|
platform: 'browser',
|