ecopages 0.2.0-alpha.46 → 0.2.0-alpha.47

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.
@@ -77,6 +77,27 @@ function ensureRuntimePackageLink(nodeModulesDir, specifier, resolvedPath) {
77
77
  }
78
78
  symlinkSync(packageRoot, linkPath, "dir");
79
79
  }
80
+ function readPackageManifest(packageDir) {
81
+ const packageJsonPath = path.join(packageDir, "package.json");
82
+ try {
83
+ return JSON.parse(readFileSync(packageJsonPath, "utf8"));
84
+ } catch {
85
+ return void 0;
86
+ }
87
+ }
88
+ function isPackageExportedSubpath(specifier, resolvedPath) {
89
+ const packageName = getPackageNameFromSpecifier(specifier);
90
+ if (specifier === packageName) {
91
+ return false;
92
+ }
93
+ const packageRoot = findPackageRoot(resolvedPath);
94
+ const manifest = readPackageManifest(packageRoot);
95
+ if (!manifest?.exports || typeof manifest.exports !== "object" || Array.isArray(manifest.exports)) {
96
+ return false;
97
+ }
98
+ const subpath = `.${specifier.slice(packageName.length)}`;
99
+ return subpath in manifest.exports;
100
+ }
80
101
  function getNodeExternalSpecifier(specifier, resolvedPath) {
81
102
  const packageName = getPackageNameFromSpecifier(specifier);
82
103
  if (specifier === packageName) {
@@ -85,6 +106,9 @@ function getNodeExternalSpecifier(specifier, resolvedPath) {
85
106
  if (path.extname(specifier)) {
86
107
  return specifier;
87
108
  }
109
+ if (isPackageExportedSubpath(specifier, resolvedPath)) {
110
+ return specifier;
111
+ }
88
112
  const resolvedExtension = path.extname(resolvedPath);
89
113
  if (![".js", ".mjs", ".cjs", ".json"].includes(resolvedExtension)) {
90
114
  return specifier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecopages",
3
- "version": "0.2.0-alpha.46",
3
+ "version": "0.2.0-alpha.47",
4
4
  "description": "CLI utilities for Ecopages",
5
5
  "type": "module",
6
6
  "engines": {
@@ -32,7 +32,7 @@
32
32
  "ecopages": "bin/cli.js"
33
33
  },
34
34
  "dependencies": {
35
- "@ecopages/core": "0.2.0-alpha.46",
35
+ "@ecopages/core": "0.2.0-alpha.47",
36
36
  "@ecopages/logger": "^0.2.3",
37
37
  "esbuild": "^0.28.0",
38
38
  "giget": "^2.0.0"