@silgi/module-builder 0.4.2 → 0.4.4

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.
@@ -1,4 +1,4 @@
1
- import { promises, existsSync, writeFileSync } from 'node:fs';
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.Dq1Ki07P.mjs';
18
+ import { v as version, n as name } from '../shared/silgi-module-builder.B__EJalk.mjs';
19
19
 
20
20
  const srcDir = fileURLToPath(new URL("src", import.meta.url));
21
21
  const subpaths = [
@@ -53,56 +53,12 @@ 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
- let packageData = await readPackageJSON(cwd);
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
- declaration: true,
61
+ declaration: "node16",
106
62
  sourcemap: context.args.sourcemap,
107
63
  stub: context.args.stub,
108
64
  outDir,
@@ -112,19 +68,23 @@ 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
- builder: "mkdist",
118
- format: "esm",
119
- pattern: ["**", "!**/*.stories.{js,cts,mts,ts,jsx,tsx}", "!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"]
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
+ ]
120
82
  },
121
83
  {
122
84
  input: "src/runtime/",
123
85
  outDir: `${outDir}/runtime`,
124
- builder: "mkdist",
125
- format: "esm",
126
- // addRelativeDeclarationExtensions: true,
127
- // ext: 'js',
86
+ addRelativeDeclarationExtensions: true,
87
+ ext: "js",
128
88
  pattern: [
129
89
  "**",
130
90
  "!**/*.stories.{js,cts,mts,ts,jsx,tsx}",
@@ -132,13 +92,20 @@ const build = defineCommand({
132
92
  "!**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}"
133
93
  // ignore tests
134
94
  ]
135
- // esbuild: {
136
- // jsxImportSource: 'vue',
137
- // jsx: 'automatic',
138
- // jsxFactory: 'h',
139
- // },
140
95
  },
141
- { input: "src/types/index.ts" }
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
+ }
142
109
  ],
143
110
  rollup: {
144
111
  esbuild: {
@@ -256,6 +223,19 @@ const build = defineCommand({
256
223
  `export * from './dist/${subpath}/index';`
257
224
  );
258
225
  }
226
+ },
227
+ "build:done": async function(ctx) {
228
+ const logs = [...ctx.warnings].filter((l) => l.startsWith("Potential missing package.json files:"));
229
+ if (logs.filter((l) => l.match(/\.d\.ts/)).length > 0) {
230
+ 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.`);
231
+ }
232
+ if (logs.filter((l) => l.match(/module\.cjs/)).length > 0) {
233
+ 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\`.`);
234
+ }
235
+ const pkg = await readPackageJSON(cwd);
236
+ if (pkg?.types && !existsSync(resolve(cwd, pkg.types))) {
237
+ 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.`);
238
+ }
259
239
  }
260
240
  },
261
241
  stubOptions: {
@@ -358,8 +338,10 @@ ${schemaShims.join("\n")}
358
338
  ${moduleExports.length ? `
359
339
  ${moduleExports.join("\n")}` : ""}
360
340
  ${isStub ? 'export * from "./module.mjs"' : ""}
361
- ${moduleReExports[0] ? `
362
- export { ${moduleReExports[0].names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from './module.mjs'` : ""}
341
+ ${moduleReExports.filter((e) => e.type === "named" || e.type === "default").map((e) => `
342
+ export { ${e.names.map((n) => (n === "default" ? "" : "type ") + n).join(", ")} } from '${e.specifier || "./module.mjs"}'`).join("\n")}
343
+ ${moduleReExports.filter((e) => e.type === "star").map((e) => `
344
+ export * from '${e.specifier || "./module.mjs"}'`).join("\n")}
363
345
  `.trim().replace(/[\n\r]{3,}/g, "\n\n")}
364
346
  `;
365
347
  await promises.writeFile(dtsFile, dtsContents, "utf8");
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.Dq1Ki07P.mjs';
4
+ import { v as version, d as description, n as name } from './shared/silgi-module-builder.B__EJalk.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
@@ -16,4 +16,4 @@ import 'silgi/runtime/meta';
16
16
  import 'tsconfck';
17
17
  import 'typescript';
18
18
  import 'unimport';
19
- import './shared/silgi-module-builder.Dq1Ki07P.mjs';
19
+ import './shared/silgi-module-builder.B__EJalk.mjs';
@@ -1,5 +1,5 @@
1
1
  const name = "@silgi/module-builder";
2
- const version = "0.4.2";
2
+ const version = "0.4.4";
3
3
  const description = "Complete solution for building Silgi modules";
4
4
 
5
5
  export { description as d, name as n, version as v };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silgi/module-builder",
3
3
  "type": "module",
4
- "version": "0.4.2",
4
+ "version": "0.4.4",
5
5
  "private": false,
6
6
  "description": "Complete solution for building Silgi modules",
7
7
  "exports": {
@@ -23,7 +23,7 @@
23
23
  "mlly": "^1.7.4",
24
24
  "pathe": "^2.0.3",
25
25
  "pkg-types": "^2.1.0",
26
- "silgi": "^0.27.9",
26
+ "silgi": "^0.28.1",
27
27
  "tsconfck": "^3.1.5",
28
28
  "unbuild": "^3.5.0",
29
29
  "unimport": "^5.0.0"
@@ -31,7 +31,7 @@
31
31
  "devDependencies": {
32
32
  "@antfu/eslint-config": "^4.12.0",
33
33
  "@types/node": "^22.14.1",
34
- "eslint": "^9.24.0",
34
+ "eslint": "^9.25.0",
35
35
  "typescript": "^5.8.3"
36
36
  },
37
37
  "publishConfig": {