silgi 0.34.6 → 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.
@@ -586,7 +586,19 @@ function categorizeExports(exportedEntities, filePath) {
586
586
  }
587
587
  return { runtimeExports, typeExports };
588
588
  }
589
- function registerExportsWithHooks(silgiInstance, runtimeExports, typeExports) {
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: removeExtension(relativeWithDot(silgiInstance.options.silgi.serverDir, path)),
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: removeExtension(relativeWithDot(silgiInstance.options.build.typesDir, path))
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,7 +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
- scanSilgiExports(join(src, "runtime"));
744
755
  if (existsSync(moduleMetadataPath)) {
745
756
  buildTimeModuleMeta = JSON.parse(await promises.readFile(moduleMetadataPath, "utf-8"));
746
757
  } else {
@@ -753,6 +764,8 @@ async function _resolveSilgiModule(silgiModule, silgi) {
753
764
  };
754
765
  }
755
766
  }
767
+ const runtimeFolder = new URL("runtime", src);
768
+ await scanSilgiExports(runtimeFolder.pathname, buildTimeModuleMeta._packageName);
756
769
  } catch (error) {
757
770
  const code = error.code;
758
771
  if (code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_UNSUPPORTED_DIR_IMPORT" || code === "ENOTDIR") {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.34.6";
4
+ const version = "0.34.9";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.34.6",
4
+ "version": "0.34.9",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {