@faapi/faapi 4.1.0 → 4.2.0

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/testing.js CHANGED
@@ -2842,6 +2842,15 @@ function toStrippedProdImportPath(sourceFile, rootDir) {
2842
2842
  if (!rel.startsWith(".")) rel = "./" + rel;
2843
2843
  return toProdExtension(rel);
2844
2844
  }
2845
+ function toProdImportFromImporter(importer, rootDir, relFromDist) {
2846
+ const importerRel = path8.relative(toRealPath(path8.resolve(rootDir)), toRealPath(importer)).split(path8.sep).join("/");
2847
+ const importerProdDir = path8.posix.dirname(toProdExtension(importerRel));
2848
+ if (importerProdDir === ".") return relFromDist;
2849
+ const target = relFromDist.replace(/^\.\//, "");
2850
+ let rel = path8.posix.relative(importerProdDir, target);
2851
+ if (!rel.startsWith(".")) rel = "./" + rel;
2852
+ return rel;
2853
+ }
2845
2854
  var PROD_EXTS = [".js", ".mjs", ".cjs"];
2846
2855
  var SOURCE_EXTS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
2847
2856
  var INDEX_EXTS = [
@@ -2899,9 +2908,10 @@ function createAliasPlugin(config, options) {
2899
2908
  }
2900
2909
  if (appDirAbs && importerOutsideAppDir && isInsideDir(resolved, appDirAbs)) {
2901
2910
  modified = true;
2902
- return `${prefix}${quote}${toStrippedProdImportPath(
2903
- resolved,
2904
- options.rootDir
2911
+ return `${prefix}${quote}${toProdImportFromImporter(
2912
+ importer,
2913
+ options.rootDir,
2914
+ toStrippedProdImportPath(resolved, options.rootDir)
2905
2915
  )}${quote}`;
2906
2916
  }
2907
2917
  modified = true;
@@ -2916,9 +2926,10 @@ function createAliasPlugin(config, options) {
2916
2926
  if (fs6.existsSync(file)) {
2917
2927
  modified = true;
2918
2928
  if (appDirAbs && importerOutsideAppDir && isInsideDir(file, appDirAbs)) {
2919
- return `${prefix}${quote}${toStrippedProdImportPath(
2920
- file,
2921
- options.rootDir
2929
+ return `${prefix}${quote}${toProdImportFromImporter(
2930
+ importer,
2931
+ options.rootDir,
2932
+ toStrippedProdImportPath(file, options.rootDir)
2922
2933
  )}${quote}`;
2923
2934
  }
2924
2935
  return `${prefix}${quote}${toProdImportPath(file, importer)}${quote}`;
@@ -2929,9 +2940,10 @@ function createAliasPlugin(config, options) {
2929
2940
  if (fs6.existsSync(file)) {
2930
2941
  modified = true;
2931
2942
  if (appDirAbs && importerOutsideAppDir && isInsideDir(file, appDirAbs)) {
2932
- return `${prefix}${quote}${toStrippedProdImportPath(
2933
- file,
2934
- options.rootDir
2943
+ return `${prefix}${quote}${toProdImportFromImporter(
2944
+ importer,
2945
+ options.rootDir,
2946
+ toStrippedProdImportPath(file, options.rootDir)
2935
2947
  )}${quote}`;
2936
2948
  }
2937
2949
  return `${prefix}${quote}${toProdImportPath(file, importer)}${quote}`;