@silgi/module-builder 0.4.3 → 0.4.5
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,4 +1,4 @@
|
|
1
|
-
import { existsSync, promises
|
1
|
+
import { existsSync, promises } from 'node:fs';
|
2
2
|
import { writeFile, mkdir } from 'node:fs/promises';
|
3
3
|
import { join } from 'node:path';
|
4
4
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
@@ -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.CthaFlaR.mjs';
|
19
19
|
|
20
20
|
const srcDir = fileURLToPath(new URL("src", import.meta.url));
|
21
21
|
const subpaths = [
|
@@ -53,53 +53,9 @@ const build = defineCommand({
|
|
53
53
|
async run(context) {
|
54
54
|
const { build } = await import('unbuild');
|
55
55
|
const cwd = resolve(context.args.cwd || context.args.rootDir || ".");
|
56
|
-
|
56
|
+
const packageData = await readPackageJSON(cwd);
|
57
57
|
const jiti = createJiti(cwd);
|
58
58
|
const outDir = context.args.outDir || "dist";
|
59
|
-
function check() {
|
60
|
-
if (packageData) {
|
61
|
-
const expectedExports = {
|
62
|
-
".": {
|
63
|
-
import: {
|
64
|
-
types: "./dist/module.d.ts",
|
65
|
-
default: "./dist/module.mjs"
|
66
|
-
}
|
67
|
-
},
|
68
|
-
"./module": {
|
69
|
-
types: "./dist/module.d.ts",
|
70
|
-
import: "./dist/module.mjs"
|
71
|
-
},
|
72
|
-
"./runtime": {
|
73
|
-
silgi: "./dist/runtime/index.ts",
|
74
|
-
silgiTypes: "./dist/runtime/index.ts",
|
75
|
-
types: "./runtime.d.ts",
|
76
|
-
import: "./dist/runtime/index.mjs"
|
77
|
-
},
|
78
|
-
"./runtime/*": {
|
79
|
-
silgi: "./dist/runtime/*.ts",
|
80
|
-
silgiTypes: "./dist/runtime/*.ts",
|
81
|
-
types: "./dist/runtime/*.d.ts",
|
82
|
-
import: "./dist/runtime/*.mjs"
|
83
|
-
}
|
84
|
-
};
|
85
|
-
packageData.exports = defu(packageData.exports, expectedExports);
|
86
|
-
packageData = defu(packageData, {
|
87
|
-
main: "./dist/module.mjs",
|
88
|
-
types: "./dist/module.d.ts",
|
89
|
-
scripts: {
|
90
|
-
"build": "pnpm silgi-module-build build",
|
91
|
-
"build:stub": "pnpm silgi-module-build build --stub",
|
92
|
-
"test": "vitest",
|
93
|
-
"test:coverage": "vitest run --coverage"
|
94
|
-
}
|
95
|
-
});
|
96
|
-
}
|
97
|
-
writeFileSync(resolve(cwd, "package.json"), JSON.stringify(packageData, null, 2));
|
98
|
-
}
|
99
|
-
if (context.args.check) {
|
100
|
-
check();
|
101
|
-
return;
|
102
|
-
}
|
103
59
|
const rootPkg = await readPackageJSON(join(pkgDir, "package.json"));
|
104
60
|
await build(cwd, false, {
|
105
61
|
declaration: "node16",
|
@@ -112,7 +68,7 @@ const build = defineCommand({
|
|
112
68
|
entries: [
|
113
69
|
"src/module",
|
114
70
|
{
|
115
|
-
input: "src/data",
|
71
|
+
input: "src/data/",
|
116
72
|
outDir: `${outDir}/data`,
|
117
73
|
addRelativeDeclarationExtensions: true,
|
118
74
|
ext: "js",
|
@@ -127,10 +83,8 @@ const build = defineCommand({
|
|
127
83
|
{
|
128
84
|
input: "src/runtime/",
|
129
85
|
outDir: `${outDir}/runtime`,
|
130
|
-
|
131
|
-
|
132
|
-
// addRelativeDeclarationExtensions: true,
|
133
|
-
// ext: 'js',
|
86
|
+
addRelativeDeclarationExtensions: true,
|
87
|
+
ext: "js",
|
134
88
|
pattern: [
|
135
89
|
"**",
|
136
90
|
"!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
|
@@ -138,13 +92,20 @@ const build = defineCommand({
|
|
138
92
|
"!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
|
139
93
|
// ignore tests
|
140
94
|
]
|
141
|
-
// esbuild: {
|
142
|
-
// jsxImportSource: 'vue',
|
143
|
-
// jsx: 'automatic',
|
144
|
-
// jsxFactory: 'h',
|
145
|
-
// },
|
146
95
|
},
|
147
|
-
{
|
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
|
+
}
|
148
109
|
],
|
149
110
|
rollup: {
|
150
111
|
esbuild: {
|
@@ -258,7 +219,7 @@ const build = defineCommand({
|
|
258
219
|
"build:prepare": async function(_ctx) {
|
259
220
|
for (const subpath of subpaths) {
|
260
221
|
await writeFile(
|
261
|
-
`./${subpath}.d.
|
222
|
+
`./${subpath}.d.mts`,
|
262
223
|
`export * from './dist/${subpath}/index';`
|
263
224
|
);
|
264
225
|
}
|
@@ -295,7 +256,7 @@ const build = defineCommand({
|
|
295
256
|
}
|
296
257
|
});
|
297
258
|
async function writeTypes(options, isStub, _moduleMeta) {
|
298
|
-
const dtsFile = resolve(options.outDir, "moduleTypes.d.
|
259
|
+
const dtsFile = resolve(options.outDir, "moduleTypes.d.mts");
|
299
260
|
if (existsSync(dtsFile)) {
|
300
261
|
return;
|
301
262
|
}
|
@@ -384,7 +345,7 @@ export * from '${e.specifier || "./module.mjs"}'`).join("\n")}
|
|
384
345
|
`.trim().replace(/[\n\r]{3,}/g, "\n\n")}
|
385
346
|
`;
|
386
347
|
await promises.writeFile(dtsFile, dtsContents, "utf8");
|
387
|
-
await promises.writeFile(resolve(options.rootDir, "moduleTypes.d.
|
348
|
+
await promises.writeFile(resolve(options.rootDir, "moduleTypes.d.mts"), `export * from './dist/moduleTypes';
|
388
349
|
`, "utf8");
|
389
350
|
}
|
390
351
|
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.CthaFlaR.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