silgi 0.19.21 → 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.21";
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, findExports, 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,132 +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
- const moduleReExports = [];
337
- const moduleTypes = await promises.readFile(module.entryPath.replace(/\.mjs$/, "Types.d.ts"), "utf8").catch(() => "");
338
- const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
339
- for (const e of findExports(normalisedModuleTypes)) {
340
- moduleReExports.push(e);
341
- }
342
- const hasTypeExport = (name) => moduleReExports.find((exp) => exp.names?.includes(name));
343
- const configKey2 = module.meta.configKey;
344
- const moduleName2 = module.meta.name || module.meta._packageName;
345
- options.importItems[configKey2] = {
346
- import: [],
347
- from: module.meta._packageName ? moduleName2 : relativeWithDot(silgi.options.build.typesDir, module.entryPath)
348
- };
349
- if (hasTypeExport("ModuleOptions")) {
350
- const importName = `_${hash(`${configKey2}ModuleOptions`)}`;
351
- options.importItems[configKey2].import.push({
352
- name: `ModuleOptions as ${importName}`,
353
- type: true,
354
- key: importName
355
- });
356
- options.options.push({ key: configKey2, value: importName });
357
- }
358
- if (hasTypeExport("ModuleRuntimeOptions")) {
359
- const importName = `_${hash(`${configKey2}ModuleRuntimeOptions`)}`;
360
- options.importItems[configKey2].import.push({
361
- name: `ModuleRuntimeOptions as ${importName}`,
362
- type: true,
363
- key: importName
364
- });
365
- options.runtimeOptions.push({ key: configKey2, value: importName });
366
- }
367
- if (hasTypeExport("ModuleRuntimeShareds")) {
368
- const importName = `_${hash(`${configKey2}ModuleRuntimeShareds`)}`;
369
- options.importItems[configKey2].import.push({
370
- name: `ModuleRuntimeShareds as ${importName}`,
371
- type: true,
372
- key: importName
373
- });
374
- options.shareds.push({ key: configKey2, value: importName });
375
- }
376
- if (hasTypeExport("ModuleEvents")) {
377
- const importName = `_${hash(`${configKey2}ModuleEvents`)}`;
378
- options.importItems[configKey2].import.push({
379
- name: `ModuleEvents as ${importName}`,
380
- type: true,
381
- key: importName
382
- });
383
- options.events.push({ key: configKey2, value: importName });
384
- }
385
- if (hasTypeExport("ModuleRuntimeContexts")) {
386
- const importName = `_${hash(`${configKey2}ModuleRuntimeContexts`)}`;
387
- options.importItems[configKey2].import.push({
388
- name: `ModuleRuntimeContexts as ${importName}`,
389
- type: true,
390
- key: importName
391
- });
392
- options.contexts.push({ key: configKey2, value: importName });
393
- }
394
- if (hasTypeExport("ModuleHooks")) {
395
- const importName = `_${hash(`${configKey2}ModuleHooks`)}`;
396
- options.importItems[configKey2].import.push({
397
- name: `ModuleHooks as ${importName}`,
398
- type: true,
399
- key: importName
400
- });
401
- options.hooks.push({ key: configKey2, value: importName });
402
- }
403
- if (hasTypeExport("ModuleRuntimeHooks")) {
404
- const importName = `_${hash(`${configKey2}RuntimeHooks`)}`;
405
- options.importItems[configKey2].import.push({
406
- name: `ModuleRuntimeHooks as ${importName}`,
407
- type: true,
408
- key: importName
409
- });
410
- options.runtimeHooks.push({ key: configKey2, value: importName });
411
- }
412
- if (hasTypeExport("ModuleRuntimeActions")) {
413
- const importName = `_${hash(`${configKey2}ModuleRuntimeActions`)}`;
414
- options.importItems[configKey2].import.push({
415
- name: `ModuleRuntimeActions as ${importName}`,
416
- type: true,
417
- key: importName
418
- });
419
- options.actions.push({ key: configKey2, value: importName });
420
- }
421
- if (hasTypeExport("ModuleRuntimeMethods")) {
422
- const importName = `_${hash(`${configKey2}ModuleRuntimeMethods`)}`;
423
- options.importItems[configKey2].import.push({
424
- name: `ModuleRuntimeMethods as ${importName}`,
425
- type: true,
426
- key: importName
427
- });
428
- options.methods.push({ key: configKey2, value: importName });
429
- }
430
- if (hasTypeExport("ModuleRuntimeRouteRules")) {
431
- const importName = `_${hash(`${configKey2}ModuleRuntimeRouteRules`)}`;
432
- options.importItems[configKey2].import.push({
433
- name: `ModuleRuntimeRouteRules as ${importName}`,
434
- type: true,
435
- key: importName
436
- });
437
- options.routeRules.push({ key: configKey2, value: importName });
438
- }
439
- if (hasTypeExport("ModuleRuntimeRouteRulesConfig")) {
440
- const importName = `_${hash(`${configKey2}ModuleRuntimeRouteRulesConfig`)}`;
441
- options.importItems[configKey2].import.push({
442
- name: `ModuleRuntimeRouteRulesConfig as ${importName}`,
443
- type: true,
444
- key: importName
445
- });
446
- options.routeRulesConfig.push({ key: configKey2, value: importName });
447
- }
448
- continue;
335
+ const moduleReExports = [];
336
+ if (module.entryPath.endsWith("src/module.ts")) {
337
+ module.entryPath = module.entryPath.replace(/src\/module\.ts$/, "dist/module.mjs");
449
338
  }
