silgi 0.34.8 → 0.34.9
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 +19 -7
- package/dist/cli/index.mjs +1 -1
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -586,7 +586,19 @@ 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
|
+
}
|
|
596
|
+
} else if (relativeTo) {
|
|
597
|
+
importPath = removeExtension(relativeWithDot(relativeTo, path));
|
|
598
|
+
}
|
|
599
|
+
return importPath;
|
|
600
|
+
}
|
|
601
|
+
function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports, packageName) {
|
|
590
602
|
silgiInstance.hook("before:scan.ts", (options) => {
|
|
591
603
|
for (const { exportName, path, uniqueId, category } of runtimeExports) {
|
|
592
604
|
if (!path.includes("vfs")) {
|
|
@@ -607,7 +619,7 @@ function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports) {
|
|
|
607
619
|
break;
|
|
608
620
|
}
|
|
609
621
|
options.addImportItem({
|
|
610
|
-
specifier:
|
|
622
|
+
specifier: transformImportPath(path, packageName, silgiInstance.options.silgi.serverDir),
|
|
611
623
|
imports: [{ name: exportName, as: uniqueId }]
|
|
612
624
|
});
|
|
613
625
|
}
|
|
@@ -623,7 +635,7 @@ function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports) {
|
|
|
623
635
|
}
|
|
624
636
|
options.addImportItem({
|
|
625
637
|
imports: [{ name: exportName, as: uniqueId }],
|
|
626
|
-
specifier:
|
|
638
|
+
specifier: transformImportPath(path, packageName, silgiInstance.options.build.typesDir)
|
|
627
639
|
});
|
|
628
640
|
}
|
|
629
641
|
});
|
|
@@ -652,7 +664,7 @@ async function verifyDirectoryCaseSensitivity(directoryPath, rootDirectory) {
|
|
|
652
664
|
} catch {
|
|
653
665
|
}
|
|
654
666
|
}
|
|
655
|
-
async function scanSilgiExports(path, silgiInstance = useSilgiCLI()) {
|
|
667
|
+
async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI()) {
|
|
656
668
|
const processedFilePaths = /* @__PURE__ */ new Set();
|
|
657
669
|
const alreadyScannedPaths = [];
|
|
658
670
|
const serverDirectory = path || silgiInstance.options.serverDir;
|
|
@@ -698,7 +710,7 @@ async function scanSilgiExports(path, silgiInstance = useSilgiCLI()) {
|
|
|
698
710
|
allExportedEntities,
|
|
699
711
|
absoluteFilePath
|
|
700
712
|
);
|
|
701
|
-
registerExportsWithHooks(silgiInstance, runtimeExports, typeExports);
|
|
713
|
+
registerExportsWithHooks(silgiInstance, runtimeExports, typeExports, packageName);
|
|
702
714
|
} catch (error) {
|
|
703
715
|
consola.error(`Error processing file ${absoluteFilePath}:`, error);
|
|
704
716
|
}
|
|
@@ -740,8 +752,6 @@ async function _resolveSilgiModule(silgiModule, silgi) {
|
|
|
740
752
|
conditions: silgi.options.conditions
|
|
741
753
|
});
|
|
742
754
|
const moduleMetadataPath = new URL("module.json", src);
|
|
743
|
-
const runtimeFolder = new URL("runtime", src);
|
|
744
|
-
await scanSilgiExports(runtimeFolder.pathname);
|
|
745
755
|
if (existsSync(moduleMetadataPath)) {
|
|
746
756
|
buildTimeModuleMeta = JSON.parse(await promises.readFile(moduleMetadataPath, "utf-8"));
|
|
747
757
|
} else {
|
|
@@ -754,6 +764,8 @@ async function _resolveSilgiModule(silgiModule, silgi) {
|
|
|
754
764
|
};
|
|
755
765
|
}
|
|
756
766
|
}
|
|
767
|
+
const runtimeFolder = new URL("runtime", src);
|
|
768
|
+
await scanSilgiExports(runtimeFolder.pathname, buildTimeModuleMeta._packageName);
|
|
757
769
|
} catch (error) {
|
|
758
770
|
const code = error.code;
|
|
759
771
|
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