@flex-development/mlly 1.0.0-alpha.2 → 1.0.0-alpha.20

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.
Files changed (151) hide show
  1. package/CHANGELOG.md +1058 -119
  2. package/README.md +190 -10
  3. package/dist/index.d.mts +3 -4
  4. package/dist/index.mjs +1 -4
  5. package/dist/interfaces/aliases.d.mts +11 -0
  6. package/dist/interfaces/context-get-source.d.mts +52 -0
  7. package/dist/interfaces/file-system.d.mts +54 -0
  8. package/dist/interfaces/index.d.mts +11 -9
  9. package/dist/interfaces/main-field-map.d.mts +13 -0
  10. package/dist/interfaces/module-format-map.d.mts +17 -0
  11. package/dist/interfaces/options-get-source.d.mts +47 -0
  12. package/dist/interfaces/options-resolve-alias.d.mts +16 -44
  13. package/dist/interfaces/options-resolve-module.d.mts +75 -0
  14. package/dist/interfaces/protocol-map.d.mts +35 -0
  15. package/dist/interfaces/stats.d.mts +28 -0
  16. package/dist/internal/chars.mjs +11 -0
  17. package/dist/internal/check-invalid-segments.mjs +19 -0
  18. package/dist/internal/fs.browser.mjs +36 -0
  19. package/dist/internal/fs.d.mts +7 -0
  20. package/dist/internal/invalid-package-target.mjs +18 -0
  21. package/dist/internal/invalid-subpath.mjs +16 -0
  22. package/dist/internal/process.browser.mjs +7 -0
  23. package/dist/internal/process.d.mts +4 -0
  24. package/dist/lib/can-parse-url.d.mts +21 -0
  25. package/dist/lib/can-parse-url.mjs +12 -0
  26. package/dist/lib/cwd.d.mts +12 -0
  27. package/dist/lib/cwd.mjs +8 -0
  28. package/dist/lib/default-conditions.d.mts +15 -0
  29. package/dist/lib/default-conditions.mjs +5 -0
  30. package/dist/lib/default-extensions.d.mts +14 -0
  31. package/dist/{constants.mjs → lib/default-extensions.mjs} +3 -6
  32. package/dist/lib/default-main-fields.d.mts +14 -0
  33. package/dist/lib/default-main-fields.mjs +5 -0
  34. package/dist/lib/extension-format-map.d.mts +16 -0
  35. package/dist/lib/extension-format-map.mjs +21 -0
  36. package/dist/lib/formats.d.mts +21 -0
  37. package/dist/lib/formats.mjs +14 -0
  38. package/dist/lib/get-source.d.mts +26 -0
  39. package/dist/lib/get-source.mjs +70 -0
  40. package/dist/lib/index.d.mts +37 -17
  41. package/dist/lib/index.mjs +51 -32
  42. package/dist/lib/is-absolute-specifier.d.mts +23 -0
  43. package/dist/lib/is-absolute-specifier.mjs +9 -0
  44. package/dist/lib/is-array-index.d.mts +17 -0
  45. package/dist/lib/is-array-index.mjs +11 -0
  46. package/dist/lib/is-bare-specifier.d.mts +23 -0
  47. package/dist/lib/is-bare-specifier.mjs +11 -0
  48. package/dist/lib/is-directory.d.mts +20 -0
  49. package/dist/lib/is-directory.mjs +13 -0
  50. package/dist/lib/is-file.d.mts +20 -0
  51. package/dist/lib/is-file.mjs +13 -0
  52. package/dist/lib/is-imports-subpath.d.mts +19 -0
  53. package/dist/lib/is-imports-subpath.mjs +8 -0
  54. package/dist/lib/is-relative-specifier.d.mts +21 -0
  55. package/dist/lib/is-relative-specifier.mjs +16 -0
  56. package/dist/lib/lookup-package-scope.d.mts +24 -0
  57. package/dist/lib/lookup-package-scope.mjs +16 -0
  58. package/dist/lib/pattern-key-compare.d.mts +31 -0
  59. package/dist/lib/pattern-key-compare.mjs +18 -0
  60. package/dist/lib/pattern-match.d.mts +19 -0
  61. package/dist/lib/pattern-match.mjs +36 -0
  62. package/dist/lib/read-package-json.d.mts +35 -0
  63. package/dist/lib/read-package-json.mjs +29 -0
  64. package/dist/lib/resolve-alias.d.mts +11 -12
  65. package/dist/lib/resolve-alias.mjs +46 -37
  66. package/dist/lib/resolve-module.d.mts +23 -17
  67. package/dist/lib/resolve-module.mjs +69 -68
  68. package/dist/lib/resolver.d.mts +533 -0
  69. package/dist/lib/resolver.mjs +567 -0
  70. package/dist/lib/root.d.mts +11 -0
  71. package/dist/lib/root.mjs +6 -0
  72. package/dist/lib/to-relative-specifier.d.mts +10 -7
  73. package/dist/lib/to-relative-specifier.mjs +22 -13
  74. package/dist/lib/to-url.d.mts +24 -0
  75. package/dist/lib/to-url.mjs +10 -0
  76. package/dist/types/awaitable.d.mts +14 -0
  77. package/dist/types/change-ext-fn.d.mts +29 -0
  78. package/dist/types/get-source-handler.d.mts +21 -0
  79. package/dist/types/get-source-handlers.d.mts +14 -0
  80. package/dist/types/index.d.mts +12 -6
  81. package/dist/types/main-field.d.mts +13 -0
  82. package/dist/types/module-format.d.mts +13 -0
  83. package/dist/types/module-id.d.mts +11 -0
  84. package/dist/types/numeric.d.mts +9 -0
  85. package/dist/types/pattern-key-compare-result.d.mts +9 -0
  86. package/dist/types/pattern-match.d.mts +10 -0
  87. package/dist/types/protocol.d.mts +13 -0
  88. package/package.json +234 -139
  89. package/changelog.config.cts +0 -204
  90. package/dist/constants.d.mts +0 -19
  91. package/dist/interfaces/import-dynamic.d.mts +0 -23
  92. package/dist/interfaces/import-dynamic.mjs +0 -0
  93. package/dist/interfaces/import-static.d.mts +0 -19
  94. package/dist/interfaces/import-static.mjs +0 -0
  95. package/dist/interfaces/index.mjs +0 -0
  96. package/dist/interfaces/options-resolve-alias.mjs +0 -0
  97. package/dist/interfaces/options-resolve.d.mts +0 -60
  98. package/dist/interfaces/options-resolve.mjs +0 -0
  99. package/dist/interfaces/statement-export.d.mts +0 -31
  100. package/dist/interfaces/statement-export.mjs +0 -0
  101. package/dist/interfaces/statement-import.d.mts +0 -27
  102. package/dist/interfaces/statement-import.mjs +0 -0
  103. package/dist/interfaces/statement-require.d.mts +0 -27
  104. package/dist/interfaces/statement-require.mjs +0 -0
  105. package/dist/interfaces/statement.d.mts +0 -33
  106. package/dist/interfaces/statement.mjs +0 -0
  107. package/dist/internal/compiler-options-json.d.mts +0 -111
  108. package/dist/internal/compiler-options-json.mjs +0 -0
  109. package/dist/internal/constants.d.mts +0 -70
  110. package/dist/internal/constants.mjs +0 -18
  111. package/dist/internal/get-compiler-options.d.mts +0 -21
  112. package/dist/internal/get-compiler-options.mjs +0 -14
  113. package/dist/internal/index.d.mts +0 -7
  114. package/dist/internal/index.mjs +0 -5
  115. package/dist/lib/detect-syntax.d.mts +0 -21
  116. package/dist/lib/detect-syntax.mjs +0 -11
  117. package/dist/lib/extract-statements.d.mts +0 -21
  118. package/dist/lib/extract-statements.mjs +0 -18
  119. package/dist/lib/find-dynamic-imports.d.mts +0 -15
  120. package/dist/lib/find-dynamic-imports.mjs +0 -20
  121. package/dist/lib/find-exports.d.mts +0 -15
  122. package/dist/lib/find-exports.mjs +0 -53
  123. package/dist/lib/find-requires.d.mts +0 -17
  124. package/dist/lib/find-requires.mjs +0 -19
  125. package/dist/lib/find-static-imports.d.mts +0 -15
  126. package/dist/lib/find-static-imports.mjs +0 -20
  127. package/dist/lib/has-cjs-syntax.d.mts +0 -22
  128. package/dist/lib/has-cjs-syntax.mjs +0 -6
  129. package/dist/lib/has-esm-syntax.d.mts +0 -18
  130. package/dist/lib/has-esm-syntax.mjs +0 -6
  131. package/dist/lib/resolve-aliases.d.mts +0 -17
  132. package/dist/lib/resolve-aliases.mjs +0 -34
  133. package/dist/lib/resolve-modules.d.mts +0 -19
  134. package/dist/lib/resolve-modules.mjs +0 -29
  135. package/dist/lib/to-absolute-specifier.d.mts +0 -22
  136. package/dist/lib/to-absolute-specifier.mjs +0 -20
  137. package/dist/lib/to-bare-specifier.d.mts +0 -28
  138. package/dist/lib/to-bare-specifier.mjs +0 -78
  139. package/dist/lib/to-data-url.d.mts +0 -29
  140. package/dist/lib/to-data-url.mjs +0 -7
  141. package/dist/types/declaration.d.mts +0 -9
  142. package/dist/types/declaration.mjs +0 -0
  143. package/dist/types/ext.d.mts +0 -9
  144. package/dist/types/ext.mjs +0 -0
  145. package/dist/types/index.mjs +0 -0
  146. package/dist/types/mime-type.d.mts +0 -11
  147. package/dist/types/mime-type.mjs +0 -0
  148. package/dist/types/specifier-type.d.mts +0 -11
  149. package/dist/types/specifier-type.mjs +0 -0
  150. package/dist/types/statement-type.d.mts +0 -9
  151. package/dist/types/statement-type.mjs +0 -0
package/README.md CHANGED
@@ -1,17 +1,197 @@
1
- # mlly
1
+ # \:gear: mlly
2
2
 
3
- [![conventional commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
4
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
5
- [![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)
3
+ [![github release](https://img.shields.io/github/v/release/flex-development/mlly.svg?include_prereleases\&sort=semver)](https://github.com/flex-development/mlly/releases/latest)
6
4
  [![npm](https://img.shields.io/npm/v/@flex-development/mlly.svg)](https://npmjs.com/package/@flex-development/mlly)
5
+ [![codecov](https://codecov.io/gh/flex-development/mlly/graph/badge.svg?token=36NUNRH6FW)](https://codecov.io/gh/flex-development/mlly)
6
+ [![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)
7
7
  [![license](https://img.shields.io/github/license/flex-development/mlly.svg)](LICENSE.md)
8
- [![typescript](https://badgen.net/badge/-/typescript?color=2a72bc&icon=typescript&label)](https://typescriptlang.org)
8
+ [![conventional commits](https://img.shields.io/badge/-conventional%20commits-fe5196?logo=conventional-commits\&logoColor=ffffff)](https://conventionalcommits.org)
9
+ [![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript\&logoColor=ffffff)](https://typescriptlang.org)
10
+ [![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat\&logo=vitest\&logoColor=ffffff)](https://vitest.dev)
11
+ [![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat\&logo=yarn\&logoColor=ffffff)](https://yarnpkg.com)
12
+
13
+ [ECMAScript module][node-esm] utilities.
14
+
15
+ ## Contents
16
+
17
+ - [What is this?](#what-is-this)
18
+ - [Install](#install)
19
+ - [Use](#use)
20
+ - [API](#api)
21
+ - [Types](#types)
22
+ - [Contribute](#contribute)
23
+
24
+ ## What is this?
25
+
26
+ `mlly` is a set of [ECMAScript module][node-esm] (ESM) utilities. It exposes several tools to bridge the gap between
27
+ developer experience and the current state of ECMAScript modules.
28
+
29
+ ## Install
30
+
31
+ This package is [ESM only][esm].
32
+
33
+ In Node.js (version 18+) with [yarn][]:
34
+
35
+ ```sh
36
+ yarn add @flex-development/mlly
37
+ ```
38
+
39
+ <blockquote>
40
+ <small>
41
+ See <a href='https://yarnpkg.com/protocol/git'>Git - Protocols | Yarn</a>
42
+ &nbsp;for details regarding installing from Git.
43
+ </small>
44
+ </blockquote>
45
+
46
+ In Deno with [`esm.sh`][esmsh]:
47
+
48
+ ```ts
49
+ import { resolveModule } from 'https://esm.sh/@flex-development/mlly'
50
+ ```
51
+
52
+ In browsers with [`esm.sh`][esmsh]:
53
+
54
+ ```html
55
+ <script type="module">
56
+ import { resolveModule } from 'https://esm.sh/@flex-development/mlly'
57
+ </script>
58
+ ```
59
+
60
+ ## Use
61
+
62
+ ```js
63
+ import {
64
+ canParseUrl,
65
+ cwd,
66
+ defaultConditions,
67
+ defaultExtensions,
68
+ defaultMainFields,
69
+ extensionFormatMap,
70
+ formats,
71
+ getSource,
72
+ isAbsoluteSpecifier,
73
+ isArrayIndex,
74
+ isBareSpecifier,
75
+ isDirectory,
76
+ isFile,
77
+ isImportsSubpath,
78
+ isRelativeSpecifier,
79
+ legacyMainResolve,
80
+ legacyMainResolveSync,
81
+ lookupPackageScope,
82
+ moduleResolve,
83
+ moduleResolveSync,
84
+ packageExportsResolve,
85
+ packageExportsResolveSync,
86
+ packageImportsExportsResolve,
87
+ packageImportsExportsResolveSync,
88
+ packageImportsResolve,
89
+ packageImportsResolveSync,
90
+ packageResolve,
91
+ packageResolveSync,
92
+ packageSelfResolve,
93
+ packageSelfResolveSync,
94
+ packageTargetResolve,
95
+ packageTargetResolveSync,
96
+ patternKeyCompare,
97
+ patternMatch,
98
+ readPackageJson,
99
+ resolveAlias,
100
+ resolveModule,
101
+ resolver,
102
+ root,
103
+ toRelativeSpecifier,
104
+ toUrl
105
+ } from '@flex-development/mlly'
106
+ ```
107
+
108
+ ## API
109
+
110
+ This package exports the following identifiers:
111
+
112
+ - [`canParseUrl`](./src/lib/can-parse-url.mts)
113
+ - [`cwd`](./src/lib/cwd.mts)
114
+ - [`defaultConditions`](./src/lib/default-conditions.mts)
115
+ - [`defaultExtensions`](./src/lib/default-extensions.mts)
116
+ - [`defaultMainFields`](./src/lib/default-main-fields.mts)
117
+ - [`extensionFormatMap`](./src/lib/extension-format-map.mts)
118
+ - [`formats`](./src/lib/formats.mts)
119
+ - [`getSource`](./src/lib/get-source.mts)
120
+ - [`isAbsoluteSpecifier`](./src/lib/is-absolute-specifier.mts)
121
+ - [`isArrayIndex`](./src/lib/is-array-index.mts)
122
+ - [`isBareSpecifier`](./src/lib/is-bare-specifier.mts)
123
+ - [`isDirectory`](./src/lib/is-directory.mts)
124
+ - [`isFile`](./src/lib/is-file.mts)
125
+ - [`isImportsSubpath`](./src/lib/is-imports-subpath.mts)
126
+ - [`isRelativeSpecifier`](./src/lib/is-relative-specifier.mts)
127
+ - [`lookupPackageScope`](./src/lib/lookup-package-scope.mts)
128
+ - [`patternKeyCompare`](./src/lib/pattern-key-compare.mts)
129
+ - [`patternMatch`](./src/lib/pattern-match.mts)
130
+ - [`readPackageJson`](./src/lib/read-package-json.mts)
131
+ - [`resolveAlias`](./src/lib/resolve-alias.mts)
132
+ - [`resolveModule`](./src/lib/resolve-module.mts)
133
+ - [`resolver`](./src/lib/resolver.mts)
134
+ - `legacyMainResolve`
135
+ - `legacyMainResolveSync`
136
+ - `moduleResolve`
137
+ - `moduleResolveSync`
138
+ - `packageExportsResolve`
139
+ - `packageExportsResolveSync`
140
+ - `packageImportsExportsResolve`
141
+ - `packageImportsExportsResolveSync`
142
+ - `packageImportsResolve`
143
+ - `packageImportsResolveSync`
144
+ - `packageResolve`
145
+ - `packageResolveSync`
146
+ - `packageSelfResolve`
147
+ - `packageSelfResolveSync`
148
+ - `packageTargetResolve`
149
+ - `packageTargetResolveSync`
150
+ - [`root`](./src/lib/root.mts)
151
+ - [`toRelativeSpecifier`](./src/lib/to-relative-specifier.mts)
152
+ - [`toUrl`](./src/lib/to-url.mts)
153
+
154
+ There is no default export.
155
+
156
+ ## Types
157
+
158
+ This package is fully typed with [TypeScript][].
159
+
160
+ ### Interfaces
161
+
162
+ - [`Aliases`](src/interfaces/aliases.mts)
163
+ - [`FileSystem`](src/interfaces/file-system.mts)
164
+ - [`MainFieldMap`](src/interfaces/main-field-map.mts)
165
+ - [`ModuleFormatMap`](src/interfaces/module-format-map.mts)
166
+ - [`ResolveAliasOptions`](src/interfaces/options-resolve-alias.mts)
167
+ - [`ResolveModuleOptions`](src/interfaces/options-resolve-module.mts)
168
+ - [`ProtocolMap`](src/interfaces/protocol-map.mts)
169
+ - [`Stats`](src/interfaces/stats.mts)
170
+
171
+ ### Type Aliases
172
+
173
+ - [`ChangeExtFn`](src/types/change-ext-fn.mts)
174
+ - [`MainField`](src/types/main-field.mts)
175
+ - [`ModuleFormat`](src/types/module-format.mts)
176
+ - [`ModuleId`](src/types/module-id.mts)
177
+ - [`Numeric`](src/types/numeric.mts)
178
+ - [`PatternKeyCompareResult`](src/types/pattern-key-compare-result.mts)
179
+ - [`PatternMatch`](src/types/pattern-match.mts)
180
+ - [`Protocol`](src/types/protocol.mts)
181
+
182
+ ## Contribute
183
+
184
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md).
185
+
186
+ This project has a [code of conduct](./CODE_OF_CONDUCT.md). By interacting with this repository, organization, or
187
+ community you agree to abide by its terms.
188
+
189
+ [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
9
190
 
10
- > [ECMAScript module][1] utilities.
191
+ [esmsh]: https://esm.sh
11
192
 
12
- ## Getting Started
193
+ [node-esm]: https://nodejs.org/api/esm.html
13
194
 
14
- See the [docs][2] for install and usage instructions.
195
+ [typescript]: https://www.typescriptlang.org
15
196
 
16
- [1]: https://nodejs.org/api/esm.html
17
- [2]: https://mlly.vercel.app/
197
+ [yarn]: https://yarnpkg.com
package/dist/index.d.mts CHANGED
@@ -2,7 +2,6 @@
2
2
  * @file Package Entry Point
3
3
  * @module mlly
4
4
  */
5
- export * from './constants.mjs';
6
- export * from './interfaces/index.mjs';
7
- export * from './lib/index.mjs';
8
- export * from './types/index.mjs';
5
+ export type * from '#interfaces/index';
6
+ export * from '#lib/index';
7
+ export type * from '#types/index';
package/dist/index.mjs CHANGED
@@ -1,4 +1 @@
1
- export * from "./constants.mjs";
2
- export * from "./interfaces/index.mjs";
3
- export * from "./lib/index.mjs";
4
- export * from "./types/index.mjs";
1
+ export * from "#lib/index";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @file Interfaces - Aliases
3
+ * @module mlly/interfaces/Aliases
4
+ */
5
+ /**
6
+ * Path aliases.
7
+ */
8
+ interface Aliases {
9
+ [alias: string]: (string | null | undefined)[] | string | null | undefined;
10
+ }
11
+ export type { Aliases as default };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @file Interfaces - GetSourceContext
3
+ * @module mlly/interfaces/GetSourceContext
4
+ */
5
+ import type { FileSystem, GetSourceHandlers, GetSourceOptions } from '@flex-development/mlly';
6
+ /**
7
+ * Source code retrieval context.
8
+ *
9
+ * @see {@linkcode GetSourceOptions}
10
+ *
11
+ * @extends {GetSourceOptions}
12
+ */
13
+ interface GetSourceContext extends GetSourceOptions {
14
+ /**
15
+ * Throw [`ERR_UNSUPPORTED_ESM_URL_SCHEME`][err]?
16
+ *
17
+ * [err]: https://nodejs.org/api/errors.html#err_unsupported_esm_url_scheme
18
+ */
19
+ error: boolean;
20
+ /**
21
+ * File system API.
22
+ *
23
+ * @see {@linkcode FileSystem}
24
+ *
25
+ * @override
26
+ */
27
+ fs: FileSystem;
28
+ /**
29
+ * URL handler map.
30
+ *
31
+ * @see {@linkcode GetSourceHandlers}
32
+ *
33
+ * @override
34
+ */
35
+ handlers: GetSourceHandlers;
36
+ /**
37
+ * Request options for network based modules.
38
+ *
39
+ * > 👉 **Note**: Only applicable if {@linkcode network} is
40
+ * > enabled.
41
+ *
42
+ * @override
43
+ */
44
+ req: RequestInit;
45
+ /**
46
+ * List of supported URL schemes.
47
+ *
48
+ * @override
49
+ */
50
+ schemes: Set<string>;
51
+ }
52
+ export type { GetSourceContext as default };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @file Interfaces - FileSystem
3
+ * @module mlly/interfaces/FileSystem
4
+ */
5
+ import type { ModuleId, Stats } from '@flex-development/mlly';
6
+ /**
7
+ * File system API.
8
+ */
9
+ interface FileSystem {
10
+ /**
11
+ * Get the contents of `id`.
12
+ *
13
+ * @see {@linkcode Buffer}
14
+ * @see {@linkcode ModuleId}
15
+ * @see https://nodejs.org/api/fs.html#fsreadfilepath-options-callback
16
+ *
17
+ * @this {void}
18
+ *
19
+ * @param {ModuleId} id
20
+ * The path or `file:` URL to handle
21
+ * @return {Buffer | string}
22
+ * File contents
23
+ */
24
+ readFileSync(this: void, id: ModuleId): Buffer | string;
25
+ /**
26
+ * Get the resolved pathname for `id`.
27
+ *
28
+ * @see {@linkcode ModuleId}
29
+ * @see https://nodejs.org/api/fs.html#fsrealpathpath-options-callback
30
+ *
31
+ * @this {void}
32
+ *
33
+ * @param {ModuleId} id
34
+ * The path or `file:` URL to handle
35
+ * @return {string}
36
+ * Resolved pathname
37
+ */
38
+ realpathSync(this: void, id: ModuleId): string;
39
+ /**
40
+ * Get information about a directory or file.
41
+ *
42
+ * @see {@linkcode ModuleId}
43
+ * @see {@linkcode Stats}
44
+ *
45
+ * @this {void}
46
+ *
47
+ * @param {ModuleId} id
48
+ * The path or `file:` URL to handle
49
+ * @return {Stats}
50
+ * Info about `id`
51
+ */
52
+ statSync(this: void, id: ModuleId): Stats;
53
+ }
54
+ export type { FileSystem as default };
@@ -1,12 +1,14 @@
1
1
  /**
2
- * @file Interfaces
2
+ * @file Entry Point - Interfaces
3
3
  * @module mlly/interfaces
4
4
  */
5
- export type { default as DynamicImport } from './import-dynamic.mjs';
6
- export type { default as StaticImport } from './import-static.mjs';
7
- export type { default as ResolveOptions } from './options-resolve.mjs';
8
- export type { default as ResolveAliasOptions } from './options-resolve-alias.mjs';
9
- export type { default as Statement } from './statement.mjs';
10
- export type { default as ExportStatement } from './statement-export.mjs';
11
- export type { default as ImportStatement } from './statement-import.mjs';
12
- export type { default as RequireStatement } from './statement-require.mjs';
5
+ export type { default as Aliases } from '#interfaces/aliases';
6
+ export type { default as GetSourceContext } from '#interfaces/context-get-source';
7
+ export type { default as FileSystem } from '#interfaces/file-system';
8
+ export type { default as MainFieldMap } from '#interfaces/main-field-map';
9
+ export type { default as ModuleFormatMap } from '#interfaces/module-format-map';
10
+ export type { default as GetSourceOptions } from '#interfaces/options-get-source';
11
+ export type { default as ResolveAliasOptions } from '#interfaces/options-resolve-alias';
12
+ export type { default as ResolveModuleOptions } from '#interfaces/options-resolve-module';
13
+ export type { default as ProtocolMap } from '#interfaces/protocol-map';
14
+ export type { default as Stats } from '#interfaces/stats';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @file Interfaces - MainFieldMap
3
+ * @module mlly/interfaces/MainFieldMap
4
+ */
5
+ /**
6
+ * Main fields registry.
7
+ */
8
+ interface MainFieldMap {
9
+ main: 'main';
10
+ module: 'module';
11
+ types: 'types';
12
+ }
13
+ export type { MainFieldMap as default };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Interfaces - ModuleFormatMap
3
+ * @module mlly/interfaces/ModuleFormatMap
4
+ */
5
+ /**
6
+ * Module format registry.
7
+ */
8
+ interface ModuleFormatMap {
9
+ builtin: 'builtin';
10
+ commonjs: 'commonjs';
11
+ cts: 'commonjs-typescript';
12
+ json: 'json';
13
+ module: 'module';
14
+ mts: 'module-typescript';
15
+ wasm: 'wasm';
16
+ }
17
+ export type { ModuleFormatMap as default };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @file Interfaces - GetSourceOptions
3
+ * @module mlly/interfaces/GetSourceOptions
4
+ */
5
+ import type { FileSystem, GetSourceHandlers, ModuleFormat } from '@flex-development/mlly';
6
+ /**
7
+ * Source code retrieval options.
8
+ */
9
+ interface GetSourceOptions {
10
+ /**
11
+ * Module format hint.
12
+ *
13
+ * @see {@linkcode ModuleFormat}
14
+ */
15
+ format?: ModuleFormat | null | undefined;
16
+ /**
17
+ * File system API.
18
+ *
19
+ * @see {@linkcode FileSystem}
20
+ */
21
+ fs?: FileSystem | null | undefined;
22
+ /**
23
+ * URL handler map.
24
+ *
25
+ * @see {@linkcode GetSourceHandlers}
26
+ */
27
+ handlers?: GetSourceHandlers | null | undefined;
28
+ /**
29
+ * Ignore [`ERR_UNSUPPORTED_ESM_URL_SCHEME`][err] if thrown.
30
+ *
31
+ * [err]: https://nodejs.org/api/errors.html#err_unsupported_esm_url_scheme
32
+ */
33
+ ignoreErrors?: boolean | null | undefined;
34
+ /**
35
+ * Request options for network based modules.
36
+ *
37
+ * > 👉 **Note**: Only applicable if {@linkcode network} is enabled.
38
+ */
39
+ req?: RequestInit | null | undefined;
40
+ /**
41
+ * List of supported URL schemes.
42
+ *
43
+ * @default ['data','file','http','https','node']
44
+ */
45
+ schemes?: Set<string> | readonly string[] | null | undefined;
46
+ }
47
+ export type { GetSourceOptions as default };
@@ -2,68 +2,40 @@
2
2
  * @file Interfaces - ResolveAliasOptions
3
3
  * @module mlly/interfaces/ResolveAliasOptions
4
4
  */
5
- import type { OneOrMany } from '@flex-development/tutils';
5
+ import type { Aliases, ModuleId } from '@flex-development/mlly';
6
6
  /**
7
7
  * Path alias resolution options.
8
- *
9
- * @see https://github.com/dividab/tsconfig-paths
10
8
  */
11
9
  interface ResolveAliasOptions {
12
10
  /**
13
- * Base directory to resolve non-absolute module names.
11
+ * Return resolved module URL as absolute specifier (a [`file:` URL][1]).
14
12
  *
15
- * @see https://www.typescriptlang.org/tsconfig#baseUrl
13
+ * [1]: https://nodejs.org/api/esm.html#file-urls
16
14
  *
17
- * @default process.cwd()
15
+ * @see https://nodejs.org/api/esm.html#terminology
18
16
  */
19
- baseUrl?: string;
17
+ absolute?: boolean | null | undefined;
20
18
  /**
21
- * Module extensions to probe for.
22
- *
23
- * **Note**: Should be sorted by priority.
24
- *
25
- * @default RESOLVE_EXTENSIONS
26
- */
27
- extensions?: string[] | readonly string[];
28
- /**
29
- * Checks for the existence of a file at `path`.
30
- *
31
- * @param {string} path - Path to check
32
- * @return {boolean} `true` if file exists, `false` otherwise
33
- */
34
- fileExists?(this: void, path: string): boolean;
35
- /**
36
- * `package.json` fields to check when resolving modules.
19
+ * Path mappings.
37
20
  *
38
- * A nested field can be selected by passing an array of field names.
21
+ * > 👉 **Note**: Paths should be relative to {@linkcode cwd}.
39
22
  *
40
- * @default ['main', 'module']
41
- */
42
- mainFields?: OneOrMany<string>[];
43
- /**
44
- * Absolute path to file containing path alias.
23
+ * @see {@linkcode Aliases}
45
24
  */
46
- parent?: string;
25
+ aliases?: Aliases | null | undefined;
47
26
  /**
48
- * Path mappings.
27
+ * URL of directory to resolve non-absolute modules from.
49
28
  *
50
- * **Note**: Should be relative to {@link baseUrl}.
29
+ * @see {@linkcode ModuleId}
51
30
  *
52
- * @see https://www.typescriptlang.org/tsconfig#paths
53
- *
54
- * @default {}
31
+ * @default cwd()
55
32
  */
56
- paths?: Record<string, string[]>;
33
+ cwd?: ModuleId | null | undefined;
57
34
  /**
58
- * Synchronously returns the contents of `filename`.
35
+ * URL of parent module.
59
36
  *
60
- * @param {string} filename - Filename
61
- * @return {string} Contents of `filename`
62
- */
63
- readFile?(this: void, filename: string): string;
64
- /**
65
- * Absolute path to tsconfig file.
37
+ * @see {@linkcode ModuleId}
66
38
  */
67
- tsconfig?: string;
39
+ parent?: ModuleId | null | undefined;
68
40
  }
69
41
  export type { ResolveAliasOptions as default };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @file Interfaces - ResolveModuleOptions
3
+ * @module mlly/interfaces/ResolveModuleOptions
4
+ */
5
+ import type { Aliases, ChangeExtFn, FileSystem, MainField, ModuleId } from '@flex-development/mlly';
6
+ import type { Condition } from '@flex-development/pkg-types';
7
+ /**
8
+ * Module resolution options.
9
+ */
10
+ interface ResolveModuleOptions {
11
+ /**
12
+ * Path mappings.
13
+ *
14
+ * > 👉 **Note**: Paths should be relative to {@linkcode cwd}.
15
+ *
16
+ * @see {@linkcode Aliases}
17
+ */
18
+ aliases?: Aliases | null | undefined;
19
+ /**
20
+ * List of export/import conditions.
21
+ *
22
+ * > 👉 **Note**: Should be sorted by priority.
23
+ *
24
+ * @see {@linkcode Condition}
25
+ * @see https://nodejs.org/api/packages.html#conditional-exports
26
+ *
27
+ * @default defaultConditions
28
+ */
29
+ conditions?: Condition[] | Set<Condition> | null | undefined;
30
+ /**
31
+ * URL of directory to resolve path aliases from.
32
+ *
33
+ * @see {@linkcode ModuleId}
34
+ *
35
+ * @default cwd()
36
+ */
37
+ cwd?: ModuleId | null | undefined;
38
+ /**
39
+ * Replacement file extension or function that returns a file extension.
40
+ *
41
+ * An empty string (`''`) or `null` will remove a file extension.
42
+ *
43
+ * @see {@linkcode ChangeExtFn}
44
+ */
45
+ ext?: ChangeExtFn | string | null | undefined;
46
+ /**
47
+ * Module extensions to probe for.
48
+ *
49
+ * > 👉 **Note**: Should be sorted by priority.
50
+ *
51
+ * @default defaultExtensions
52
+ */
53
+ extensions?: Set<string> | string[] | null | undefined;
54
+ /**
55
+ * File system API.
56
+ *
57
+ * @see {@linkcode FileSystem}
58
+ */
59
+ fs?: FileSystem | null | undefined;
60
+ /**
61
+ * List of legacy `main` fields.
62
+ *
63
+ * > 👉 **Note**: Should be sorted by priority.
64
+ *
65
+ * @see {@linkcode MainField}
66
+ *
67
+ * @default defaultMainFields
68
+ */
69
+ mainFields?: MainField[] | Set<MainField> | null | undefined;
70
+ /**
71
+ * Keep symlinks instead of resolving them.
72
+ */
73
+ preserveSymlinks?: boolean | null | undefined;
74
+ }
75
+ export type { ResolveModuleOptions as default };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @file Interfaces - ProtocolMap
3
+ * @module mlly/interfaces/ProtocolMap
4
+ */
5
+ /**
6
+ * URL protocol registry.
7
+ *
8
+ * @see https://nodejs.org/api/url.html#urlprotocol
9
+ * @see https://iana.org/assignments/uri-schemes/uri-schemes.xhtml
10
+ * @see https://url.spec.whatwg.org/#special-scheme
11
+ */
12
+ interface ProtocolMap {
13
+ blob: 'blob:';
14
+ content: 'content:';
15
+ cvs: 'cvs:';
16
+ data: 'data:';
17
+ dns: 'dns:';
18
+ file: 'file:';
19
+ fish: 'fish:';
20
+ ftp: 'ftp:';
21
+ git: 'git:';
22
+ http: 'http:';
23
+ https: 'https:';
24
+ mvn: 'mvn:';
25
+ node: 'node:';
26
+ redis: 'redis:';
27
+ sftp: 'sftp:';
28
+ ssh: 'ssh:';
29
+ svn: 'svn:';
30
+ urn: 'urn:';
31
+ viewSource: 'view-source:';
32
+ ws: 'ws:';
33
+ wss: 'wss:';
34
+ }
35
+ export type { ProtocolMap as default };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @file Interfaces - Stats
3
+ * @module mlly/interfaces/Stats
4
+ */
5
+ /**
6
+ * File system metadata.
7
+ */
8
+ interface Stats {
9
+ /**
10
+ * Check if the stats object describes a file system directory.
11
+ *
12
+ * @this {void}
13
+ *
14
+ * @return {boolean}
15
+ * `true` if stats object describes directory, `false` otherwise
16
+ */
17
+ isDirectory(this: void): boolean;
18
+ /**
19
+ * Check if the stats object describes a regular file.
20
+ *
21
+ * @this {void}
22
+ *
23
+ * @return {boolean}
24
+ * `true` if stats object describes regular file, `false` otherwise
25
+ */
26
+ isFile(this: void): boolean;
27
+ }
28
+ export type { Stats as default };