@silgi/module-builder 0.7.6 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.d.mts CHANGED
@@ -1 +1 @@
1
-
1
+ export { };
package/dist/cli.mjs CHANGED
@@ -1,25 +1,25 @@
1
1
  #!/usr/bin/env node
2
- import { defineCommand, runMain } from 'citty';
3
- import { consola } from 'consola';
4
- import { v as version, d as description, n as name } from './shared/silgi-module-builder.B-36xW1_.mjs';
2
+ import { description, name, version } from "./package.mjs";
3
+ import { defineCommand, runMain } from "citty";
4
+ import { consola } from "consola";
5
5
 
6
+ //#region src/cli.ts
6
7
  const _rDefault = (r) => r && typeof r === "object" && "default" in r ? r.default : r;
7
8
  const main = defineCommand({
8
- meta: {
9
- name,
10
- description,
11
- version
12
- },
13
- subCommands: {
14
- // prepare: () => import('./commands/prepare').then(_rDefault),
15
- build: () => import('./chunks/build.mjs').then(_rDefault)
16
- },
17
- setup(context) {
18
- const firstArg = context.rawArgs[0];
19
- if (context.cmd.subCommands && !(firstArg && firstArg in context.cmd.subCommands)) {
20
- consola.warn("Please specify the `build` command explicitly. In a future version of `@silgi/module-builder`, the implicit default build command will be removed.");
21
- context.rawArgs.unshift("build");
22
- }
23
- }
9
+ meta: {
10
+ name,
11
+ description,
12
+ version
13
+ },
14
+ subCommands: { build: () => import("./commands/build.mjs").then(_rDefault) },
15
+ setup(context) {
16
+ const firstArg = context.rawArgs[0];
17
+ if (context.cmd.subCommands && !(firstArg && firstArg in context.cmd.subCommands)) {
18
+ consola.warn("Please specify the `build` command explicitly. In a future version of `@silgi/module-builder`, the implicit default build command will be removed.");
19
+ context.rawArgs.unshift("build");
20
+ }
21
+ }
24
22
  });
25
23
  runMain(main);
