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.
- package/dist/_chunks/index.mjs +1 -1
- package/dist/cli/common.mjs +24 -18
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +0 -8
- package/dist/types/index.d.ts +0 -8
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/common.mjs
CHANGED
|
@@ -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
|
-
|
|
336
|
-
|
|
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
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
444
|
+
if (hasTypeExport("ModuleRuntimeRouteRulesConfig")) {
|
|
439
445
|
const importName = `_${hash(`${configKey}ModuleRuntimeRouteRulesConfig`)}`;
|
|
440
446
|
options.importItems[configKey].import.push({
|
|
441
447
|
name: `ModuleRuntimeRouteRulesConfig as ${importName}`,
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -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/dist/types/index.d.ts
CHANGED
|
@@ -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
|
/**
|