@silgi/module-builder 0.4.4 → 0.4.6
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/chunks/build.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { existsSync, promises } from 'node:fs';
|
2
|
-
import {
|
2
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
3
3
|
import { join } from 'node:path';
|
4
4
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
5
5
|
import { defineCommand } from 'citty';
|
@@ -15,7 +15,7 @@ import { pkgDir } from 'silgi/runtime/meta';
|
|
15
15
|
import { parse } from 'tsconfck';
|
16
16
|
import { convertCompilerOptionsFromJson } from 'typescript';
|
17
17
|
import { scanExports } from 'unimport';
|
18
|
-
import { v as version, n as name } from '../shared/silgi-module-builder.
|
18
|
+
import { v as version, n as name } from '../shared/silgi-module-builder.DtliGA_j.mjs';
|
19
19
|
|
20
20
|
const srcDir = fileURLToPath(new URL("src", import.meta.url));
|
21
21
|
const subpaths = [
|
@@ -57,6 +57,39 @@ const build = defineCommand({
|
|
57
57
|
const jiti = createJiti(cwd);
|
58
58
|
const outDir = context.args.outDir || "dist";
|
59
59
|
const rootPkg = await readPackageJSON(join(pkgDir, "package.json"));
|
60
|
+
const isDataFolder = existsSync(join(cwd, "src", "data"));
|
61
|
+
const isRuntimeFolder = existsSync(join(cwd, "src", "runtime"));
|
62
|
+
const isTypesFolder = existsSync(join(cwd, "src", "types"));
|
63
|
+
const entries = [];
|
64
|
+
if (isDataFolder) {
|
65
|
+
entries.push({
|
66
|
+
input: "src/data/",
|
67
|
+
outDir: `${outDir}/data`,
|
68
|
+
builder: "rollup"
|
69
|
+
});
|
70
|
+
}
|
71
|
+
if (isRuntimeFolder) {
|
72
|
+
entries.push({
|
73
|
+
input: "src/runtime/",
|
74
|
+
outDir: `${outDir}/runtime`,
|
75
|
+
addRelativeDeclarationExtensions: true,
|
76
|
+
ext: "js",
|
77
|
+
pattern: [
|
78
|
+
"**",
|
79
|
+
"!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
|
80
|
+
// ignore storybook files
|
81
|
+
"!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
|
82
|
+
// ignore tests
|
83
|
+
]
|
84
|
+
});
|
85
|
+
}
|
86
|
+
if (isTypesFolder) {
|
87
|
+
entries.push({
|
88
|
+
input: "src/types/index.ts",
|
89
|
+
outDir: `${outDir}/types`,
|
90
|
+
builder: "rollup"
|
91
|
+
});
|
92
|
+
}
|
60
93
|
await build(cwd, false, {
|
61
94
|
declaration: "node16",
|
62
95
|
sourcemap: context.args.sourcemap,
|
@@ -64,48 +97,10 @@ const build = defineCommand({
|
|
64
97
|
outDir,
|
65
98
|
// eslint-disable-next-line ts/ban-ts-comment
|
66
99
|
// @ts-ignore
|
67
|
-
ignoreConditions: ["silgi", "silgiTypes", "pckSilgi", "pckSilgiTypes", ...packageData
|
100
|
+
ignoreConditions: ["silgi", "silgiTypes", "pckSilgi", "pckSilgiTypes", ...packageData?.config?.ignoreConditions || []],
|
68
101
|
entries: [
|
69
102
|
"src/module",
|
70
|
-
|
71
|
-
input: "src/data/",
|
72
|
-
outDir: `${outDir}/data`,
|
73
|
-
addRelativeDeclarationExtensions: true,
|
74
|
-
ext: "js",
|
75
|
-
pattern: [
|
76
|
-
"**",
|
77
|
-
"!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
|
78
|
-
// ignore storybook files
|
79
|
-
"!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
|
80
|
-
// ignore tests
|
81
|
-
]
|
82
|
-
},
|
83
|
-
{
|
84
|
-
input: "src/runtime/",
|
85
|
-
outDir: `${outDir}/runtime`,
|
86
|
-
addRelativeDeclarationExtensions: true,
|
87
|
-
ext: "js",
|
88
|
-
pattern: [
|
89
|
-
"**",
|
90
|
-
"!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
|
91
|
-
// ignore storybook files
|
92
|
-
"!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
|
93
|
-
// ignore tests
|
94
|
-
]
|
95
|
-
},
|
96
|
-
{
|
97
|
-
input: "src/types/index.ts",
|
98
|
-
outDir: `${outDir}/types`,
|
99
|
-
addRelativeDeclarationExtensions: true,
|
100
|
-
ext: "js",
|
101
|
-
pattern: [
|
102
|
-
"**",
|
103
|
-
"!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
|
104
|
-
// ignore storybook files
|
105
|
-
"!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
|
106
|
-
// ignore tests
|
107
|
-
]
|
108
|
-
}
|
103
|
+
...entries
|
109
104
|
],
|
110
105
|
rollup: {
|
111
106
|
esbuild: {
|
@@ -127,8 +122,9 @@ const build = defineCommand({
|
|
127
122
|
...Object.keys(rootPkg.peerDependencies || {})
|
128
123
|
],
|
129
124
|
hooks: {
|
130
|
-
"mkdist:entry:options": async function(_ctx, entry,
|
131
|
-
|
125
|
+
"mkdist:entry:options": async function(_ctx, entry, mkdistOptions) {
|
126
|
+
mkdistOptions.addRelativeDeclarationExtensions = true;
|
127
|
+
mkdistOptions.typescript = defu(mkdistOptions.typescript, {
|
132
128
|
compilerOptions: await loadTSCompilerOptions(entry.input)
|
133
129
|
});
|
134
130
|
},
|
@@ -216,14 +212,6 @@ const build = defineCommand({
|
|
216
212
|
await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
|
217
213
|
await writeTypes(ctx.options, ctx.options.stub);
|
218
214
|
},
|
219
|
-
"build:prepare": async function(_ctx) {
|
220
|
-
for (const subpath of subpaths) {
|
221
|
-
await writeFile(
|
222
|
-
`./${subpath}.d.ts`,
|
223
|
-
`export * from './dist/${subpath}/index';`
|
224
|
-
);
|
225
|
-
}
|
226
|
-
},
|
227
215
|
"build:done": async function(ctx) {
|
228
216
|
const logs = [...ctx.warnings].filter((l) => l.startsWith("Potential missing package.json files:"));
|
229
217
|
if (logs.filter((l) => l.match(/\.d\.ts/)).length > 0) {
|
@@ -256,7 +244,7 @@ const build = defineCommand({
|
|
256
244
|
}
|
257
245
|
});
|
258
246
|
async function writeTypes(options, isStub, _moduleMeta) {
|
259
|
-
const dtsFile = resolve(options.outDir, "moduleTypes.d.
|
247
|
+
const dtsFile = resolve(options.outDir, "moduleTypes.d.mts");
|
260
248
|
if (existsSync(dtsFile)) {
|
261
249
|
return;
|
262
250
|
}
|
@@ -345,7 +333,7 @@ export * from '${e.specifier || "./module.mjs"}'`).join("\n")}
|
|
345
333
|
`.trim().replace(/[\n\r]{3,}/g, "\n\n")}
|
346
334
|
`;
|
347
335
|
await promises.writeFile(dtsFile, dtsContents, "utf8");
|
348
|
-
await promises.writeFile(resolve(options.rootDir, "moduleTypes.d.
|
336
|
+
await promises.writeFile(resolve(options.rootDir, "moduleTypes.d.mts"), `export * from './dist/moduleTypes';
|
349
337
|
`, "utf8");
|
350
338
|
}
|
351
339
|
async function loadTSCompilerOptions(path) {
|
package/dist/cli.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import { defineCommand, runMain } from 'citty';
|
3
3
|
import { consola } from 'consola';
|
4
|
-
import { v as version, d as description, n as name } from './shared/silgi-module-builder.
|
4
|
+
import { v as version, d as description, n as name } from './shared/silgi-module-builder.DtliGA_j.mjs';
|
5
5
|
|
6
6
|
const _rDefault = (r) => r && typeof r === "object" && "default" in r ? r.default : r;
|
7
7
|
const main = defineCommand({
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@silgi/module-builder",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.4.
|
4
|
+
"version": "0.4.6",
|
5
5
|
"private": false,
|
6
6
|
"description": "Complete solution for building Silgi modules",
|
7
7
|
"exports": {
|
@@ -37,6 +37,9 @@
|
|
37
37
|
"publishConfig": {
|
38
38
|
"access": "public"
|
39
39
|
},
|
40
|
+
"resolutions": {
|
41
|
+
"@silgi/module-builder": "link:."
|
42
|
+
},
|
40
43
|
"scripts": {
|
41
44
|
"build": "unbuild",
|
42
45
|
"dev:prepare": "unbuild --stub && pnpm -r dev:prepare",
|