You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,22 @@ This automatically bundles all matching source files. For example:
114
114
> [!IMPORTANT]
115
115
> Wildcard patterns must include a file extension (e.g., `.mjs`, `.cjs`)
116
116
117
+
#### Subpath Imports
118
+
119
+
_Pkgroll_ supports building entry-points defined in [`package.json#imports` (Node.js subpath imports)](https://nodejs.org/api/packages.html#subpath-imports), including conditional imports:
120
+
121
+
```json
122
+
{
123
+
"imports": {
124
+
"#my-pkg": "./dist/index.js",
125
+
"#env": {
126
+
"node": "./dist/env.node.js",
127
+
"default": "./dist/env.browser.js"
128
+
}
129
+
}
130
+
}
131
+
```
132
+
117
133
### Output formats
118
134
_Pkgroll_ detects the format for each entry-point based on the file extension or the `package.json` property it's placed in, using the [same lookup logic as Node.js](https://nodejs.org/api/packages.html#determining-module-system).
119
135
@@ -171,9 +187,6 @@ You can configure aliases using the [import map](https://nodejs.org/api/packages
171
187
172
188
In Node.js, import mappings must start with `#` to indicate an internal [subpath import](https://nodejs.org/api/packages.html#subpath-imports). However, _Pkgroll_ allows defining aliases **without** the `#` prefix.
173
189
174
-
> [!NOTE]
175
-
> While Node.js supports conditional imports (e.g., different paths for Node.js vs. browsers), _Pkgroll_ does not.
0 commit comments