silgi 0.19.19 → 0.19.21
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 +113 -1
- package/dist/cli/types.mjs +1 -1
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- 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, 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';
|
|
@@ -333,6 +333,118 @@ async function registerModuleExportScan(silgi) {
|
|
|
333
333
|
silgi.hook("prepare:schema.ts", async (options) => {
|
|
334
334
|
for (const module of silgi.scanModules) {
|
|
335
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
|
+
}
|
|
336
448
|
continue;
|
|
337
449
|
}
|
|
338
450
|
const exports = module.meta.exports;
|
package/dist/cli/types.mjs
CHANGED
|
@@ -718,7 +718,7 @@ async function silgiGenerateType(silgi) {
|
|
|
718
718
|
}
|
|
719
719
|
const references = [];
|
|
720
720
|
if (silgi.options.preset === "npm-package") {
|
|
721
|
-
references.push({ types: relativeWithDot(
|
|
721
|
+
references.push({ types: relativeWithDot(tsconfigDir, join(silgi.options.rootDir, "dist/moduleTypes.d.ts")) });
|
|
722
722
|
}
|
|
723
723
|
await Promise.all([...silgi.options.modules, ...silgi.options._modules].map(async (id) => {
|
|
724
724
|
if (typeof id !== "string") {
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED