silgi 0.19.20 → 0.19.22

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
- const version = "0.19.20";
1
+ const version = "0.19.22";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -11,7 +11,7 @@ import { scanExports, createUnimport, toExports } from 'unimport';
11
11
  import { c as createRouteRules } from '../_chunks/routeRules.mjs';
12
12
  import * as p from '@clack/prompts';
13
13
  import * as dotenv from 'dotenv';
14
- import { resolveModuleExportNames, resolvePath, parseNodeModulePath, lookupNodeModuleSubpath } from 'mlly';
14
+ import { resolveModuleExportNames, findTypeExports, findExports, resolvePath, parseNodeModulePath, lookupNodeModuleSubpath } from 'mlly';
15
15
  import { createJiti } from 'dev-jiti';
16
16
  import { a as hasInstalledModule, h as hasError } from './compatibility.mjs';
17
17
  import { fileURLToPath } from 'node:url';
@@ -332,20 +332,26 @@ const frameworkSetup = [emptyFramework, h3Framework, nitroFramework, nuxtFramewo
332
332
  async function registerModuleExportScan(silgi) {
333
333
  silgi.hook("prepare:schema.ts", async (options) => {
334
334
  for (const module of silgi.scanModules) {
335
- if (module.meta._packageName || silgi.options.preset === "npm-package") {
336
- continue;
335
+ const moduleReExports = [];
336
+ if (module.entryPath.endsWith("src/module.ts")) {
337
+ module.entryPath = module.entryPath.replace(/src\/module\.ts$/, "dist/module.mjs");
337
338
  }
338
- const exports = module.meta.exports;
339
- if (!exports?.length)
340
- continue;
339
+ const moduleTypes = await promises.readFile(module.entryPath.replace(/\.mjs$/, "Types.d.ts"), "utf8").catch(() => "");
340
+ const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
341
+ for (const e of findTypeExports(normalisedModuleTypes)) {
342
+ moduleReExports.push(e);
343
+ }
344
+ for (const e of findExports(normalisedModuleTypes)) {
345
+ moduleReExports.push(e);
346
+ }
347
+ const hasTypeExport = (name) => moduleReExports.find((exp) => exp.names?.includes(name));
341
348
  const configKey = module.meta.configKey;
342
349
  const moduleName = module.meta.name || module.meta._packageName;
343
350
  options.importItems[configKey] = {
344
351
  import: [],
345
352
  from: module.meta._packageName ? moduleName : relativeWithDot(silgi.options.build.typesDir, module.entryPath)
346
353
  };
347
- const exportedTypes = exports.filter((exp) => exp.type).map((exp) => exp.name);
348
- if (exportedTypes.includes("ModuleOptions")) {
354
+ if (hasTypeExport("ModuleOptions")) {
349
355
  const importName = `_${hash(`${configKey}ModuleOptions`)}`;
350
356
  options.importItems[configKey].import.push({
351
357
  name: `ModuleOptions as ${importName}`,
@@ -354,7 +360,7 @@ async function registerModuleExportScan(silgi) {
354
360
  });
355
361
  options.options.push({ key: configKey, value: importName });
356
362
  }
357
- if (exportedTypes.includes("ModuleRuntimeOptions")) {
363
+ if (hasTypeExport("ModuleRuntimeOptions")) {
358
364
  const importName = `_${hash(`${configKey}ModuleRuntimeOptions`)}`;
359
365
  options.importItems[configKey].import.push({
360
366
  name: `ModuleRuntimeOptions as ${importName}`,
@@ -363,7 +369,7 @@ async function registerModuleExportScan(silgi) {
363
369
  });
364
370
  options.runtimeOptions.push({ key: configKey, value: importName });
365
371
  }
366
- if (exportedTypes.includes("ModuleRuntimeShareds")) {
372
+ if (hasTypeExport("ModuleRuntimeShareds")) {
367
373
  const importName = `_${hash(`${configKey}ModuleRuntimeShareds`)}`;
368
374
  options.importItems[configKey].import.push({
369
375
  name: `ModuleRuntimeShareds as ${importName}`,
@@ -372,7 +378,7 @@ async function registerModuleExportScan(silgi) {
372
378
  });
373
379
  options.shareds.push({ key: configKey, value: importName });
374
380
  }
375
- if (exportedTypes.includes("ModuleEvents")) {
381
+ if (hasTypeExport("ModuleEvents")) {
376
382
  const importName = `_${hash(`${configKey}ModuleEvents`)}`;
377
383
  options.importItems[configKey].import.push({
378
384
  name: `ModuleEvents as ${importName}`,
@@ -381,7 +387,7 @@ async function registerModuleExportScan(silgi) {
381
387
  });
382
388
  options.events.push({ key: configKey, value: importName });
383
389
  }
384
- if (exportedTypes.includes("ModuleRuntimeContexts")) {
390
+ if (hasTypeExport("ModuleRuntimeContexts")) {
385
391
  const importName = `_${hash(`${configKey}ModuleRuntimeContexts`)}`;
386
392
  options.importItems[configKey].import.push({
387
393
  name: `ModuleRuntimeContexts as ${importName}`,
@@ -390,7 +396,7 @@ async function registerModuleExportScan(silgi) {
390
396
  });
391
397
  options.contexts.push({ key: configKey, value: importName });
392
398
  }
393
- if (exportedTypes.includes("ModuleHooks")) {
399
+ if (hasTypeExport("ModuleHooks")) {
394
400
  const importName = `_${hash(`${configKey}ModuleHooks`)}`;
395
401
  options.importItems[configKey].import.push({
396
402
  name: `ModuleHooks as ${importName}`,
@@ -399,7 +405,7 @@ async function registerModuleExportScan(silgi) {
399
405
  });
400
406
  options.hooks.push({ key: configKey, value: importName });
401
407
  }
402
- if (exportedTypes.includes("ModuleRuntimeHooks")) {
408
+ if (hasTypeExport("ModuleRuntimeHooks")) {
403
409
  const importName = `_${hash(`${configKey}RuntimeHooks`)}`;
404
410
  options.importItems[configKey].import.push({
405
411
  name: `ModuleRuntimeHooks as ${importName}`,
@@ -408,7 +414,7 @@ async function registerModuleExportScan(silgi) {
408
414
  });
409
415
  options.runtimeHooks.push({ key: configKey, value: importName });
410
416
  }
411
- if (exportedTypes.includes("ModuleRuntimeActions")) {
417
+ if (hasTypeExport("ModuleRuntimeActions")) {
412
418
  const importName = `_${hash(`${configKey}ModuleRuntimeActions`)}`;
413
419
  options.importItems[configKey].import.push({
414
420
  name: `ModuleRuntimeActions as ${importName}`,
@@ -417,7 +423,7 @@ async function registerModuleExportScan(silgi) {
417
423
  });
418
424
  options.actions.push({ key: configKey, value: importName });
419
425
  }
420
- if (exportedTypes.includes("ModuleRuntimeMethods")) {
426
+ if (hasTypeExport("ModuleRuntimeMethods")) {
421
427
  const importName = `_${hash(`${configKey}ModuleRuntimeMethods`)}`;
422
428
  options.importItems[configKey].import.push({
423
429
  name: `ModuleRuntimeMethods as ${importName}`,
@@ -426,7 +432,7 @@ async function registerModuleExportScan(silgi) {
426
432
  });
427
433
  options.methods.push({ key: configKey, value: importName });
428
434
  }
429
- if (exportedTypes.includes("ModuleRuntimeRouteRules")) {
435
+ if (hasTypeExport("ModuleRuntimeRouteRules")) {
430
436
  const importName = `_${hash(`${configKey}ModuleRuntimeRouteRules`)}`;
431
437
  options.importItems[configKey].import.push({
432
438
  name: `ModuleRuntimeRouteRules as ${importName}`,
@@ -435,7 +441,7 @@ async function registerModuleExportScan(silgi) {
435
441
  });
436
442
  options.routeRules.push({ key: configKey, value: importName });
437
443
  }
438
- if (exportedTypes.includes("ModuleRuntimeRouteRulesConfig")) {
444
+ if (hasTypeExport("ModuleRuntimeRouteRulesConfig")) {
439
445
  const importName = `_${hash(`${configKey}ModuleRuntimeRouteRulesConfig`)}`;
440
446
  options.importItems[configKey].import.push({
441
447
  name: `ModuleRuntimeRouteRulesConfig as ${importName}`,
@@ -1,4 +1,4 @@
1
- const version = "0.19.20";
1
+ const version = "0.19.22";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,4 +1,4 @@
1
- const version = "0.19.20";
1
+ const version = "0.19.22";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -436,14 +436,6 @@ interface ModuleMeta {
436
436
  author?: string;
437
437
  /** Module license. */
438
438
  license?: string;
439
- /** exports */
440
- exports?: {
441
- name: string;
442
- as?: string;
443
- from?: string;
444
- type?: boolean;
445
- options?: Record<string, any>;
446
- }[];
447
439
  /** Module version. */
448
440
  version?: string;
449
441
  /**
@@ -436,14 +436,6 @@ interface ModuleMeta {
436
436
  author?: string;
437
437
  /** Module license. */
438
438
  license?: string;
439
- /** exports */
440
- exports?: {
441
- name: string;
442
- as?: string;
443
- from?: string;
444
- type?: boolean;
445
- options?: Record<string, any>;
446
- }[];
447
439
  /** Module version. */
448
440
  version?: string;
449
441
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.19.20",
4
+ "version": "0.19.22",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {