@ecopages/core 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/core",
3
- "version": "0.2.0-alpha.46",
3
+ "version": "0.2.0-alpha.47",
4
4
  "description": "Core package for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -17,7 +17,7 @@
17
17
  "directory": "packages/core"
18
18
  },
19
19
  "dependencies": {
20
- "@ecopages/file-system": "0.2.0-alpha.46",
20
+ "@ecopages/file-system": "0.2.0-alpha.47",
21
21
  "@ecopages/logger": "^0.2.3",
22
22
  "@ecopages/scripts-injector": "^0.1.5",
23
23
  "@worker-tools/html-rewriter": "0.1.0-pre.19",
@@ -46,6 +46,19 @@ function resolveRuntimePackageRoot(specifier, resolvedPath, parentPath) {
46
46
  const packageName = getPackageNameFromSpecifier(specifier);
47
47
  return findInstalledPackageDir(packageName, parentPath) ?? findPackageRoot(resolvedPath);
48
48
  }
49
+ function isPackageExportedSubpath(specifier, resolvedPath, parentPath) {
50
+ const packageName = getPackageNameFromSpecifier(specifier);
51
+ if (specifier === packageName) {
52
+ return false;
53
+ }
54
+ const packageRoot = resolveRuntimePackageRoot(specifier, resolvedPath, parentPath);
55
+ const manifest = readPackageManifest(packageRoot);
56
+ if (!manifest?.exports || typeof manifest.exports !== "object" || Array.isArray(manifest.exports)) {
57
+ return false;
58
+ }
59
+ const subpath = `.${specifier.slice(packageName.length)}`;
60
+ return subpath in manifest.exports;
61
+ }
49
62
  function getNodeExternalSpecifier(specifier, resolvedPath, parentPath) {
50
63
  const packageName = getPackageNameFromSpecifier(specifier);
51
64
  if (specifier === packageName) {
@@ -54,6 +67,9 @@ function getNodeExternalSpecifier(specifier, resolvedPath, parentPath) {
54
67
  if (path.extname(specifier)) {
55
68
  return specifier;
56
69
  }
70
+ if (isPackageExportedSubpath(specifier, resolvedPath, parentPath)) {
71
+ return specifier;
72
+ }
57
73
  for (const extension of [".js", ".mjs", ".cjs", ".json"]) {
58
74
  const candidateSpecifier = `${specifier}${extension}`;
59
75
  try {