@jsenv/core 41.4.14 → 41.4.16

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.
@@ -6089,9 +6089,15 @@ const createNodeEsmResolver = ({
6089
6089
  }
6090
6090
  }
6091
6091
  version_relationship: {
6092
- const packageVersion = packageDirectory.read(
6092
+ const closestPackageJson = packageDirectory.read(
6093
6093
  closestPackageDirectoryUrl,
6094
- ).version;
6094
+ );
6095
+ if (!closestPackageJson) {
6096
+ // package.json can be momentarily missing while a package manager
6097
+ // is installing/updating that package (npm install running in watch mode)
6098
+ break version_relationship;
6099
+ }
6100
+ const packageVersion = closestPackageJson.version;
6095
6101
  if (!packageVersion) {
6096
6102
  // package version can be null, see https://github.com/babel/babel/blob/2ce56e832c2dd7a7ed92c89028ba929f874c2f5c/packages/babel-runtime/helpers/esm/package.json#L2
6097
6103
  break version_relationship;
@@ -9824,6 +9830,17 @@ const jsenvPluginWorkspaceBundle = ({ packageDirectory }) => {
9824
9830
  // main is node-only code (node:url) that cannot be served to a browser.
9825
9831
  return null;
9826
9832
  }
9833
+ const ownerPackageDirectoryUrl = packageDirectory.find(
9834
+ reference.ownerUrlInfo.url,
9835
+ );
9836
+ if (ownerPackageDirectoryUrl === packageDirectoryUrl) {
9837
+ // Import between two files of the same package: the owner was reached
9838
+ // outside the package bundle (an HTML <script src> entry point, see
9839
+ // above). Consolidation only applies to references crossing into a
9840
+ // package from outside; redirecting an intra-package relative import
9841
+ // to the package main would run the wrong module.
9842
+ return null;
9843
+ }
9827
9844
  // we make sure we target the bundle version of the package
9828
9845
  // otherwise we might execute some parts of the package code multiple times.
9829
9846
  // so we need to redirect the potential reference to non entry point to the package main entry point
@@ -2805,9 +2805,15 @@ const createNodeEsmResolver = ({
2805
2805
  }
2806
2806
  }
2807
2807
  version_relationship: {
2808
- const packageVersion = packageDirectory.read(
2808
+ const closestPackageJson = packageDirectory.read(
2809
2809
  closestPackageDirectoryUrl,
2810
- ).version;
2810
+ );
2811
+ if (!closestPackageJson) {
2812
+ // package.json can be momentarily missing while a package manager
2813
+ // is installing/updating that package (npm install running in watch mode)
2814
+ break version_relationship;
2815
+ }
2816
+ const packageVersion = closestPackageJson.version;
2811
2817
  if (!packageVersion) {
2812
2818
  // package version can be null, see https://github.com/babel/babel/blob/2ce56e832c2dd7a7ed92c89028ba929f874c2f5c/packages/babel-runtime/helpers/esm/package.json#L2
2813
2819
  break version_relationship;
@@ -7674,6 +7680,17 @@ const jsenvPluginWorkspaceBundle = ({ packageDirectory }) => {
7674
7680
  // main is node-only code (node:url) that cannot be served to a browser.
7675
7681
  return null;
7676
7682
  }
7683
+ const ownerPackageDirectoryUrl = packageDirectory.find(
7684
+ reference.ownerUrlInfo.url,
7685
+ );
7686
+ if (ownerPackageDirectoryUrl === packageDirectoryUrl) {
7687
+ // Import between two files of the same package: the owner was reached
7688
+ // outside the package bundle (an HTML <script src> entry point, see
7689
+ // above). Consolidation only applies to references crossing into a
7690
+ // package from outside; redirecting an intra-package relative import
7691
+ // to the package main would run the wrong module.
7692
+ return null;
7693
+ }
7677
7694
  // we make sure we target the bundle version of the package
7678
7695
  // otherwise we might execute some parts of the package code multiple times.
7679
7696
  // so we need to redirect the potential reference to non entry point to the package main entry point
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "41.4.14",
3
+ "version": "41.4.16",
4
4
  "type": "module",
5
5
  "description": "Tool to develop, test and build js projects",
6
6
  "repository": {
@@ -154,9 +154,15 @@ export const createNodeEsmResolver = ({
154
154
  }
155
155
  }
156
156
  version_relationship: {
157
- const packageVersion = packageDirectory.read(
157
+ const closestPackageJson = packageDirectory.read(
158
158
  closestPackageDirectoryUrl,
159
- ).version;
159
+ );
160
+ if (!closestPackageJson) {
161
+ // package.json can be momentarily missing while a package manager
162
+ // is installing/updating that package (npm install running in watch mode)
163
+ break version_relationship;
164
+ }
165
+ const packageVersion = closestPackageJson.version;
160
166
  if (!packageVersion) {
161
167
  // package version can be null, see https://github.com/babel/babel/blob/2ce56e832c2dd7a7ed92c89028ba929f874c2f5c/packages/babel-runtime/helpers/esm/package.json#L2
162
168
  break version_relationship;
@@ -51,6 +51,17 @@ export const jsenvPluginWorkspaceBundle = ({ packageDirectory }) => {
51
51
  // main is node-only code (node:url) that cannot be served to a browser.
52
52
  return null;
53
53
  }
54
+ const ownerPackageDirectoryUrl = packageDirectory.find(
55
+ reference.ownerUrlInfo.url,
56
+ );
57
+ if (ownerPackageDirectoryUrl === packageDirectoryUrl) {
58
+ // Import between two files of the same package: the owner was reached
59
+ // outside the package bundle (an HTML <script src> entry point, see
60
+ // above). Consolidation only applies to references crossing into a
61
+ // package from outside; redirecting an intra-package relative import
62
+ // to the package main would run the wrong module.
63
+ return null;
64
+ }
54
65
  // we make sure we target the bundle version of the package
55
66
  // otherwise we might execute some parts of the package code multiple times.
56
67
  // so we need to redirect the potential reference to non entry point to the package main entry point