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
This major release is mostly about keeping import map for node module and writing importmap file separated.
- replace generateImportMapForProjectPackage by getImportMapFromNodeModules
- getImportMapFromNodeModules only return importmap, it does not write to filesystem anymore.
- add getImportMapFromFile
- add generateImportMapForProject
- generate importmap for package self ref by default
see nodejs/node#31002
- rename some parameter like favoredExports becoming packagesExportsPreference
- ensure a package self reference is stronger than self dev dependency
@@ -135,8 +140,75 @@ We do this because importMap are used on the web where a file outside project fo
135
140
136
141
In practice it does not impact you because node modules are inside your project folder. If not, write all your dependencies in your `package.json` and re-run `npm install`.
137
142
138
-
# Advanced usage
143
+
# generateImportMapForProject
139
144
140
-
This repository also provides the ability to compose several import map into a final importmap file.
145
+
`generateImportMapForProject` is an async function receiving an array of promise resolving to importmaps. It awaits for every importmap, compose them into one and write it into a file.
141
146
142
-
[docs/advanced.md](./docs/advanced.md)
147
+
> This function is meant to be responsible of generating the final importMap file that a project uses.
148
+
149
+
For example code below will generate an import map from node_modules + a file + an inline importmap.
— source code at [src/generateImportMapForProject.js](./src/generateImportMapForProject.js).
180
+
181
+
## importMapInputs
182
+
183
+
`importMapInputs` is an array of importmap object or promise resolving to importmap objects. This parameter is optional and is an empty array by default.
184
+
185
+
> When `importMapInputs` is empty a warning is emitted and `generateImportMapForProject` write an empty importmap file.
186
+
187
+
## importMapFile
188
+
189
+
`importMapFile` parameter is a boolean controling if importMap is written to a file. This parameters is optional and enabled by default.
190
+
191
+
## importMapFileRelativeUrl
192
+
193
+
`importMapFileRelativeUrl` parameter is a string controlling where importMap file is written. This parameter is optional and by default it's `"./import-map.importmap"`.
194
+
195
+
## importMapFileLog
196
+
197
+
`importMapFileLog` parameter a boolean controlling if there is log in the terminal when importMap file is written. This parameter is optional and by default it's enabled.
198
+
199
+
# getImportMapFromFile
200
+
201
+
`getImportMapFromFile` is an async function reading importmap from a file.
0 commit comments