450
- const exports = module.meta.exports;
451
- if (!exports?.length)
452
- 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));
453
348
  const configKey = module.meta.configKey;
454
349
  const moduleName = module.meta.name || module.meta._packageName;
455
350
  options.importItems[configKey] = {
456
351
  import: [],
457
352
  from: module.meta._packageName ? moduleName : relativeWithDot(silgi.options.build.typesDir, module.entryPath)
458
353
  };
459
- const exportedTypes = exports.filter((exp) => exp.type).map((exp) => exp.name);
460
- if (exportedTypes.includes("ModuleOptions")) {
354
+ if (hasTypeExport("ModuleOptions")) {
461
355
  const importName = `_${hash(`${configKey}ModuleOptions`)}`;
462
356
  options.importItems[configKey].import.push({
463
357
  name: `ModuleOptions as ${importName}`,
@@ -466,7 +360,7 @@ async function registerModuleExportScan(silgi) {
466
360
  });
467
361
  options.options.push({ key: configKey, value: importName });
468
362
  }
469
- if (exportedTypes.includes("ModuleRuntimeOptions")) {
363
+ if (hasTypeExport("ModuleRuntimeOptions")) {
470
364
  const importName = `_${hash(`${configKey}ModuleRuntimeOptions`)}`;
471
365
  options.importItems[configKey].import.push({
472
366
  name: `ModuleRuntimeOptions as ${importName}`,
@@ -475,7 +369,7 @@ async function registerModuleExportScan(silgi) {
475
369
  });
476
370
  options.runtimeOptions.push({ key: configKey, value: importName });
477
371
  }
478
- if (exportedTypes.includes("ModuleRuntimeShareds")) {
372
+ if (hasTypeExport("ModuleRuntimeShareds")) {
479
373
  const importName = `_${hash(`${configKey}ModuleRuntimeShareds`)}`;
480
374
  options.importItems[configKey].import.push({
481
375
  name: `ModuleRuntimeShareds as ${importName}`,
@@ -484,7 +378,7 @@ async function registerModuleExportScan(silgi) {
484
378
  });
485
379
  options.shareds.push({ key: configKey, value: importName });
486
380
  }
487
- if (exportedTypes.includes("ModuleEvents")) {
381
+ if (hasTypeExport("ModuleEvents")) {
488
382
  const importName = `_${hash(`${configKey}ModuleEvents`)}`;
489
383
  options.importItems[configKey].import.push({
490
384
  name: `ModuleEvents as ${importName}`,
@@ -493,7 +387,7 @@ async function registerModuleExportScan(silgi) {
493
387
  });
494
388
  options.events.push({ key: configKey, value: importName });
495
389
  }
496
- if (exportedTypes.includes("ModuleRuntimeContexts")) {
390
+ if (hasTypeExport("ModuleRuntimeContexts")) {
497
391
  const importName = `_${hash(`${configKey}ModuleRuntimeContexts`)}`;
498
392
  options.importItems[configKey].import.push({
499
393
  name: `ModuleRuntimeContexts as ${importName}`,
@@ -502,7 +396,7 @@ async function registerModuleExportScan(silgi) {
502
396
  });
503
397
  options.contexts.push({ key: configKey, value: importName });
504
398
  }
505
- if (exportedTypes.includes("ModuleHooks")) {
399
+ if (hasTypeExport("ModuleHooks")) {
506
400
  const importName = `_${hash(`${configKey}ModuleHooks`)}`;
507
401
  options.importItems[configKey].import.push({
508
402
  name: `ModuleHooks as ${importName}`,
@@ -511,7 +405,7 @@ async function registerModuleExportScan(silgi) {
511
405
  });
512
406
  options.hooks.push({ key: configKey, value: importName });
513
407
  }
514
- if (exportedTypes.includes("ModuleRuntimeHooks")) {
408
+ if (hasTypeExport("ModuleRuntimeHooks")) {
515
409
  const importName = `_${hash(`${configKey}RuntimeHooks`)}`;
516
410
  options.importItems[configKey].import.push({
517
411
  name: `ModuleRuntimeHooks as ${importName}`,
@@ -520,7 +414,7 @@ async function registerModuleExportScan(silgi) {
520
414
  });
521
415
  options.runtimeHooks.push({ key: configKey, value: importName });
522
416
  }
523
- if (exportedTypes.includes("ModuleRuntimeActions")) {
417
+ if (hasTypeExport("ModuleRuntimeActions")) {
524
418
  const importName = `_${hash(`${configKey}ModuleRuntimeActions`)}`;
525
419
  options.importItems[configKey].import.push({
526
420
  name: `ModuleRuntimeActions as ${importName}`,
@@ -529,7 +423,7 @@ async function registerModuleExportScan(silgi) {
529
423
  });
530
424
  options.actions.push({ key: configKey, value: importName });
531
425
  }
532
- if (exportedTypes.includes("ModuleRuntimeMethods")) {
426
+ if (hasTypeExport("ModuleRuntimeMethods")) {
533
427
  const importName = `_${hash(`${configKey}ModuleRuntimeMethods`)}`;
534
428
  options.importItems[configKey].import.push({
535
429
  name: `ModuleRuntimeMethods as ${importName}`,
@@ -538,7 +432,7 @@ async function registerModuleExportScan(silgi) {
538
432
  });
539
433
  options.methods.push({ key: configKey, value: importName });
540
434
  }
541
- if (exportedTypes.includes("ModuleRuntimeRouteRules")) {
435
+ if (hasTypeExport("ModuleRuntimeRouteRules")) {
542
436
  const importName = `_${hash(`${configKey}ModuleRuntimeRouteRules`)}`;
543
437
  options.importItems[configKey].import.push({
544
438
  name: `ModuleRuntimeRouteRules as ${importName}`,
@@ -547,7 +441,7 @@ async function registerModuleExportScan(silgi) {
547
441
  });
548
442
  options.routeRules.push({ key: configKey, value: importName });
549
443
  }
550
- if (exportedTypes.includes("ModuleRuntimeRouteRulesConfig")) {
444
+ if (hasTypeExport("ModuleRuntimeRouteRulesConfig")) {
551
445
  const importName = `_${hash(`${configKey}ModuleRuntimeRouteRulesConfig`)}`;
552
446
  options.importItems[configKey].import.push({
553
447
  name: `ModuleRuntimeRouteRulesConfig as ${importName}`,
@@ -1,4 +1,4 @@
1
- const version = "0.19.21";
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.21";
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.21",
4
+ "version": "0.19.22",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {