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

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 (73) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +6 -4
  3. package/dist/constants.d.mts +3 -1
  4. package/dist/enums/index.d.mts +7 -0
  5. package/dist/enums/index.mjs +8 -0
  6. package/dist/enums/kind-specifier.d.mts +14 -0
  7. package/dist/enums/kind-specifier.mjs +9 -0
  8. package/dist/enums/kind-statement.d.mts +15 -0
  9. package/dist/enums/kind-statement.mjs +10 -0
  10. package/dist/enums/kind-syntax.d.mts +22 -0
  11. package/dist/enums/kind-syntax.mjs +17 -0
  12. package/dist/index.d.mts +1 -0
  13. package/dist/index.mjs +1 -0
  14. package/dist/interfaces/import-dynamic.d.mts +24 -6
  15. package/dist/interfaces/import-static.d.mts +20 -4
  16. package/dist/interfaces/options-resolve-alias.d.mts +7 -7
  17. package/dist/interfaces/options-resolve.d.mts +11 -10
  18. package/dist/interfaces/statement-export.d.mts +22 -9
  19. package/dist/interfaces/statement-import.d.mts +15 -4
  20. package/dist/interfaces/statement-require.d.mts +15 -4
  21. package/dist/interfaces/statement.d.mts +20 -9
  22. package/dist/internal/get-compiler-options.d.mts +4 -4
  23. package/dist/internal/get-compiler-options.mjs +2 -2
  24. package/dist/lib/detect-syntax.d.mts +3 -3
  25. package/dist/lib/extract-statements.d.mts +6 -7
  26. package/dist/lib/extract-statements.mjs +1 -1
  27. package/dist/lib/find-dynamic-imports.d.mts +4 -2
  28. package/dist/lib/find-dynamic-imports.mjs +18 -9
  29. package/dist/lib/find-exports.d.mts +7 -2
  30. package/dist/lib/find-exports.mjs +57 -32
  31. package/dist/lib/find-requires.d.mts +5 -5
  32. package/dist/lib/find-requires.mjs +12 -9
  33. package/dist/lib/find-static-imports.d.mts +4 -2
  34. package/dist/lib/find-static-imports.mjs +13 -8
  35. package/dist/lib/has-cjs-syntax.d.mts +3 -1
  36. package/dist/lib/has-cjs-syntax.mjs +4 -2
  37. package/dist/lib/has-esm-syntax.d.mts +3 -1
  38. package/dist/lib/has-esm-syntax.mjs +4 -2
  39. package/dist/lib/resolve-alias.d.mts +1 -1
  40. package/dist/lib/resolve-alias.mjs +3 -3
  41. package/dist/lib/resolve-aliases.d.mts +2 -2
  42. package/dist/lib/resolve-aliases.mjs +3 -3
  43. package/dist/lib/resolve-module.d.mts +4 -4
  44. package/dist/lib/resolve-module.mjs +3 -3
  45. package/dist/lib/resolve-modules.d.mts +2 -2
  46. package/dist/lib/resolve-modules.mjs +4 -3
  47. package/dist/lib/to-absolute-specifier.d.mts +1 -1
  48. package/dist/lib/to-absolute-specifier.mjs +3 -3
  49. package/dist/lib/to-bare-specifier.d.mts +3 -3
  50. package/dist/lib/to-bare-specifier.mjs +7 -7
  51. package/dist/lib/to-data-url.d.mts +1 -1
  52. package/dist/lib/to-relative-specifier.d.mts +1 -1
  53. package/dist/lib/to-relative-specifier.mjs +2 -2
  54. package/dist/types/declaration.d.mts +1 -1
  55. package/dist/types/index.d.mts +4 -3
  56. package/dist/types/mime-type.d.mts +1 -1
  57. package/dist/types/module-specifier-type.d.mts +11 -0
  58. package/dist/{internal/compiler-options-json.mjs → types/module-specifier-type.mjs} +0 -0
  59. package/dist/types/syntax-kind-export.d.mts +12 -0
  60. package/dist/types/{ext.mjs → syntax-kind-export.mjs} +0 -0
  61. package/dist/types/syntax-kind-import.d.mts +12 -0
  62. package/dist/types/{specifier-type.mjs → syntax-kind-import.mjs} +0 -0
  63. package/dist/types/syntax-kind-require.d.mts +12 -0
  64. package/dist/types/{statement-type.mjs → syntax-kind-require.mjs} +0 -0
  65. package/package.json +66 -59
  66. package/dist/internal/compiler-options-json.d.mts +0 -111
  67. package/dist/internal/constants.d.mts +0 -70
  68. package/dist/internal/constants.mjs +0 -18
  69. package/dist/internal/index.d.mts +0 -7
  70. package/dist/internal/index.mjs +0 -5
  71. package/dist/types/ext.d.mts +0 -9
  72. package/dist/types/specifier-type.d.mts +0 -11
  73. package/dist/types/statement-type.d.mts +0 -9
