silgi 0.34.8 → 0.34.10
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/cli/build.mjs +22 -7
- package/dist/cli/index.mjs +1 -1
- package/dist/kit/index.d.mts +1 -1
- package/dist/kit/index.mjs +2 -2
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -586,7 +586,20 @@ function categorizeExports(exportedEntities, filePath) {
|
|
|
586
586
|
}
|
|
587
587
|
return { runtimeExports, typeExports };
|
|
588
588
|
}
|
|
589
|
-
function
|
|
589
|
+
function transformImportPath(path, packageName, relativeTo) {
|
|
590
|
+
let importPath = path;
|
|
591
|
+
if (packageName) {
|
|
592
|
+
const distMatch = importPath.match(/.*?(\/dist\/.*)/);
|
|
593
|
+
if (distMatch && distMatch[1]) {
|
|
594
|
+
importPath = packageName + distMatch[1].substring("/dist".length);
|
|
595
|
+
importPath = removeExtension(importPath, true);
|
|
596
|
+
}
|
|
597
|
+
} else if (relativeTo) {
|
|
598
|
+
importPath = removeExtension(relativeWithDot(relativeTo, path));
|
|
599
|
+
}
|
|
600
|
+
return importPath;
|
|
601
|
+
}
|
|
602
|
+
function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports, packageName) {
|
|
590
603
|
silgiInstance.hook("before:scan.ts", (options) => {
|
|
591
604
|
for (const { exportName, path, uniqueId, category } of runtimeExports) {
|
|
592
605
|
if (!path.includes("vfs")) {
|
|
@@ -607,7 +620,7 @@ function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports) {
|
|
|
607
620
|
break;
|
|
608
621
|
}
|
|
609
622
|
options.addImportItem({
|
|
610
|
-
specifier:
|
|
623
|
+
specifier: transformImportPath(path, packageName, silgiInstance.options.silgi.serverDir),
|
|
611
624
|
imports: [{ name: exportName, as: uniqueId }]
|
|
612
625
|
});
|
|
613
626
|
}
|
|
@@ -623,7 +636,7 @@ function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports) {
|
|
|
623
636
|
}
|
|
624
637
|
options.addImportItem({
|
|
625
638
|
imports: [{ name: exportName, as: uniqueId }],
|
|
626
|
-
specifier:
|
|
639
|
+
specifier: transformImportPath(path, packageName, silgiInstance.options.build.typesDir)
|
|
627
640
|
});
|
|
628
641
|
}
|
|
629
642
|
});
|
|
@@ -652,7 +665,7 @@ async function verifyDirectoryCaseSensitivity(directoryPath, rootDirectory) {
|
|
|
652
665
|
} catch {
|
|
653
666
|
}
|
|
654
667
|
}
|
|
655
|
-
async function scanSilgiExports(path, silgiInstance = useSilgiCLI()) {
|
|
668
|
+
async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI()) {
|
|
656
669
|
const processedFilePaths = /* @__PURE__ */ new Set();
|
|
657
670
|
const alreadyScannedPaths = [];
|
|
658
671
|
const serverDirectory = path || silgiInstance.options.serverDir;
|
|
@@ -698,7 +711,7 @@ async function scanSilgiExports(path, silgiInstance = useSilgiCLI()) {
|
|
|
698
711
|
allExportedEntities,
|
|
699
712
|
absoluteFilePath
|
|
700
713
|
);
|
|
701
|
-
registerExportsWithHooks(silgiInstance, runtimeExports, typeExports);
|
|
714
|
+
registerExportsWithHooks(silgiInstance, runtimeExports, typeExports, packageName);
|
|
702
715
|
} catch (error) {
|
|
703
716
|
consola.error(`Error processing file ${absoluteFilePath}:`, error);
|
|
704
717
|
}
|
|
@@ -740,8 +753,6 @@ async function _resolveSilgiModule(silgiModule, silgi) {
|
|
|
740
753
|
conditions: silgi.options.conditions
|
|
741
754
|
});
|
|
742
755
|
const moduleMetadataPath = new URL("module.json", src);
|
|
743
|
-
const runtimeFolder = new URL("runtime", src);
|
|
744
|
-
await scanSilgiExports(runtimeFolder.pathname);
|
|
745
756
|
if (existsSync(moduleMetadataPath)) {
|
|
746
757
|
buildTimeModuleMeta = JSON.parse(await promises.readFile(moduleMetadataPath, "utf-8"));
|
|
747
758
|
} else {
|
|
@@ -754,6 +765,10 @@ async function _resolveSilgiModule(silgiModule, silgi) {
|
|
|
754
765
|
};
|
|
755
766
|
}
|
|
756
767
|
}
|
|
768
|
+
if (!isPresents(["npm-package"])) {
|
|
769
|
+
const runtimeFolder = new URL("runtime", src);
|
|
770
|
+
await scanSilgiExports(runtimeFolder.pathname, buildTimeModuleMeta._packageName);
|
|
771
|
+
}
|
|
757
772
|
} catch (error) {
|
|
758
773
|
const code = error.code;
|
|
759
774
|
if (code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_UNSUPPORTED_DIR_IMPORT" || code === "ENOTDIR") {
|
package/dist/cli/index.mjs
CHANGED
package/dist/kit/index.d.mts
CHANGED
|
@@ -309,7 +309,7 @@ declare const baseHeaderBannerComment: string[];
|
|
|
309
309
|
declare function processFilePath(src: string): string;
|
|
310
310
|
declare function isPresents(names: PresetName[]): boolean;
|
|
311
311
|
declare function isRuntimePresents(names: PresetName[]): boolean;
|
|
312
|
-
declare function removeExtension(filePath: string): string;
|
|
312
|
+
declare function removeExtension(filePath: string, force?: boolean): string;
|
|
313
313
|
|
|
314
314
|
export { MODE_RE, MigrationStatus, addCommands, addCoreFile, addImports, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineFramework, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, isPresents, isRuntimePresents, listMigrations, migrationDown, migrationUp, normalizeTemplate, prettyPath, processFilePath, relativeWithDot, removeExtension, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|
|
315
315
|
export type { FunctionConfig, JsonPatch, MigrationData, MigrationInfo, MigrationOptions, MigrationResult };
|
package/dist/kit/index.mjs
CHANGED
|
@@ -67,9 +67,9 @@ function isRuntimePresents(names) {
|
|
|
67
67
|
const silgi = useSilgi();
|
|
68
68
|
return names.includes(silgi.options.present);
|
|
69
69
|
}
|
|
70
|
-
function removeExtension(filePath) {
|
|
70
|
+
function removeExtension(filePath, force = false) {
|
|
71
71
|
const silgi = useSilgiCLI();
|
|
72
|
-
if (silgi.options.typescript.removeFileExtension) {
|
|
72
|
+
if (silgi.options.typescript.removeFileExtension || force) {
|
|
73
73
|
const ext = extname(filePath);
|
|
74
74
|
return ext ? filePath.slice(0, -ext.length) : filePath;
|
|
75
75
|
}
|