@jsenv/node-esm-resolution 0.0.4 → 0.0.5
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 +1 -1
- package/src/node_esm_resolution.js +15 -9
package/package.json
CHANGED
|
@@ -104,7 +104,11 @@ const applyPackageSpecifierResolution = ({
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
const applyBrowserFieldResolution = ({
|
|
107
|
+
const applyBrowserFieldResolution = ({
|
|
108
|
+
conditions,
|
|
109
|
+
parentUrl,
|
|
110
|
+
packageSpecifier,
|
|
111
|
+
}) => {
|
|
108
112
|
const browserCondition = conditions.includes("browser")
|
|
109
113
|
if (!browserCondition) {
|
|
110
114
|
return null
|
|
@@ -125,22 +129,24 @@ const applyBrowserFieldResolution = ({ conditions, parentUrl, specifier }) => {
|
|
|
125
129
|
return null
|
|
126
130
|
}
|
|
127
131
|
let url
|
|
128
|
-
if (
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
if (packageSpecifier.startsWith(".")) {
|
|
133
|
+
const packageSpecifierUrl = new URL(packageSpecifier, parentUrl).href
|
|
134
|
+
const packageSpecifierRelativeUrl = packageSpecifierUrl.slice(
|
|
135
|
+
packageUrl.length,
|
|
136
|
+
)
|
|
137
|
+
const packageSpecifierRelativeNotation = `./${packageSpecifierRelativeUrl}`
|
|
138
|
+
const browserMapping = browser[packageSpecifierRelativeNotation]
|
|
133
139
|
if (typeof browserMapping === "string") {
|
|
134
140
|
url = new URL(browserMapping, packageUrl).href
|
|
135
141
|
} else if (browserMapping === false) {
|
|
136
|
-
url = `file:///@ignore/${
|
|
142
|
+
url = `file:///@ignore/${packageSpecifierUrl.slice("file:///")}`
|
|
137
143
|
}
|
|
138
144
|
} else {
|
|
139
|
-
const browserMapping = browser[
|
|
145
|
+
const browserMapping = browser[packageSpecifier]
|
|
140
146
|
if (typeof browserMapping === "string") {
|
|
141
147
|
url = new URL(browserMapping, packageUrl).href
|
|
142
148
|
} else if (browserMapping === false) {
|
|
143
|
-
url = `file:///@ignore/${
|
|
149
|
+
url = `file:///@ignore/${packageSpecifier}`
|
|
144
150
|
}
|
|
145
151
|
}
|
|
146
152
|
if (url) {
|