package/CHANGELOG.md CHANGED
@@ -1,3 +1,80 @@
1
+ ## [1.0.0-alpha.3](https://github.com/flex-development/mlly/compare/1.0.0-alpha.2...1.0.0-alpha.3) (2022-12-26)
2
+
3
+
4
+ ### ⚠ BREAKING CHANGES
5
+
6
+ * **types:** remove `Ext`
7
+ * **types:** `SpecifierType` -> `ModuleSpecifierType`
8
+ * statements
9
+
10
+ ### :package: Build
11
+
12
+ * **deps-dev:** add @flex-development/docast ([42b8ed2](https://github.com/flex-development/mlly/commit/42b8ed2360e8b4478202ba7db7e2b5cacae9ec90))
13
+ * **deps-dev:** bump @flex-development/docast-parse to 1.0.0-alpha.4 ([9634f8d](https://github.com/flex-development/mlly/commit/9634f8d4ec4375e7d29ad709c36ce1d398293718))
14
+ * **deps-dev:** bump @flex-development/mkbuild from 1.0.0-alpha.8 to 1.0.0-alpha.9 ([0262207](https://github.com/flex-development/mlly/commit/026220768f780149e143c0a5e6d35f9c2a4f0215))
15
+ * **deps-dev:** bump deps according to `yarn upgrade-interactive` ([ab0b8ce](https://github.com/flex-development/mlly/commit/ab0b8ced1e664a9bb6a9f4a7189d870bdf76c8c0))
16
+ * **deps-dev:** bump deps according to `yarn upgrade-interactive` ([bddfa7c](https://github.com/flex-development/mlly/commit/bddfa7c3f8864ab38fe35dc295ab46e472df187e))
17
+ * **deps:** add @flex-development/tsconfig-types ([a7c38e5](https://github.com/flex-development/mlly/commit/a7c38e50ea583dde948078569b41e0aebde8cfbf))
18
+ * **deps:** replace upath with @flex-development/pathe ([8a584d6](https://github.com/flex-development/mlly/commit/8a584d6dc2fed8c4cae491c290cf58ded9ca038e))
19
+ * **docs:** [site] use flex-development/docast-parse@27c73c7c03df4d92585c538c1f8214886b1fd0a9 ([b696cf6](https://github.com/flex-development/mlly/commit/b696cf676ecb0ace14647727415a49d03092d0d5))
20
+
21
+
22
+ ### :robot: Continuous Integration
23
+
24
+ * configure private package registry for [@dependabot](https://github.com/dependabot) ([e188761](https://github.com/flex-development/mlly/commit/e1887618c8a2c5fe9cb69babd15498b618e64e66))
25
+ * fix [@dependabot](https://github.com/dependabot) npm package-ecosystem x yarn integration ([126dfab](https://github.com/flex-development/mlly/commit/126dfab8d937f3526ea109acc91565accf3b2653))
26
+ * **deps:** bump actions/add-to-project from 0.3.0 to 0.4.0 ([b5e8279](https://github.com/flex-development/mlly/commit/b5e8279269f75cee5076d86b7c34578b74f306df))
27
+ * **deps:** bump actions/checkout from 3.1.0 to 3.2.0 ([0637831](https://github.com/flex-development/mlly/commit/063783140fb475f29f821408837389219c471625))
28
+ * **deps:** bump dessant/lock-threads from 3.0.0 to 4.0.0 ([ba6063c](https://github.com/flex-development/mlly/commit/ba6063cb88556d106fb01c3948ba03d8f4848a47))
29
+ * **deps:** bump flex-development/dist-tag-action from 1.1.1 to 1.1.2 ([e19b975](https://github.com/flex-development/mlly/commit/e19b97514d655b2c89e7fa4b09aa3ea93a0f8415))
30
+ * **workflows:** [`add-to-project`] add items from repo admin account ([e271e8a](https://github.com/flex-development/mlly/commit/e271e8afe22244e3d270aa02a833ccb4b077f296))
31
+ * **workflows:** [`ci`] add node.js matrix ([28a0fa6](https://github.com/flex-development/mlly/commit/28a0fa6d809c94af458c6d5c9b661bb9d564b70a))
32
+ * **workflows:** [`ci`] archive production artifacts ([701caea](https://github.com/flex-development/mlly/commit/701caea0edc1e2d36d7a1323a88e1e714e88743d))
33
+ * **workflows:** [`ci`] let [@dependabot](https://github.com/dependabot) modify lockfile ([74ec538](https://github.com/flex-development/mlly/commit/74ec5381fd5339d0d29b1a5529e48d8b86fc2419))
34
+ * **workflows:** [`ci`] re-add node14 to matrix ([44801d8](https://github.com/flex-development/mlly/commit/44801d803774588c46299050ff858027605a2079))
35
+ * **workflows:** [`ci`] update codecov environment ([32518bd](https://github.com/flex-development/mlly/commit/32518bdd2650e01bc92dd6e212ef9420f239ac9f))
36
+ * **workflows:** [`ci`] update node setup ([b326f5d](https://github.com/flex-development/mlly/commit/b326f5d35c968fd4f1145a50a769e8d645190941)), closes [/github.com/actions/setup-node/blob/v3.5.1/docs/advanced-usage.md#yarn2](https://github.com/flex-development//github.com/actions/setup-node/blob/v3.5.1/docs/advanced-usage.md/issues/yarn2)
37
+ * **workflows:** [`ci`] upload coverage reports to codecov ([a24776b](https://github.com/flex-development/mlly/commit/a24776ba0c3aad87e36881f5558eba58f5f7a866))
38
+ * **workflows:** [`publish`] cleanup registry scope ([ba5b355](https://github.com/flex-development/mlly/commit/ba5b355f30e62cb863abd35eddaa28b5b0885f56)), closes [/github.com/actions/setup-node/blob/v3.5.1/src/authutil.ts#L28-L30](https://github.com/flex-development//github.com/actions/setup-node/blob/v3.5.1/src/authutil.ts/issues/L28-L30)
39
+ * **workflows:** [`publish`] print contents of `.npmrc` file ([2c16ff6](https://github.com/flex-development/mlly/commit/2c16ff62786d8ecc1f403d364af4d6db372e5a75))
40
+ * **workflows:** [`publish`] use node version file ([80d68c1](https://github.com/flex-development/mlly/commit/80d68c13aac5cdb0005c236d56bb8db90bd831a0)), closes [/github.com/actions/setup-node/blob/v3.5.1/action.yml#L10-L11](https://github.com/flex-development//github.com/actions/setup-node/blob/v3.5.1/action.yml/issues/L10-L11)
41
+ * **workflows:** [`release`] publish releases from repo admin account ([bbda19c](https://github.com/flex-development/mlly/commit/bbda19ca37155411a0a4e9bf4e734a7b7ad959c8))
42
+
43
+
44
+ ### :pencil: Documentation
45
+
46
+ * add "contributor covenant code of conduct" ([8f1285b](https://github.com/flex-development/mlly/commit/8f1285b12b7c74401c962d614e2c79a6a0c89585))
47
+
48
+
49
+ ### :bug: Fixes
50
+
51
+ * **install:** [git] make `postinstall` script work with git install ([1a70af2](https://github.com/flex-development/mlly/commit/1a70af2bed20cbb6667ca0dd3e8d2e7d6a38da4b))
52
+
53
+
54
+ ### :house_with_garden: Housekeeping
55
+
56
+ * project qa ([4acf639](https://github.com/flex-development/mlly/commit/4acf639b6b28c20a782e39d6f4a8c4b2adb0ae20))
57
+ * project qa ([3120990](https://github.com/flex-development/mlly/commit/312099035d0a90f044688e6619ec84dd6049d8bb))
58
+ * **github:** add commit scope `install` ([065dbbb](https://github.com/flex-development/mlly/commit/065dbbbfd271e576d5031fcd155e91007cb95f62))
59
+ * **github:** add label `scope:install` ([3ddc9c2](https://github.com/flex-development/mlly/commit/3ddc9c29e92e0e254f48f87ce7052196b79c9cc1))
60
+ * **internal:** remove barrel file ([e0ba89c](https://github.com/flex-development/mlly/commit/e0ba89cceee97e99111dd4ab7c63601b593a24d5))
61
+ * **pkg:** add keywords `ecmascript-modules` and `esmodules` ([e994f4b](https://github.com/flex-development/mlly/commit/e994f4bb182f0861f3c1c3c68c1a9d0a9a3d6631))
62
+ * **tests:** local codecov integration ([bdbae1d](https://github.com/flex-development/mlly/commit/bdbae1d44cc60409a3dabb23acae79f8180b187a))
63
+ * **yarn:** bump yarn from 4.0.0-rc.14 to 4.0.0-rc.34 ([045ee62](https://github.com/flex-development/mlly/commit/045ee6252342027657771d7bbdab6748fbb9a36a))
64
+
65
+
66
+ ### :zap: Refactors
67
+
68
+ * statements ([731bd2a](https://github.com/flex-development/mlly/commit/731bd2a770671ad771ff38e8b12fce513034db27))
69
+ * **ts:** enforce `exactOptionalPropertyTypes` ([f3109b4](https://github.com/flex-development/mlly/commit/f3109b4cb6b33528ac2655e9c90eb86a2512b00d))
70
+ * **types:** `SpecifierType` -> `ModuleSpecifierType` ([263e98b](https://github.com/flex-development/mlly/commit/263e98b4e8189315157dfb4940df76e61a661922))
71
+ * **types:** remove `Ext` ([303de20](https://github.com/flex-development/mlly/commit/303de200e3eddf4c6c33fd41db6f6f0ad84fe8ec))
72
+
73
+
74
+ ### :white_check_mark: Testing
75
+
76
+ * **ts:** add remaining type tests ([7a5430f](https://github.com/flex-development/mlly/commit/7a5430f4d95392b9fa6637d09765dcdd79d275b4))
77
+
1
78
  ## [1.0.0-alpha.2](https://github.com/flex-development/mlly/compare/1.0.0-alpha.1...1.0.0-alpha.2) (2022-11-06)
2
79
 
3
80
 
package/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # 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)
6
3
  [![npm](https://img.shields.io/npm/v/@flex-development/mlly.svg)](https://npmjs.com/package/@flex-development/mlly)
4
+ [![codecov](https://codecov.io/gh/flex-development/mlly/branch/main/graph/badge.svg?token=R2TPEBGWXB)](https://codecov.io/gh/flex-development/mlly)
7
5
  [![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)
6
+ [![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)
7
+ [![conventional commits](https://img.shields.io/badge/-conventional%20commits-fe5196?logo=conventional-commits&logoColor=ffffff)](https://conventionalcommits.org/)
8
+ [![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript&logoColor=ffffff)](https://typescriptlang.org/)
9
+ [![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat&logo=vitest&logoColor=ffffff)](https://vitest.dev/)
10
+ [![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat&logo=yarn&logoColor=ffffff)](https://yarnpkg.com/)
9
11
 
10
12
  > [ECMAScript module][1] utilities.
11
13
 
@@ -2,7 +2,7 @@
2
2
  * @file Constants
3
3
  * @module mlly/constants
4
4
  */
5
- import type { Ext } from './types/index.mjs';
5
+ import type { Ext } from '@flex-development/pathe';
6
6
  /**
7
7
  * Default export conditions.
8
8
  *
@@ -14,6 +14,8 @@ export declare const CONDITIONS: Readonly<Set<string>>;
14
14
  /**
15
15
  * Default resolvable file extensions.
16
16
  *
17
+ * @see {@linkcode Ext}
18
+ *
17
19
  * @const {ReadonlyArray<Ext>} RESOLVE_EXTENSIONS
18
20
  */
19
21
  export declare const RESOLVE_EXTENSIONS: readonly Ext[];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @file Entry Point - Enums
3
+ * @module mlly/enums
4
+ */
5
+ export { default as SpecifierKind } from './kind-specifier.mjs';
6
+ export { default as StatementKind } from './kind-statement.mjs';
7
+ export { default as SyntaxKind } from './kind-syntax.mjs';
@@ -0,0 +1,8 @@
1
+ import { default as default2 } from "./kind-specifier.mjs";
2
+ import { default as default3 } from "./kind-statement.mjs";
3
+ import { default as default4 } from "./kind-syntax.mjs";
4
+ export {
5
+ default2 as SpecifierKind,
6
+ default3 as StatementKind,
7
+ default4 as SyntaxKind
8
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @file Enums - SpecifierKind
3
+ * @module mlly/enums/SpecifierKind
4
+ */
5
+ /**
6
+ * Specifier kinds.
7
+ *
8
+ * @enum {Lowercase<string>}
9
+ */
10
+ declare enum SpecifierKind {
11
+ DYNAMIC = "dynamic",
12
+ STATIC = "static"
13
+ }
14
+ export default SpecifierKind;
@@ -0,0 +1,9 @@
1
+ var SpecifierKind = /* @__PURE__ */ ((SpecifierKind2) => {
2
+ SpecifierKind2["DYNAMIC"] = "dynamic";
3
+ SpecifierKind2["STATIC"] = "static";
4
+ return SpecifierKind2;
5
+ })(SpecifierKind || {});
6
+ var kind_specifier_default = SpecifierKind;
7
+ export {
8
+ kind_specifier_default as default
9
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @file Enums - StatementKind
3
+ * @module mlly/enums/StatementKind
4
+ */
5
+ /**
6
+ * CommonJS and ESM statement kinds.
7
+ *
8
+ * @enum {Lowercase<string>}
9
+ */
10
+ declare enum StatementKind {
11
+ EXPORT = "export",
12
+ IMPORT = "import",
13
+ REQUIRE = "require"
14
+ }
15
+ export default StatementKind;
@@ -0,0 +1,10 @@
1
+ var StatementKind = /* @__PURE__ */ ((StatementKind2) => {
2
+ StatementKind2["EXPORT"] = "export";
3
+ StatementKind2["IMPORT"] = "import";
4
+ StatementKind2["REQUIRE"] = "require";
5
+ return StatementKind2;
6
+ })(StatementKind || {});
7
+ var kind_statement_default = StatementKind;
8
+ export {
9
+ kind_statement_default as default
10
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @file Enums - SyntaxKind
3
+ * @module mlly/enums/SyntaxKind
4
+ */
5
+ /**
6
+ * CommonJS and ESM statement syntax kinds.
7
+ *
8
+ * @enum {Lowercase<string>}
9
+ */
10
+ declare enum SyntaxKind {
11
+ DECLARATION = "declaration",
12
+ DEFAULT = "default",
13
+ DEFAULT_WITH_NAMED = "default-with-named",
14
+ DEFAULT_WITH_NAMESPACE = "default-with-namespace",
15
+ DYNAMIC = "dynamic",
16
+ LIST = "list",
17
+ NAMED = "named",
18
+ NAMESPACE = "namespace",
19
+ REQUIRE = "require",
20
+ SIDE_EFFECT = "side-effect"
21
+ }
22
+ export default SyntaxKind;
@@ -0,0 +1,17 @@
1
+ var SyntaxKind = /* @__PURE__ */ ((SyntaxKind2) => {
2
+ SyntaxKind2["DECLARATION"] = "declaration";
3
+ SyntaxKind2["DEFAULT"] = "default";
4
+ SyntaxKind2["DEFAULT_WITH_NAMED"] = "default-with-named";
5
+ SyntaxKind2["DEFAULT_WITH_NAMESPACE"] = "default-with-namespace";
6
+ SyntaxKind2["DYNAMIC"] = "dynamic";
7
+ SyntaxKind2["LIST"] = "list";
8
+ SyntaxKind2["NAMED"] = "named";
9
+ SyntaxKind2["NAMESPACE"] = "namespace";
10
+ SyntaxKind2["REQUIRE"] = "require";
11
+ SyntaxKind2["SIDE_EFFECT"] = "side-effect";
12
+ return SyntaxKind2;
13
+ })(SyntaxKind || {});
14
+ var kind_syntax_default = SyntaxKind;
15
+ export {
16
+ kind_syntax_default as default
17
+ };
package/dist/index.d.mts CHANGED
@@ -3,6 +3,7 @@
3
3
  * @module mlly
4
4
  */
5
5
  export * from './constants.mjs';
6
+ export * from './enums/index.mjs';
6
7
  export * from './interfaces/index.mjs';
7
8
  export * from './lib/index.mjs';
8
9
  export * from './types/index.mjs';
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./constants.mjs";
2
+ export * from "./enums/index.mjs";
2
3
  export * from "./interfaces/index.mjs";
3
4
  export * from "./lib/index.mjs";
4
5
  export * from "./types/index.mjs";
@@ -2,22 +2,40 @@
2
2
  * @file Interfaces - DynamicImport
3
3
  * @module mlly/interfaces/DynamicImport
4
4
  */
5
+ import type { SyntaxKind } from '../enums/index.mjs';
6
+ import type { SyntaxKindImport } from '../types/index.mjs';
7
+ import type { EmptyString, LiteralUnion } from '@flex-development/tutils';
5
8
  import type ImportStatement from './statement-import.mjs';
6
9
  /**
7
- * Dynamic import statement object schema.
10
+ * Dynamic import statement object.
8
11
  *
9
- * @see {@link ImportStatement}
12
+ * @see {@linkcode ImportStatement}
13
+ * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/import
10
14
  *
11
15
  * @extends {ImportStatement}
12
16
  */
13
17
  interface DynamicImport extends ImportStatement {
14
18
  /**
15
- * Module specifier type.
19
+ * Import expression.
20
+ *
21
+ * @example
22
+ * 'import("foo.json")'
23
+ * @example
24
+ * 'import(foo)'
16
25
  */
17
- specifier_type: 'dynamic' | 'static';
26
+ expression: LiteralUnion<EmptyString, string>;
18
27
  /**
19
- * Import statement type.
28
+ * Options bag.
29
+ *
30
+ * @see https://github.com/tc39/proposal-import-assertions#dynamic-import
31
+ *
32
+ * @example
33
+ * '{ assert: { type: "json" } }'
20
34
  */
21
- type: 'dynamic';
35
+ options: LiteralUnion<EmptyString, string>;
36
+ /**
37
+ * Statement syntax kind.
38
+ */
39
+ syntax: Extract<SyntaxKindImport, SyntaxKind.DYNAMIC>;
22
40
  }
23
41
  export type { DynamicImport as default };
@@ -2,18 +2,34 @@
2
2
  * @file Interfaces - StaticImport
3
3
  * @module mlly/interfaces/StaticImport
4
4
  */
5
+ import type { SyntaxKind } from '../enums/index.mjs';
6
+ import type { SyntaxKindImport } from '../types/index.mjs';
7
+ import type { EmptyString, LiteralUnion } from '@flex-development/tutils';
5
8
  import type ImportStatement from './statement-import.mjs';
6
9
  /**
7
- * Static import statement object schema.
10
+ * Static import statement object.
8
11
  *
9
- * @see {@link ImportStatement}
12
+ * @see {@linkcode ImportStatement}
10
13
  *
11
14
  * @extends {ImportStatement}
12
15
  */
13
16
  interface StaticImport extends ImportStatement {
14
17
  /**
15
- * Import statement type.
18
+ * Assertion options.
19
+ *
20
+ * @see https://github.com/tc39/proposal-import-assertions#import-statements
21
+ *
22
+ * @example
23
+ * '{ type: "json" }'
16
24
  */
17
- type: 'default' | 'named' | 'star';
25
+ assertion: LiteralUnion<EmptyString, string>;
26
+ /**
27
+ * Statement syntax kind.
28
+ */
29
+ syntax: Extract<SyntaxKindImport, SyntaxKind.DEFAULT | SyntaxKind.DEFAULT_WITH_NAMED | SyntaxKind.DEFAULT_WITH_NAMESPACE | SyntaxKind.NAMED | SyntaxKind.NAMESPACE | SyntaxKind.SIDE_EFFECT>;
30
+ /**
31
+ * Type-only import statement check.
32
+ */
33
+ type: boolean;
18
34
  }
19
35
  export type { StaticImport as default };
@@ -16,7 +16,7 @@ interface ResolveAliasOptions {
16
16
  *
17
17
  * @default process.cwd()
18
18
  */
19
- baseUrl?: string;
19
+ baseUrl?: string | undefined;
20
20
  /**
21
21
  * Module extensions to probe for.
22
22
  *
@@ -24,7 +24,7 @@ interface ResolveAliasOptions {
24
24
  *
25
25
  * @default RESOLVE_EXTENSIONS
26
26
  */
27
- extensions?: string[] | readonly string[];
27
+ extensions?: string[] | readonly string[] | undefined;
28
28
  /**
29
29
  * Checks for the existence of a file at `path`.
30
30
  *
@@ -39,21 +39,21 @@ interface ResolveAliasOptions {
39
39
  *
40
40
  * @default ['main', 'module']
41
41
  */
42
- mainFields?: OneOrMany<string>[];
42
+ mainFields?: OneOrMany<string>[] | undefined;
43
43
  /**
44
44
  * Absolute path to file containing path alias.
45
45
  */
46
- parent?: string;
46
+ parent?: string | undefined;
47
47
  /**
48
48
  * Path mappings.
49
49
  *
50
- * **Note**: Should be relative to {@link baseUrl}.
50
+ * **Note**: Should be relative to {@linkcode baseUrl}.
51
51
  *
52
52
  * @see https://www.typescriptlang.org/tsconfig#paths
53
53
  *
54
54
  * @default {}
55
55
  */
56
- paths?: Record<string, string[]>;
56
+ paths?: Record<string, string[]> | undefined;
57
57
  /**
58
58
  * Synchronously returns the contents of `filename`.
59
59
  *
@@ -64,6 +64,6 @@ interface ResolveAliasOptions {
64
64
  /**
65
65
  * Absolute path to tsconfig file.
66
66
  */
67
- tsconfig?: string;
67
+ tsconfig?: string | undefined;
68
68
  }
69
69
  export type { ResolveAliasOptions as default };
@@ -3,7 +3,8 @@
3
3
  * @module mlly/interfaces/ResolveOptions
4
4
  */
5
5
  /// <reference types="node" />
6
- import type { Ext, SpecifierType } from '../types/index.mjs';
6
+ import type { ModuleSpecifierType } from '../types/index.mjs';
7
+ import type { Ext } from '@flex-development/pathe';
7
8
  import type { EmptyString } from '@flex-development/tutils';
8
9
  import type { URL } from 'node:url';
9
10
  /**
@@ -19,15 +20,15 @@ interface ResolveOptions {
19
20
  *
20
21
  * @default CONDITIONS
21
22
  */
22
- conditions?: Set<string> | string[] | readonly string[];
23
+ conditions?: Set<string> | string[] | readonly string[] | undefined;
23
24
  /**
24
25
  * Remove or replace file extension.
25
26
  *
26
- * **Note**: {@link type} must be set to `relative`.
27
+ * **Note**: {@linkcode type} must be set to `relative`.
27
28
  *
28
- * @see {@link Ext}
29
+ * @see {@linkcode Ext}
29
30
  */
30
- ext?: Ext | false | ((specifier: string, resolved: string) => EmptyString | Ext | PromiseLike<EmptyString | Ext>);
31
+ ext?: Ext | false | ((specifier: string, resolved: string) => EmptyString | Ext | PromiseLike<EmptyString | Ext>) | undefined;
31
32
  /**
32
33
  * Module extensions to probe for.
33
34
  *
@@ -35,26 +36,26 @@ interface ResolveOptions {
35
36
  *
36
37
  * @default RESOLVE_EXTENSIONS
37
38
  */
38
- extensions?: string[] | readonly string[];
39
+ extensions?: string[] | readonly string[] | undefined;
39
40
  /**
40
41
  * Parent module URL or path to resolve from.
41
42
  *
42
43
  * @default import.meta.url
43
44
  */
44
- parent?: URL | string;
45
+ parent?: URL | string | undefined;
45
46
  /**
46
47
  * Keep symlinks instead of resolving them.
47
48
  *
48
49
  * @default false
49
50
  */
50
- preserveSymlinks?: boolean;
51
+ preserveSymlinks?: boolean | undefined;
51
52
  /**
52
53
  * Module specifier type or a function to determine module specifier type.
53
54
  *
54
- * @see {@link SpecifierType}
55
+ * @see {@linkcode ModuleSpecifierType}
55
56
  *
56
57
  * @default 'absolute'
57
58
  */
58
- type?: SpecifierType | ((resolved: string) => PromiseLike<SpecifierType> | SpecifierType);
59
+ type?: ModuleSpecifierType | ((resolved: string) => ModuleSpecifierType | PromiseLike<ModuleSpecifierType>) | undefined;
59
60
  }
60
61
  export type { ResolveOptions as default };
@@ -2,30 +2,43 @@
2
2
  * @file Interfaces - ExportStatement
3
3
  * @module mlly/interfaces/ExportStatement
4
4
  */
5
- import type { Declaration } from '../types/index.mjs';
5
+ import type { StatementKind } from '../enums/index.mjs';
6
+ import type { Declaration, SyntaxKindExport } from '../types/index.mjs';
7
+ import type { Nullable } from '@flex-development/tutils';
6
8
  import type Statement from './statement.mjs';
7
9
  /**
8
- * Export statement object schema.
10
+ * Export statement object.
9
11
  *
10
- * @see {@link Declaration}
11
- * @see {@link Statement}
12
+ * @see {@linkcode Declaration}
13
+ * @see {@linkcode Statement}
14
+ * @see {@linkcode SyntaxKindExport}
12
15
  *
13
16
  * @extends {Statement}
14
17
  */
15
18
  interface ExportStatement extends Statement {
16
19
  /**
17
20
  * Export declaration, if any.
18
- *
19
- * @see {@link Declaration}
20
21
  */
21
- declaration: Declaration | undefined;
22
+ declaration: Nullable<Declaration>;
22
23
  /**
23
24
  * Export names.
24
25
  */
25
26
  exports: string[];
26
27
  /**
27
- * Export statement type.
28
+ * Statement kind.
28
29
  */
29
- type: 'declaration' | 'default' | 'named' | 'star';
30
+ kind: StatementKind.EXPORT;
31
+ /**
32
+ * Modifier keywords.
33
+ */
34
+ modifiers: string[];
35
+ /**
36
+ * Statement syntax kind.
37
+ */
38
+ syntax: SyntaxKindExport;
39
+ /**
40
+ * Type-only export statement check.
41
+ */
42
+ type: boolean;
30
43
  }
31
44
  export type { ExportStatement as default };
@@ -2,11 +2,14 @@
2
2
  * @file Interfaces - ImportStatement
3
3
  * @module mlly/interfaces/ImportStatement
4
4
  */
5
+ import type { StatementKind } from '../enums/index.mjs';
6
+ import type { SyntaxKindImport } from '../types/index.mjs';
5
7
  import type Statement from './statement.mjs';
6
8
  /**
7
- * Import statement object schema.
9
+ * Import statement object.
8
10
  *
9
- * @see {@link Statement}
11
+ * @see {@linkcode Statement}
12
+ * @see {@linkcode SyntaxKindImport}
10
13
  *
11
14
  * @extends {Statement}
12
15
  */
@@ -15,13 +18,21 @@ interface ImportStatement extends Statement {
15
18
  * Import names.
16
19
  */
17
20
  imports: string[];
21
+ /**
22
+ * Statement kind.
23
+ */
24
+ kind: StatementKind.IMPORT;
18
25
  /**
19
26
  * Module specifier.
20
27
  */
21
28
  specifier: NonNullable<Statement['specifier']>;
22
29
  /**
23
- * Import statement type.
30
+ * Module specifier kind.
31
+ */
32
+ specifier_kind: NonNullable<Statement['specifier_kind']>;
33
+ /**
34
+ * Statement syntax kind.
24
35
  */
25
- type: 'default' | 'dynamic' | 'named' | 'star';
36
+ syntax: SyntaxKindImport;
26
37
  }
27
38
  export type { ImportStatement as default };
@@ -2,11 +2,14 @@
2
2
  * @file Interfaces - RequireStatement
3
3
  * @module mlly/interfaces/RequireStatement
4
4
  */
5
+ import type { StatementKind } from '../enums/index.mjs';
6
+ import type { SyntaxKindRequire } from '../types/index.mjs';
5
7
  import type Statement from './statement.mjs';
6
8
  /**
7
- * Require statement object schema.
9
+ * Require statement object.
8
10
  *
9
- * @see {@link Statement}
11
+ * @see {@linkcode Statement}
12
+ * @see {@linkcode SyntaxKindRequire}
10
13
  *
11
14
  * @extends {Statement}
12
15
  */
@@ -15,13 +18,21 @@ interface RequireStatement extends Statement {
15
18
  * Import names.
16
19
  */
17
20
  imports: string[];
21
+ /**
22
+ * Statement kind.
23
+ */
24
+ kind: StatementKind.REQUIRE;
18
25
  /**
19
26
  * Module specifier.
20
27
  */
21
28
  specifier: NonNullable<Statement['specifier']>;
22
29
  /**
23
- * Import statement type.
30
+ * Module specifier kind.
31
+ */
32
+ specifier_kind: NonNullable<Statement['specifier_kind']>;
33
+ /**
34
+ * Statement syntax kind.
24
35
  */
25
- type: 'require';
36
+ syntax: SyntaxKindRequire;
26
37
  }
27
38
  export type { RequireStatement as default };
@@ -2,11 +2,14 @@
2
2
  * @file Interfaces - Statement
3
3
  * @module mlly/interfaces/Statement
4
4
  */
5
- import type { StatementType } from '../types/index.mjs';
5
+ import type { SpecifierKind, StatementKind, SyntaxKind } from '../enums/index.mjs';
6
+ import type { Nullable } from '@flex-development/tutils';
6
7
  /**
7
- * CommonJS or ESM statement object schema.
8
+ * CommonJS or ESM statement object.
8
9
  *
9
- * @see {@link StatementType}
10
+ * @see {@linkcode SpecifierKind}
11
+ * @see {@linkcode StatementKind}
12
+ * @see {@linkcode SyntaxKind}
10
13
  */
11
14
  interface Statement {
12
15
  /**
@@ -14,20 +17,28 @@ interface Statement {
14
17
  */
15
18
  code: string;
16
19
  /**
17
- * Ending index of {@link code} in source content.
20
+ * End index of {@linkcode code} in source content.
18
21
  */
19
22
  end: number;
23
+ /**
24
+ * Statement kind.
25
+ */
26
+ kind: StatementKind;
20
27
  /**
21
28
  * Module specifier.
22
29
  */
23
- specifier: string | undefined;
30
+ specifier: Nullable<string>;
24
31
  /**
25
- * Starting index of {@link code} in source content.
32
+ * Module specifier kind.
26
33
  */
27
- start: number;
34
+ specifier_kind: Nullable<SpecifierKind>;
28
35
  /**
29
- * Statement type.
36
+ * Statement syntax kind.
30
37
  */
31
- type: StatementType;
38
+ syntax: SyntaxKind;
39
+ /**
40
+ * Start index of {@linkcode code} in source content.
41
+ */
42
+ start: number;
32
43
  }
33
44
  export type { Statement as default };