@flex-development/mlly 1.0.0-beta.5 → 1.0.0-beta.7

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/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ ## [1.0.0-beta.7](https://github.com/flex-development/mlly/compare/1.0.0-beta.6...1.0.0-beta.7) (2026-02-18)
2
+
3
+ ### :package: Build
4
+
5
+ - [[`d1d72a8`](https://github.com/flex-development/mlly/commit/d1d72a8ad498328f8bd9e1e030c18ac58441a879)] **deps:** use @flex-development/when
6
+ - [[`fc3e70a`](https://github.com/flex-development/mlly/commit/fc3e70addbd8172f1464ba5fcef8dcf24cdd22e1)] **pkg:** bundle dts files with rollup only
7
+
8
+ ### :sparkles: Features
9
+
10
+ - [[`20cd201`](https://github.com/flex-development/mlly/commit/20cd2010a3e4ba5fb3d6cfea649ee12996aebea7)] **lib:** [`resolveModule`] allow `specifier` to be `URL`
11
+
12
+ ### :white_check_mark: Testing
13
+
14
+ - [[`b598060`](https://github.com/flex-development/mlly/commit/b59806093cf5bbdb8b06ec9bcea9972054bd2902)] add `edge-runtime` environment tests
15
+
16
+ ## [1.0.0-beta.6](https://github.com/flex-development/mlly/compare/1.0.0-beta.5...1.0.0-beta.6) (2026-02-12)
17
+
18
+ ### ⚠ BREAKING CHANGES
19
+
20
+ - **lib:** [`resolveModule`] support extension rewrite map
21
+
22
+ ### :package: Build
23
+
24
+ - [[`38c36b4`](https://github.com/flex-development/mlly/commit/38c36b4a6df62494e87aeb6ba7d9ce8466ab22cc)] **deps-dev:** Bump vite-tsconfig-paths from 6.1.0 to 6.1.1 ([#975](https://github.com/flex-development/mlly/issues/975))
25
+
26
+ ### :sparkles: Features
27
+
28
+ - [[`efdcc40`](https://github.com/flex-development/mlly/commit/efdcc40de2380932f7cfac80b0d7e96a2cdb8e48)] **lib:** [`resolveModule`] support extension rewrite map
29
+
1
30
  ## [1.0.0-beta.5](https://github.com/flex-development/mlly/compare/1.0.0-beta.4...1.0.0-beta.5) (2026-02-12)
2
31
 
3
32
  ### :package: Build
@@ -1312,3 +1341,5 @@
1312
1341
 
1313
1342
 
1314
1343
 
1344
+
1345
+
package/README.md CHANGED
@@ -23,6 +23,7 @@
23
23
  - [Resolve like Node.js](#resolve-like-nodejs)
24
24
  - [Resolve with custom conditions](#resolve-with-custom-conditions)
25
25
  - [Resolve a directory index](#resolve-a-directory-index)
26
+ - [Resolve path aliases](#resolve-path-aliases)
26
27
  - [Rewrite an extension](#rewrite-an-extension)
27
28
  - [Use a custom file system](#use-a-custom-file-system)
28
29
  - [Use Cases](#use-cases)
@@ -67,7 +68,6 @@
67
68
  - [`Awaitable<T>`](#awaitablet)
68
69
  - [`BufferEncodingMap`](#bufferencodingmap)
69
70
  - [`BufferEncoding`](#bufferencoding)
70
- - [`ChangeExtFn<[Ext]>`](#changeextfnext)
71
71
  - [`ConditionMap`](#conditionmap)
72
72
  - [`Condition`](#condition)
73
73
  - [`Dot`](#dot)
@@ -75,8 +75,10 @@
75
75
  - [`EmptyObject`](#emptyobject)
76
76
  - [`EmptyString`](#emptystring)
77
77
  - [`Ext`](#ext)
78
+ - [`ExtensionRewrites`](#extensionrewrites)
78
79
  - [`FileContent`](#filecontent)
79
80
  - [`FileSystem`](#filesystem)
81
+ - [`GetNewExtension<[T]>`](#getnewextensiont)
80
82
  - [`GetSourceContext`](#getsourcecontext)
81
83
  - [`GetSourceHandler`](#getsourcehandler)
82
84
  - [`GetSourceHandlers`](#getsourcehandlers)
@@ -215,6 +217,39 @@ const resolved: URL = resolveModule('./src/lib', import.meta.url, {
215
217
  })
216
218
  ```
217
219
 
220
+ ### Resolve path aliases
221
+
222
+ ```ts
223
+ import { resolveModule, type Aliases } from '@flex-development/mlly'
224
+
225
+ /**
226
+ * The path mappings dictionary.
227
+ *
228
+ * @const {Aliases} aliases
229
+ */
230
+ const aliases: Aliases = {
231
+ '@/internal': './src/internal',
232
+ '@/internal/*': './src/internal/*'
233
+ }
234
+
235
+ /**
236
+ * The resolved directory URL.
237
+ *
238
+ * @const {URL} directory
239
+ */
240
+ const directory: URL = resolveModule('@/internal', import.meta.url, { aliases })
241
+
242
+ /**
243
+ * The resolved file URL.
244
+ *
245
+ * @const {URL} file
246
+ */
247
+ const file: URL = resolveModule('@/internal/fs', import.meta.url, { aliases })
248
+
249
+ console.dir(directory)
250
+ console.dir(file)
251
+ ```
252
+
218
253
  ### Rewrite an extension
219
254
 
220
255
  ```ts
@@ -987,7 +1022,7 @@ Resolve an aliased `specifier`.
987
1022
  - `specifier` (`string`)
988
1023
  — the specifier using an alias
989
1024
  - `options` ([`ResolveAliasOptions`](#resolvealiasoptions) | `null` | `undefined`)
990
- — alias resolution options
1025
+ options for alias resolution
991
1026
 
992
1027
  #### Returns
993
1028
 
@@ -1016,12 +1051,12 @@ Adds support for:
1016
1051
 
1017
1052
  #### Parameters
1018
1053
 
1019
- - `specifier` (`string`)
1054
+ - `specifier` ([`ModuleId`](#moduleid))
1020
1055
  — the module specifier to resolve
1021
1056
  - `parent` ([`ModuleId`](#moduleid))
1022
1057
  — the url of the parent module
1023
1058
  - `options` ([`ResolveModuleOptions`](#resolvemoduleoptions))
1024
- — module resolution options
1059
+ options for module resolution
1025
1060
 
1026
1061
  #### Returns
1027
1062
 
@@ -1144,34 +1179,6 @@ They will be added to this union automatically.
1144
1179
  type BufferEncoding = BufferEncodingMap[keyof BufferEncodingMap]
1145
1180
  ```
1146
1181
 
1147
- ### `ChangeExtFn<[Ext]>`
1148
-
1149
- Get a new file extension for `url` (`type`).
1150
-
1151
- Returning an empty string (`''`), `null`, or `undefined` will remove the current file extension.
1152
-
1153
- ```ts
1154
- type ChangeExtFn<
1155
- Ext extends string | null | undefined = string | null | undefined
1156
- > = (this: void, url: URL, specifier: string) => Ext
1157
- ```
1158
-
1159
- #### Type Parameters
1160
-
1161
- - `Ext` (`string` | `null` | `undefined`, optional)
1162
- — the new file extension
1163
-
1164
- #### Parameters
1165
-
1166
- - `url` (`URL`)
1167
- — the resolved module URL
1168
- - `specifier` (`string`)
1169
- — the module specifier being resolved
1170
-
1171
- #### Returns
1172
-
1173
- (`Ext`) The new file extension
1174
-
1175
1182
  ### `ConditionMap`
1176
1183
 
1177
1184
  Registry of export/import conditions (`interface`).
@@ -1237,6 +1244,20 @@ A file extension (`type`).
1237
1244
  type Ext = `${Dot}${string}`
1238
1245
  ```
1239
1246
 
1247
+ ### `ExtensionRewrites`
1248
+
1249
+ Record, where each key is the file extension of a module specifier
1250
+ and each value is a replacement file extension (`type`).
1251
+
1252
+ > 👉 **Note**: Replacement file extensions are normalized and do not need to begin with a dot character (`'.'`);
1253
+ > falsy values will remove an extension.
1254
+
1255
+ ```ts
1256
+ type ExtensionRewrites = {
1257
+ [K in EmptyString | Ext]?: string | false | null | undefined
1258
+ }
1259
+ ```
1260
+
1240
1261
  ### `FileContent`
1241
1262
 
1242
1263
  Union of values that can occur where file content is expected (`type`).
@@ -1258,6 +1279,38 @@ The file system API (`interface`).
1258
1279
  - `stat` ([`Stat`](#stat))
1259
1280
  — get information about a directory or file
1260
1281
 
1282
+ ### `GetNewExtension<[T]>`
1283
+
1284
+ Get a new file extension for a `url` (`type`).
1285
+
1286
+ Returning an empty string (`''`), `false`, `null`, or `undefined` will remove the current file extension.
1287
+
1288
+ ```ts
1289
+ type GetNewExtension<
1290
+ T extends string | false | null | undefined =
1291
+ | string
1292
+ | false
1293
+ | null
1294
+ | undefined
1295
+ > = (this: void, url: URL, specifier: string) => T
1296
+ ```
1297
+
1298
+ #### Type Parameters
1299
+
1300
+ - `T` (`string` | `false` | `null` | `undefined`, optional)
1301
+ — the new file extension
1302
+
1303
+ #### Parameters
1304
+
1305
+ - `url` (`URL`)
1306
+ — the resolved module URL
1307
+ - `specifier` (`string`)
1308
+ — the module specifier being resolved
1309
+
1310
+ #### Returns
1311
+
1312
+ (`T`) The new file extension
1313
+
1261
1314
  ### `GetSourceContext`
1262
1315
 
1263
1316
  Source code retrieval context (`interface`).
@@ -1557,7 +1610,7 @@ Options for path alias resolution (`interface`).
1557
1610
 
1558
1611
  ### `ResolveModuleOptions`
1559
1612
 
1560
- Options for path alias resolution (`interface`).
1613
+ Options for module resolution (`interface`).
1561
1614
 
1562
1615
  #### Properties
1563
1616
 
@@ -1571,9 +1624,12 @@ Options for path alias resolution (`interface`).
1571
1624
  - `cwd?` ([`ModuleId`](#moduleid) | `null` | `undefined`)
1572
1625
  — the url of the directory to resolve path `aliases` from
1573
1626
  - **default**: [`cwd()`](#cwd)
1574
- - `ext?` ([`ChangeExtFn`](#changeextfnext) | `string` | `null` | `undefined`)
1575
- a replacement file extension or a function that returns a file extension.
1576
- > \:point\_right: **note**: an empty string (`''`) or `null` will remove a file extension
1627
+ <!--lint disable-->
1628
+ - `ext?` ([`ExtensionRewrites`](#extensionrewrites) | [`GetNewExtension`](#getnewextensiont) | `false` | `string` | `null` | `undefined`)
1629
+ a replacement file extension, a record of replacement file extensions, or a function that returns a replacement file extension
1630
+ <!--lint enable-->
1631
+ > \:point\_right: **note**: replacement file extensions are normalized and do not need to begin
1632
+ > with a dot character (`'.'`); an empty string (`''`), `false`, or `null` will remove an extension
1577
1633
  - `extensions?` ([`List<string>`](#listt) | `null` | `undefined`)
1578
1634
  — the module extensions to probe for
1579
1635
  - **default**: [`defaultExtensions`](#defaultextensions)