24
+
25
+ //#endregion
@@ -0,0 +1,28 @@
1
+ import * as citty0 from "citty";
2
+
3
+ //#region src/commands/build.d.ts
4
+ declare const _default: citty0.CommandDef<{
5
+ cwd: {
6
+ type: "string";
7
+ description: string;
8
+ };
9
+ rootDir: {
10
+ type: "positional";
11
+ description: string;
12
+ required: false;
13
+ };
14
+ outDir: {
15
+ type: "string";
16
+ };
17
+ sourcemap: {
18
+ type: "boolean";
19
+ };
20
+ stub: {
21
+ type: "boolean";
22
+ };
23
+ check: {
24
+ type: "boolean";
25
+ };
26
+ }>;
27
+ //#endregion
28
+ export { _default };
@@ -0,0 +1,109 @@
1
+ import { name, version } from "../package.mjs";
2
+ import { defineCommand } from "citty";
3
+ import { consola } from "consola";
4
+ import { promises } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+ import { createJiti } from "jiti";
8
+ import "mlly";
9
+ import { resolve } from "pathe";
10
+ import { readPackageJSON } from "pkg-types";
11
+ import { pkgDir } from "silgi/runtime/meta";
12
+ import { build } from "tsdown";
13
+ import { scanExports } from "unimport";
14
+
15
+ //#region src/commands/build.ts
16
+ const subpaths = ["runtime", "types"];
17
+ var build_default = defineCommand({
18
+ meta: {
19
+ name: "build",
20
+ description: "Build module for distribution"
21
+ },
22
+ args: {
23
+ cwd: {
24
+ type: "string",
25
+ description: "Current working directory"
26
+ },
27
+ rootDir: {
28
+ type: "positional",
29
+ description: "Root directory",
30
+ required: false
31
+ },
32
+ outDir: { type: "string" },
33
+ sourcemap: { type: "boolean" },
34
+ stub: { type: "boolean" },
35
+ check: { type: "boolean" }
36
+ },
37
+ async run(context) {
38
+ const cwd = resolve(context.args.cwd || context.args.rootDir || ".");
39
+ const packageData = await readPackageJSON(cwd);
40
+ const jiti = createJiti(cwd, {
41
+ fsCache: false,
42
+ moduleCache: false,
43
+ alias: {
44
+ [`${packageData.name}/runtime/*`]: resolve(cwd, "src/runtime/*"),
45
+ ...Object.fromEntries(subpaths.map((subpath) => [`${packageData.name}/${subpath}`, resolve(cwd, `src/${subpath}/index.ts`)]))
46
+ }
47
+ });
48
+ const outDir = context.args.outDir || "dist";
49
+ const rootPkg = await readPackageJSON(join(pkgDir, "package.json"));
50
+ await build({
51
+ outDir,
52
+ entry: [
53
+ "src/module.ts",
54
+ "src/runtime",
55
+ "src/types",
56
+ "src/data",
57
+ "!src/assets",
58
+ "!src/silgi"
59
+ ],
60
+ format: "esm",
61
+ treeshake: true,
62
+ fixedExtension: true,
63
+ target: "esnext",
64
+ dts: true,
65
+ unbundle: true,
66
+ external: [
67
+ /dist[\\/]runtime[\\/]/,
68
+ "silgi",
69
+ "silgi/kit",
70
+ "silgi/runtime",
71
+ "silgi/module",
72
+ ...subpaths.map((subpath) => `${packageData.name}/${subpath}`),
73
+ ...Object.keys(packageData.dependencies || {}),
74
+ ...Object.keys(packageData.peerDependencies || {}),
75
+ ...Object.keys(rootPkg.dependencies || {}),
76
+ ...Object.keys(rootPkg.peerDependencies || {})
77
+ ],
78
+ hooks: { "build:done": async function(ctx) {
79
+ const moduleEntryPath = resolve(ctx.options.outDir, "module.mjs");
80
+ const moduleFn = await jiti.import(pathToFileURL(moduleEntryPath).toString(), { default: true }).catch((err) => {
81
+ consola.error(err);
82
+ consola.error("Cannot load module. Please check dist:", moduleEntryPath);
83
+ return null;
84
+ });
85
+ if (!moduleFn) return;
86
+ const moduleMeta = await moduleFn.getMeta?.() || {};
87
+ const moduleRawPath = resolve(ctx.options.cwd, "src/module.ts");
88
+ const _exports = await scanExports(moduleRawPath, true);
89
+ const cleanedExports = _exports.map(({ from,...rest }) => rest);
90
+ moduleMeta.exports = cleanedExports;
91
+ if (ctx.pkg) {
92
+ if (!moduleMeta.name) moduleMeta.name = ctx.pkg.name;
93
+ if (!moduleMeta.version) moduleMeta.version = ctx.pkg.version;
94
+ }
95
+ moduleMeta._packageName = ctx.pkg?.name;
96
+ if (ctx.pkg?.modules) moduleMeta._modules = ctx.pkg?.configmodules;
97
+ moduleMeta.builder = {
98
+ [name]: version,
99
+ unbuild: await readPackageJSON("unbuild").then((r) => r.version).catch(() => "unknown")
100
+ };
101
+ const metaFile = resolve(ctx.options.outDir, "module.json");
102
+ await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
103
+ } }
104
+ });
105
+ }
106
+ });
107
+
108
+ //#endregion
109
+ export { build_default as default, subpaths };
package/dist/index.d.mts CHANGED
@@ -1,27 +1,2 @@
1
- import * as citty from 'citty';
2
-
3
- declare const _default: citty.CommandDef<{
4
- cwd: {
5
- type: "string";
6
- description: string;
7
- };
8
- rootDir: {
9
- type: "positional";
10
- description: string;
11
- required: false;
12
- };
13
- outDir: {
14
- type: "string";
15
- };
16
- sourcemap: {
17
- type: "boolean";
18
- };
19
- stub: {
20
- type: "boolean";
21
- };
22
- check: {
23
- type: "boolean";
24
- };
25
- }>;
26
-
27
- export { _default as build };
1
+ import { _default } from "./commands/build.mjs";
2
+ export { _default as build };
package/dist/index.mjs CHANGED
@@ -1,19 +1,3 @@
1
- export { default as build } from './chunks/build.mjs';
2
- import 'node:fs';
3
- import 'node:fs/promises';
4
- import 'node:path';
5
- import 'node:url';
6
- import 'citty';
7
- import 'consola';
8
- import 'defu';
9
- import 'jiti';
10
- import 'magic-regexp';
11
- import 'mlly';
12
- import 'pathe';
13
- import 'pathe/utils';
14
- import 'pkg-types';
15
- import 'silgi/runtime/meta';
16
- import 'tsconfck';
17
- import 'typescript';
18
- import 'unimport';
19
- import './shared/silgi-module-builder.B-36xW1_.mjs';
1
+ import build_default from "./commands/build.mjs";
2
+
3
+ export { build_default as build };
@@ -0,0 +1,7 @@
1
+ //#region package.json
2
+ var name = "@silgi/module-builder";
3
+ var version = "0.8.1";
4
+ var description = "Complete solution for building Silgi modules";
5
+
6
+ //#endregion
7
+ export { description, name, version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silgi/module-builder",
3
3
  "type": "module",
4
- "version": "0.7.6",
4
+ "version": "0.8.1",
5
5
  "private": false,
6
6
  "description": "Complete solution for building Silgi modules",
7
7
  "exports": {
@@ -19,13 +19,11 @@
19
19
  "consola": "^3.4.2",
20
20
  "defu": "^6.1.4",
21
21
  "jiti": "^2.4.2",
22
- "magic-regexp": "^0.10.0",
23
22
  "mlly": "^1.7.4",
24
23
  "pathe": "^2.0.3",
25
24
  "pkg-types": "^2.1.0",
26
25
  "silgi": "^0.41.40",
27
- "tsconfck": "^3.1.6",
28
- "unbuild": "^3.5.0",
26
+ "tsdown": "^0.12.4",
29
27
  "unimport": "^5.0.1"
30
28
  },
31
29
  "devDependencies": {
@@ -41,9 +39,9 @@
41
39
  "@silgi/module-builder": "link:."
42
40
  },
43
41
  "scripts": {
44
- "build": "unbuild",
45
- "dev:prepare": "unbuild --stub && pnpm -r dev:prepare",
46
- "build:stub": "unbuild --stub",
42
+ "build": "tsdown",
43
+ "dev:prepare": "tsdown --watch && pnpm -r dev:prepare",
44
+ "build:watch": "tsdown --watch",
47
45
  "release": "pnpm build && pnpm publish",
48
46
  "lint": "eslint .",
49
47
  "lint:fix": "eslint . --fix"
@@ -1,355 +0,0 @@
1
- import { existsSync, promises } from 'node:fs';
2
- import { mkdir, writeFile } from 'node:fs/promises';
3
- import { join } from 'node:path';
4
- import { pathToFileURL } from 'node:url';
5
- import { defineCommand } from 'citty';
6
- import { consola } from 'consola';
7
- import defu from 'defu';
8
- import { createJiti } from 'jiti';
9
- import { createRegExp, anyOf } from 'magic-regexp';
10
- import { resolvePath, findExports, findTypeExports } from 'mlly';
11
- import { resolve, basename, normalize, dirname } from 'pathe';
12
- import { filename } from 'pathe/utils';
13
- import { readPackageJSON } from 'pkg-types';
14
- import { pkgDir } from 'silgi/runtime/meta';
15
- import { parse } from 'tsconfck';
16
- import { convertCompilerOptionsFromJson } from 'typescript';
17
- import { scanExports } from 'unimport';
18
- import { v as version, n as name } from '../shared/silgi-module-builder.B-36xW1_.mjs';
19
-
20
- const subpaths = [
21
- "runtime",
22
- "types"
23
- ];
24
- const build = defineCommand({
25
- meta: {
26
- name: "build",
27
- description: "Build module for distribution"
28
- },
29
- args: {
30
- cwd: {
31
- type: "string",
32
- description: "Current working directory"
33
- },
34
- rootDir: {
35
- type: "positional",
36
- description: "Root directory",
37
- required: false
38
- },
39
- outDir: {
40
- type: "string"
41
- },
42
- sourcemap: {
43
- type: "boolean"
44
- },
45
- stub: {
46
- type: "boolean"
47
- },
48
- check: {
49
- type: "boolean"
50
- }
51
- },
52
- async run(context) {
53
- const { build } = await import('unbuild');
54
- const cwd = resolve(context.args.cwd || context.args.rootDir || ".");
55
- const packageData = await readPackageJSON(cwd);
56
- const jiti = createJiti(cwd, {
57
- fsCache: false,
58
- moduleCache: false,
59
- alias: {
60
- [`${packageData.name}/runtime/*`]: resolve(cwd, "src/runtime/*"),
61
- ...Object.fromEntries(
62
- subpaths.map((subpath) => [
63
- `${packageData.name}/${subpath}`,
64
- resolve(cwd, `src/${subpath}/index.ts`)
65
- ])
66
- )
67
- }
68
- });
69
- const outDir = context.args.outDir || "dist";
70
- const rootPkg = await readPackageJSON(join(pkgDir, "package.json"));
71
- const isDataFolder = existsSync(join(cwd, "src", "data"));
72
- const isRuntimeFolder = existsSync(join(cwd, "src", "runtime"));
73
- const isTypesFolder = existsSync(join(cwd, "src", "types"));
74
- const entries = [];
75
- if (isDataFolder) {
76
- entries.push({
77
- input: "src/data/",
78
- outDir: `${outDir}/data`,
79
- addRelativeDeclarationExtensions: true,
80
- ext: "js",
81
- pattern: [
82
- "**",
83
- "!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
84
- // ignore storybook files
85
- "!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
86
- // ignore tests
87
- ]
88
- });
89
- }
90
- if (isRuntimeFolder) {
91
- entries.push({
92
- input: "src/runtime/",
93
- outDir: `${outDir}/runtime`,
94
- addRelativeDeclarationExtensions: true,
95
- ext: "js",
96
- pattern: [
97
- "**",
98
- "!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
99
- // ignore storybook files
100
- "!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
101
- // ignore tests
102
- ]
103
- });
104
- }
105
- if (isTypesFolder) {
106
- entries.push({
107
- input: "src/types/index.ts",
108
- outDir: `${outDir}/types`,
109
- builder: "rollup"
110
- });
111
- }
112
- await build(cwd, false, {
113
- declaration: "node16",
114
- sourcemap: context.args.sourcemap,
115
- stub: context.args.stub,
116
- outDir,
117
- // eslint-disable-next-line ts/ban-ts-comment
118
- // @ts-ignore
119
- ignoreConditions: ["silgi", "silgiTypes", "pckSilgi", "pckSilgiTypes", ...packageData?.config?.ignoreConditions || []],
120
- entries: [
121
- "src/module",
122
- ...entries
123
- ],
124
- rollup: {
125
- esbuild: {
126
- target: "esnext"
127
- },
128
- emitCJS: false,
129
- cjsBridge: false
130
- },
131
- externals: [
132
- /dist[\\/]runtime[\\/]/,
133
- "silgi",
134
- "silgi/kit",
135
- "silgi/runtime",
136
- "silgi/module",
137
- ...subpaths.map((subpath) => `${packageData.name}/${subpath}`),
138
- ...Object.keys(packageData.dependencies || {}),
139
- ...Object.keys(packageData.peerDependencies || {}),
140
- ...Object.keys(rootPkg.dependencies || {}),
141
- ...Object.keys(rootPkg.peerDependencies || {})
142
- ],
143
- hooks: {
144
- "mkdist:entry:options": async function(_ctx, entry, mkdistOptions) {
145
- mkdistOptions.addRelativeDeclarationExtensions = true;
146
- mkdistOptions.typescript = defu(mkdistOptions.typescript, {
147
- compilerOptions: await loadTSCompilerOptions(entry.input)
148
- });
149
- },
150
- "rollup:options": async function(ctx, options) {
151
- const [entry] = ctx.buildEntries;
152
- const mergedCompilerOptions = defu({
153
- noEmit: false,
154
- paths: {
155
- "#app/silgi": ["./node_modules/silgi/dist/app/silgi"]
156
- }
157
- }, ctx.options.rollup.dts.compilerOptions, await loadTSCompilerOptions(entry.path));
158
- ctx.options.rollup.dts.compilerOptions = convertCompilerOptionsFromJson(mergedCompilerOptions, entry.path).options;
159
- options.plugins ||= [];
160
- ctx.options.rollup.dts.compilerOptions.customConditions = [];
161
- if (!Array.isArray(options.plugins))
162
- options.plugins = [options.plugins];
163
- const runtimeEntries = ctx.options.entries.filter((entry2) => entry2.builder === "mkdist");
164
- const runtimeDirs = runtimeEntries.map((entry2) => basename(entry2.input));
165
- const RUNTIME_RE = createRegExp(anyOf(...runtimeDirs).and(anyOf("/", "\\")));
166
- options.plugins.unshift({
167
- name: "silgi-module-builder:runtime-externals",
168
- async resolveId(id, importer) {
169
- if (!RUNTIME_RE.test(id))
170
- return;
171
- const resolved = await this.resolve(id, importer, { skipSelf: true });
172
- if (!resolved)
173
- return;
174
- const normalizedId = normalize(resolved.id);
175
- for (const entry2 of runtimeEntries) {
176
- if (!normalizedId.includes(entry2.input))
177
- continue;
178
- const distFile = await resolvePath(join(dirname(pathToFileURL(normalizedId).href.replace(entry2.input, entry2.outDir)), filename(normalizedId)));
179
- if (distFile) {
180
- return {
181
- external: true,
182
- id: distFile
183
- };
184
- }
185
- }
186
- }
187
- });
188
- },
189
- "rollup:build": async function(ctx) {
190
- const runtimeDir = resolve(ctx.options.rootDir, "src", "runtime");
191
- const runtimeIndexPath = resolve(runtimeDir, "index.ts");
192
- if (!existsSync(runtimeDir)) {
193
- await mkdir(runtimeDir, { recursive: true });
194
- }
195
- if (!existsSync(runtimeIndexPath)) {
196
- await writeFile(runtimeIndexPath, "export default {}");
197
- }
198
- },
199
- "rollup:done": async function(ctx) {
200
- const moduleEntryPath = resolve(ctx.options.outDir, "module.mjs");
201
- const moduleFn = await jiti.import(pathToFileURL(moduleEntryPath).toString(), { default: true }).catch((err) => {
202
- consola.error(err);
203
- consola.error("Cannot load module. Please check dist:", moduleEntryPath);
204
- return null;
205
- });
206
- if (!moduleFn) {
207
- return;
208
- }
209
- const moduleMeta = await moduleFn.getMeta?.() || {};
210
- const moduleRawPath = resolve(ctx.options.rootDir, "src/module.ts");
211
- const _exports = await scanExports(moduleRawPath, true);
212
- const cleanedExports = _exports.map(({ from, ...rest }) => rest);
213
- moduleMeta.exports = cleanedExports;
214
- if (ctx.pkg) {
215
- if (!moduleMeta.name) {
216
- moduleMeta.name = ctx.pkg.name;
217
- }
218
- if (!moduleMeta.version) {
219
- moduleMeta.version = ctx.pkg.version;
220
- }
221
- }
222
- moduleMeta._packageName = ctx.pkg.name;
223
- if (ctx.pkg.modules) {
224
- moduleMeta._modules = ctx.pkg.configmodules;
225
- }
226
- moduleMeta.builder = {
227
- [name]: version,
228
- unbuild: await readPackageJSON("unbuild").then((r) => r.version).catch(() => "unknown")
229
- };
230
- const metaFile = resolve(ctx.options.outDir, "module.json");
231
- await promises.writeFile(metaFile, JSON.stringify(moduleMeta, null, 2), "utf8");
232
- await writeTypes(ctx.options);
233
- },
234
- "build:done": async function(ctx) {
235
- const logs = [...ctx.warnings].filter((l) => l.startsWith("Potential missing package.json files:"));
236
- if (logs.filter((l) => l.match(/\.d\.ts/)).length > 0) {
237
- consola.warn(`@silgi/module-builder\` will no longer generate \`.d.ts\` declaration files. You can update these paths to use the \`.d.mts\` extension instead.`);
238
- }
239
- if (logs.filter((l) => l.match(/module\.cjs/)).length > 0) {
240
- consola.warn(`@silgi/module-builder\` will no longer generate \`module.cjs\` as this is not required for Nuxt v3+. You can safely remove replace this with \`module.mjs\` in your \`package.json\`.`);
241
- }
242
- const pkg = await readPackageJSON(cwd);
243
- if (pkg?.types && !existsSync(resolve(cwd, pkg.types))) {
244
- consola.warn(`Please remove the \`types\` field from package.json as it is no longer required for Bundler TypeScript module resolution. Instead, you can use \`typesVersions\` to support subpath export types for Node10, if required.`);
245
- }
246
- }
247
- },
248
- stubOptions: {
249
- jiti: {
250
- alias: {
251
- [`${packageData.name}/runtime/*`]: resolve(cwd, "src/runtime/*"),
252
- ...Object.fromEntries(
253
- subpaths.map((subpath) => [
254
- `${packageData.name}/${subpath}`,
255
- resolve(cwd, `src/${subpath}/index.ts`)
256
- ])
257
- )
258
- }
259
- }
260
- },
261
- failOnWarn: false
262
- });
263
- }
264
- });
265
- async function writeTypes(options, _moduleMeta) {
266
- if (!options.stub) {
267
- return;
268
- }
269
- const dtsFile = resolve(options.outDir, "types/index.d.mts");
270
- const moduleReExports = [];
271
- const moduleTypesFile = resolve(options.rootDir, "src/types/index.ts");
272
- const moduleTypes = await promises.readFile(moduleTypesFile, "utf8").catch(() => "");
273
- const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
274
- for (const e of findExports(normalisedModuleTypes)) {
275
- moduleReExports.push(e);
276
- }
277
- for (const i of findTypeExports(normalisedModuleTypes)) {
278
- moduleReExports.push(i);
279
- }
280
- const moduleImports = [];
281
- const hasTypeExport = (name2) => moduleReExports.find((exp) => exp.names?.includes(name2));
282
- if (hasTypeExport("ModuleOptions")) {
283
- moduleImports.push("ModuleOptions");
284
- }
285
- if (hasTypeExport("ModuleRuntimeOptions")) {
286
- moduleImports.push("ModuleRuntimeOptions");
287
- }
288
- if (hasTypeExport("ModuleRuntimeShareds")) {
289
- moduleImports.push("ModuleRuntimeShareds");
290
- }
291
- if (hasTypeExport("ModuleEvents")) {
292
- moduleImports.push("ModuleEvents");
293
- }
294
- if (hasTypeExport("ModuleRuntimeContexts")) {
295
- moduleImports.push("ModuleRuntimeContexts");
296
- }
297
- if (hasTypeExport("ModuleHooks")) {
298
- moduleImports.push("ModuleHooks");
299
- }
300
- if (hasTypeExport("ModuleRuntimeHooks")) {
301
- moduleImports.push("ModuleRuntimeHooks");
302
- }
303
- if (hasTypeExport("SetupModuleOption")) {
304
- moduleImports.push("SetupModuleOption");
305
- }
306
- if (hasTypeExport("ModuleRuntimeMethods")) {
307
- moduleImports.push("ModuleRuntimeMethods");
308
- }
309
- if (hasTypeExport("RouteRules")) {
310
- moduleImports.push("RouteRules");
311
- }
312
- if (hasTypeExport("MetaData")) {
313
- moduleImports.push("MetaData");
314
- }
315
- let fromPath;
316
- let prevContent;
317
- if (existsSync(dtsFile)) {
318
- prevContent = await promises.readFile(dtsFile, "utf8").catch(() => "");
319
- const match = prevContent.match(/export\s+\*\s+from\s+["'](.+)["']/);
320
- if (match) {
321
- fromPath = match[1];
322
- }
323
- }
324
- let dtsContents;
325
- const importFrom = fromPath || "./module.mjs";
326
- dtsContents = `${`${moduleImports.length ? `import type { ${moduleImports.join(", ")} } from '${importFrom}'
327
-
328
- export type { ${moduleImports.join(", ")} }` : ""}`.trim()}
329
- `;
330
- let mergedContent = dtsContents;
331
- if (prevContent) {
332
- const prevLines = prevContent.split("\n").map((l) => l.trim());
333
- const newLines = dtsContents.split("\n").map((l) => l.trim());
334
- const uniqueLines = newLines.filter((line) => line && !prevLines.includes(line));
335
- mergedContent = `${uniqueLines.join("\n")}
336
- ${prevContent}`;
337
- }
338
- await promises.writeFile(dtsFile, mergedContent, "utf8");
339
- }
340
- async function loadTSCompilerOptions(path) {
341
- const config = await parse(path);
342
- const resolvedCompilerOptions = config?.tsconfig.compilerOptions || {};
343
- for (const { tsconfig, tsconfigFile } of config.extended || []) {
344
- for (const alias in tsconfig.compilerOptions?.paths || {}) {
345
- resolvedCompilerOptions.paths[alias] = resolvedCompilerOptions.paths[alias].map((p) => {
346
- if (!/^\.{1,2}(?:\/|$)/.test(p))
347
- return p;
348
- return resolve(dirname(tsconfigFile), p);
349
- });
350
- }
351
- }
352
- return resolvedCompilerOptions;
353
- }
354
-
355
- export { build as default, subpaths };
@@ -1,5 +0,0 @@
1
- const name = "@silgi/module-builder";
2
- const version = "0.7.6";
3
- const description = "Complete solution for building Silgi modules";
4
-
5
- export { description as d, name as n, version as v };