@flex-development/mlly 1.0.0-alpha.1 → 1.0.0-alpha.10
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 +412 -3
- package/README.md +6 -4
- package/changelog.config.ts +404 -0
- package/dist/enums/assert-type.d.mts +21 -0
- package/dist/enums/assert-type.mjs +10 -0
- package/dist/enums/assert-type.mjs.map +6 -0
- package/dist/enums/format.d.mts +17 -0
- package/dist/enums/format.mjs +13 -0
- package/dist/enums/format.mjs.map +6 -0
- package/dist/enums/index.d.mts +10 -0
- package/dist/enums/index.mjs +15 -0
- package/dist/enums/index.mjs.map +6 -0
- package/dist/enums/kind-specifier-syntax.d.mts +14 -0
- package/dist/enums/kind-specifier-syntax.mjs +10 -0
- package/dist/enums/kind-specifier-syntax.mjs.map +6 -0
- package/dist/enums/kind-specifier.d.mts +17 -0
- package/dist/enums/kind-specifier.mjs +11 -0
- package/dist/enums/kind-specifier.mjs.map +6 -0
- package/dist/enums/kind-statement-syntax.d.mts +22 -0
- package/dist/enums/kind-statement-syntax.mjs +18 -0
- package/dist/enums/kind-statement-syntax.mjs.map +6 -0
- package/dist/enums/kind-statement.d.mts +15 -0
- package/dist/enums/kind-statement.mjs +11 -0
- package/dist/enums/kind-statement.mjs.map +6 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +6 -0
- package/dist/interfaces/import-assertions.d.mts +20 -0
- package/dist/interfaces/import-dynamic.d.mts +26 -6
- package/dist/interfaces/import-static.d.mts +22 -4
- package/dist/interfaces/index.d.mts +12 -0
- package/dist/interfaces/index.mjs +1 -0
- package/dist/interfaces/index.mjs.map +6 -0
- package/dist/interfaces/options-fill-module.d.mts +23 -0
- package/dist/interfaces/options-find-subpath.d.mts +49 -0
- package/dist/interfaces/options-get-format.d.mts +83 -0
- package/dist/interfaces/options-get-source.d.mts +63 -0
- package/dist/interfaces/options-parse-module-id.d.mts +33 -0
- package/dist/interfaces/options-parse-subpath.d.mts +31 -0
- package/dist/interfaces/options-resolve-alias.d.mts +26 -42
- package/dist/interfaces/options-resolve-module.d.mts +64 -0
- package/dist/interfaces/options-resolve.d.mts +7 -52
- package/dist/interfaces/package-scope.d.mts +25 -0
- package/dist/interfaces/parsed-data-url.d.mts +56 -0
- package/dist/interfaces/parsed-module-id.d.mts +80 -0
- package/dist/interfaces/parsed-subpath.d.mts +40 -0
- package/dist/interfaces/statement-export.d.mts +22 -9
- package/dist/interfaces/statement-import.d.mts +15 -4
- package/dist/interfaces/statement-require.d.mts +15 -4
- package/dist/interfaces/statement.d.mts +24 -8
- package/dist/internal/escape-reg-exp.d.mts +16 -0
- package/dist/internal/escape-reg-exp.mjs +10 -0
- package/dist/internal/escape-reg-exp.mjs.map +6 -0
- package/dist/internal/format-type-map.d.mts +17 -0
- package/dist/internal/format-type-map.mjs +13 -0
- package/dist/internal/format-type-map.mjs.map +6 -0
- package/dist/internal/get-specifier-kind.d.mts +17 -0
- package/dist/internal/get-specifier-kind.mjs +14 -0
- package/dist/internal/get-specifier-kind.mjs.map +6 -0
- package/dist/internal/get-subpaths.d.mts +25 -0
- package/dist/internal/get-subpaths.mjs +10 -0
- package/dist/internal/get-subpaths.mjs.map +6 -0
- package/dist/internal/is-array-index.d.mts +15 -0
- package/dist/internal/is-array-index.mjs +9 -0
- package/dist/internal/is-array-index.mjs.map +6 -0
- package/dist/internal/is-directory.d.mts +13 -0
- package/dist/internal/is-directory.mjs +16 -0
- package/dist/internal/is-directory.mjs.map +6 -0
- package/dist/internal/is-file.d.mts +13 -0
- package/dist/internal/is-file.mjs +16 -0
- package/dist/internal/is-file.mjs.map +6 -0
- package/dist/internal/is-function.d.mts +12 -0
- package/dist/internal/is-function.mjs +8 -0
- package/dist/internal/is-function.mjs.map +6 -0
- package/dist/internal/regex-encoded-sep.d.mts +13 -0
- package/dist/internal/regex-encoded-sep.mjs +6 -0
- package/dist/internal/regex-encoded-sep.mjs.map +6 -0
- package/dist/internal/regex-internal-specifier.d.mts +14 -0
- package/dist/internal/regex-internal-specifier.mjs +6 -0
- package/dist/internal/regex-internal-specifier.mjs.map +6 -0
- package/dist/internal/regex-package-name.d.mts +13 -0
- package/dist/internal/regex-package-name.mjs +6 -0
- package/dist/internal/regex-package-name.mjs.map +6 -0
- package/dist/internal/regex-package-path.d.mts +15 -0
- package/dist/internal/regex-package-path.mjs +6 -0
- package/dist/internal/regex-package-path.mjs.map +6 -0
- package/dist/internal/resolver.d.mts +130 -0
- package/dist/internal/resolver.mjs +500 -0
- package/dist/internal/resolver.mjs.map +6 -0
- package/dist/internal/validate-boolean.d.mts +20 -0
- package/dist/internal/validate-boolean.mjs +11 -0
- package/dist/internal/validate-boolean.mjs.map +6 -0
- package/dist/internal/validate-object.d.mts +23 -0
- package/dist/internal/validate-object.mjs +11 -0
- package/dist/internal/validate-object.mjs.map +6 -0
- package/dist/internal/validate-set.d.mts +23 -0
- package/dist/internal/validate-set.mjs +11 -0
- package/dist/internal/validate-set.mjs.map +6 -0
- package/dist/internal/validate-string.d.mts +20 -0
- package/dist/internal/validate-string.mjs +11 -0
- package/dist/internal/validate-string.mjs.map +6 -0
- package/dist/internal/validate-url-string.d.mts +22 -0
- package/dist/internal/validate-url-string.mjs +12 -0
- package/dist/internal/validate-url-string.mjs.map +6 -0
- package/dist/types/declaration.d.mts +1 -1
- package/dist/types/fn-change-ext.d.mts +28 -0
- package/dist/types/index.d.mts +8 -4
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +6 -0
- package/dist/types/mime-type.d.mts +7 -5
- package/dist/types/module-id.d.mts +13 -0
- package/dist/types/module-specifier-type.d.mts +11 -0
- package/dist/types/protocol.d.mts +14 -0
- package/dist/types/syntax-kind-export.d.mts +12 -0
- package/dist/types/syntax-kind-import.d.mts +12 -0
- package/dist/types/syntax-kind-require.d.mts +12 -0
- package/dist/utils/compare-subpaths.d.mts +25 -0
- package/dist/utils/compare-subpaths.mjs +24 -0
- package/dist/utils/compare-subpaths.mjs.map +6 -0
- package/dist/utils/conditions.d.mts +13 -0
- package/dist/utils/conditions.mjs +6 -0
- package/dist/utils/conditions.mjs.map +6 -0
- package/dist/{lib → utils}/detect-syntax.d.mts +4 -4
- package/dist/{lib → utils}/detect-syntax.mjs +1 -0
- package/dist/utils/detect-syntax.mjs.map +6 -0
- package/dist/utils/extension-format-map.d.mts +16 -0
- package/dist/utils/extension-format-map.mjs +22 -0
- package/dist/utils/extension-format-map.mjs.map +6 -0
- package/dist/utils/extract-statements.d.mts +21 -0
- package/dist/{lib → utils}/extract-statements.mjs +4 -1
- package/dist/utils/extract-statements.mjs.map +6 -0
- package/dist/utils/fill-modules.d.mts +23 -0
- package/dist/utils/fill-modules.mjs +63 -0
- package/dist/utils/fill-modules.mjs.map +6 -0
- package/dist/utils/find-dynamic-imports.d.mts +18 -0
- package/dist/utils/find-dynamic-imports.mjs +39 -0
- package/dist/utils/find-dynamic-imports.mjs.map +6 -0
- package/dist/utils/find-exports.d.mts +21 -0
- package/dist/utils/find-exports.mjs +95 -0
- package/dist/utils/find-exports.mjs.map +6 -0
- package/dist/utils/find-requires.d.mts +18 -0
- package/dist/utils/find-requires.mjs +32 -0
- package/dist/utils/find-requires.mjs.map +6 -0
- package/dist/utils/find-static-imports.d.mts +18 -0
- package/dist/utils/find-static-imports.mjs +34 -0
- package/dist/utils/find-static-imports.mjs.map +6 -0
- package/dist/utils/find-subpath.d.mts +30 -0
- package/dist/utils/find-subpath.mjs +106 -0
- package/dist/utils/find-subpath.mjs.map +6 -0
- package/dist/utils/get-format.d.mts +24 -0
- package/dist/utils/get-format.mjs +111 -0
- package/dist/utils/get-format.mjs.map +6 -0
- package/dist/utils/get-source.d.mts +22 -0
- package/dist/utils/get-source.mjs +63 -0
- package/dist/utils/get-source.mjs.map +6 -0
- package/dist/{lib → utils}/has-cjs-syntax.d.mts +5 -2
- package/dist/utils/has-cjs-syntax.mjs +11 -0
- package/dist/utils/has-cjs-syntax.mjs.map +6 -0
- package/dist/{lib → utils}/has-esm-syntax.d.mts +5 -2
- package/dist/utils/has-esm-syntax.mjs +11 -0
- package/dist/utils/has-esm-syntax.mjs.map +6 -0
- package/dist/utils/index.d.mts +42 -0
- package/dist/utils/index.mjs +79 -0
- package/dist/utils/index.mjs.map +6 -0
- package/dist/utils/is-absolute-specifier.d.mts +19 -0
- package/dist/utils/is-absolute-specifier.mjs +25 -0
- package/dist/utils/is-absolute-specifier.mjs.map +6 -0
- package/dist/utils/is-bare-specifier.d.mts +19 -0
- package/dist/utils/is-bare-specifier.mjs +10 -0
- package/dist/utils/is-bare-specifier.mjs.map +6 -0
- package/dist/utils/is-exports-sugar.d.mts +25 -0
- package/dist/utils/is-exports-sugar.mjs +26 -0
- package/dist/utils/is-exports-sugar.mjs.map +6 -0
- package/dist/utils/is-relative-specifier.d.mts +20 -0
- package/dist/utils/is-relative-specifier.mjs +11 -0
- package/dist/utils/is-relative-specifier.mjs.map +6 -0
- package/dist/utils/lookup-package-scope.d.mts +26 -0
- package/dist/utils/lookup-package-scope.mjs +38 -0
- package/dist/utils/lookup-package-scope.mjs.map +6 -0
- package/dist/utils/parse-data-url.d.mts +25 -0
- package/dist/utils/parse-data-url.mjs +25 -0
- package/dist/utils/parse-data-url.mjs.map +6 -0
- package/dist/utils/parse-module-id.d.mts +22 -0
- package/dist/utils/parse-module-id.mjs +122 -0
- package/dist/utils/parse-module-id.mjs.map +6 -0
- package/dist/utils/parse-subpath.d.mts +35 -0
- package/dist/utils/parse-subpath.mjs +54 -0
- package/dist/utils/parse-subpath.mjs.map +6 -0
- package/dist/utils/pattern-character.d.mts +11 -0
- package/dist/utils/pattern-character.mjs +6 -0
- package/dist/utils/pattern-character.mjs.map +6 -0
- package/dist/utils/read-package-json.d.mts +26 -0
- package/dist/utils/read-package-json.mjs +43 -0
- package/dist/utils/read-package-json.mjs.map +6 -0
- package/dist/utils/resolve-alias.d.mts +20 -0
- package/dist/utils/resolve-alias.mjs +106 -0
- package/dist/utils/resolve-alias.mjs.map +6 -0
- package/dist/utils/resolve-aliases.d.mts +19 -0
- package/dist/utils/resolve-aliases.mjs +28 -0
- package/dist/utils/resolve-aliases.mjs.map +6 -0
- package/dist/utils/resolve-extensions.d.mts +14 -0
- package/dist/utils/resolve-extensions.mjs +22 -0
- package/dist/utils/resolve-extensions.mjs.map +6 -0
- package/dist/utils/resolve-module.d.mts +39 -0
- package/dist/utils/resolve-module.mjs +64 -0
- package/dist/utils/resolve-module.mjs.map +6 -0
- package/dist/utils/resolve-modules.d.mts +25 -0
- package/dist/{lib → utils}/resolve-modules.mjs +7 -10
- package/dist/utils/resolve-modules.mjs.map +6 -0
- package/dist/{lib → utils}/to-absolute-specifier.d.mts +6 -6
- package/dist/utils/to-absolute-specifier.mjs +8 -0
- package/dist/utils/to-absolute-specifier.mjs.map +6 -0
- package/dist/utils/to-bare-specifier.d.mts +42 -0
- package/dist/utils/to-bare-specifier.mjs +90 -0
- package/dist/utils/to-bare-specifier.mjs.map +6 -0
- package/dist/{lib → utils}/to-data-url.d.mts +6 -5
- package/dist/{lib → utils}/to-data-url.mjs +4 -0
- package/dist/utils/to-data-url.mjs.map +6 -0
- package/dist/utils/to-node-url.d.mts +19 -0
- package/dist/utils/to-node-url.mjs +10 -0
- package/dist/utils/to-node-url.mjs.map +6 -0
- package/dist/{lib → utils}/to-relative-specifier.d.mts +6 -6
- package/dist/{lib → utils}/to-relative-specifier.mjs +7 -3
- package/dist/utils/to-relative-specifier.mjs.map +6 -0
- package/dist/utils/to-url.d.mts +22 -0
- package/dist/utils/to-url.mjs +12 -0
- package/dist/utils/to-url.mjs.map +6 -0
- package/dist/utils/validate-assertions.d.mts +23 -0
- package/dist/utils/validate-assertions.mjs +52 -0
- package/dist/utils/validate-assertions.mjs.map +6 -0
- package/dist/utils/validate-exports.d.mts +24 -0
- package/dist/utils/validate-exports.mjs +72 -0
- package/dist/utils/validate-exports.mjs.map +6 -0
- package/package.json +106 -83
- package/src/enums/assert-type.ts +23 -0
- package/src/enums/format.ts +19 -0
- package/src/enums/index.ts +11 -0
- package/src/enums/kind-specifier-syntax.ts +16 -0
- package/src/enums/kind-specifier.ts +19 -0
- package/src/enums/kind-statement-syntax.ts +24 -0
- package/src/enums/kind-statement.ts +17 -0
- package/src/index.ts +9 -0
- package/src/interfaces/import-assertions.ts +24 -0
- package/src/interfaces/import-dynamic.ts +48 -0
- package/src/interfaces/import-static.ts +50 -0
- package/src/interfaces/index.ts +25 -0
- package/src/interfaces/options-fill-module.ts +26 -0
- package/src/interfaces/options-find-subpath.ts +56 -0
- package/src/interfaces/options-get-format.ts +92 -0
- package/src/interfaces/options-get-source.ts +70 -0
- package/src/interfaces/options-parse-module-id.ts +38 -0
- package/src/interfaces/options-parse-subpath.ts +36 -0
- package/src/interfaces/options-resolve-alias.ts +59 -0
- package/src/interfaces/options-resolve-module.ts +72 -0
- package/src/interfaces/options-resolve.ts +17 -0
- package/src/interfaces/package-scope.ts +30 -0
- package/src/interfaces/parsed-data-url.ts +63 -0
- package/src/interfaces/parsed-module-id.ts +90 -0
- package/src/interfaces/parsed-subpath.ts +47 -0
- package/src/interfaces/statement-export.ts +52 -0
- package/src/interfaces/statement-import.ts +45 -0
- package/src/interfaces/statement-require.ts +45 -0
- package/src/interfaces/statement.ts +64 -0
- package/src/internal/escape-reg-exp.ts +24 -0
- package/src/internal/format-type-map.ts +26 -0
- package/src/internal/get-specifier-kind.ts +38 -0
- package/src/internal/get-subpaths.ts +41 -0
- package/src/internal/is-array-index.ts +28 -0
- package/src/internal/is-directory.ts +25 -0
- package/src/internal/is-file.ts +25 -0
- package/src/internal/is-function.ts +16 -0
- package/src/internal/regex-encoded-sep.ts +15 -0
- package/src/internal/regex-internal-specifier.ts +17 -0
- package/src/internal/regex-package-name.ts +16 -0
- package/src/internal/regex-package-path.ts +18 -0
- package/src/internal/resolver.ts +783 -0
- package/src/internal/validate-boolean.ts +27 -0
- package/src/internal/validate-object.ts +30 -0
- package/src/internal/validate-set.ts +33 -0
- package/src/internal/validate-string.ts +27 -0
- package/src/internal/validate-url-string.ts +31 -0
- package/src/types/declaration.ts +22 -0
- package/src/types/fn-change-ext.ts +33 -0
- package/src/types/index.ts +14 -0
- package/src/types/mime-type.ts +19 -0
- package/src/types/module-id.ts +15 -0
- package/src/types/module-specifier-type.ts +13 -0
- package/src/types/protocol.ts +40 -0
- package/src/types/syntax-kind-export.ts +20 -0
- package/src/types/syntax-kind-import.ts +22 -0
- package/src/types/syntax-kind-require.ts +15 -0
- package/src/utils/compare-subpaths.ts +100 -0
- package/src/utils/conditions.ts +15 -0
- package/src/utils/detect-syntax.ts +40 -0
- package/src/utils/extension-format-map.ts +34 -0
- package/src/utils/extract-statements.ts +42 -0
- package/src/utils/fill-modules.ts +121 -0
- package/src/utils/find-dynamic-imports.ts +75 -0
- package/src/utils/find-exports.ts +164 -0
- package/src/utils/find-requires.ts +75 -0
- package/src/utils/find-static-imports.ts +89 -0
- package/src/utils/find-subpath.ts +241 -0
- package/src/utils/get-format.ts +222 -0
- package/src/utils/get-source.ts +129 -0
- package/src/utils/has-cjs-syntax.ts +44 -0
- package/src/utils/has-esm-syntax.ts +40 -0
- package/src/utils/index.ts +43 -0
- package/src/utils/is-absolute-specifier.ts +48 -0
- package/src/utils/is-bare-specifier.ts +30 -0
- package/src/utils/is-exports-sugar.ts +74 -0
- package/src/utils/is-relative-specifier.ts +34 -0
- package/src/utils/lookup-package-scope.ts +97 -0
- package/src/utils/parse-data-url.ts +71 -0
- package/src/utils/parse-module-id.ts +186 -0
- package/src/utils/parse-subpath.ts +173 -0
- package/src/utils/pattern-character.ts +13 -0
- package/src/utils/read-package-json.ts +101 -0
- package/src/utils/resolve-alias.ts +219 -0
- package/src/utils/resolve-aliases.ts +58 -0
- package/src/utils/resolve-extensions.ts +33 -0
- package/src/utils/resolve-module.ts +153 -0
- package/src/utils/resolve-modules.ts +62 -0
- package/src/utils/to-absolute-specifier.ts +30 -0
- package/src/utils/to-bare-specifier.ts +201 -0
- package/src/utils/to-data-url.ts +42 -0
- package/src/utils/to-node-url.ts +27 -0
- package/src/utils/to-relative-specifier.ts +47 -0
- package/src/utils/to-url.ts +31 -0
- package/src/utils/validate-assertions.ts +119 -0
- package/src/utils/validate-exports.ts +124 -0
- package/changelog.config.cts +0 -204
- package/dist/constants.d.mts +0 -19
- package/dist/constants.mjs +0 -24
- package/dist/interfaces/import-dynamic.mjs +0 -0
- package/dist/interfaces/import-static.mjs +0 -0
- package/dist/interfaces/options-resolve-alias.mjs +0 -0
- package/dist/interfaces/options-resolve.mjs +0 -0
- package/dist/interfaces/statement-export.mjs +0 -0
- package/dist/interfaces/statement-import.mjs +0 -0
- package/dist/interfaces/statement-require.mjs +0 -0
- package/dist/interfaces/statement.mjs +0 -0
- package/dist/internal/compiler-options-json.d.mts +0 -111
- package/dist/internal/compiler-options-json.mjs +0 -0
- package/dist/internal/constants.d.mts +0 -70
- package/dist/internal/constants.mjs +0 -18
- package/dist/internal/get-compiler-options.d.mts +0 -21
- package/dist/internal/get-compiler-options.mjs +0 -14
- package/dist/internal/index.d.mts +0 -7
- package/dist/internal/index.mjs +0 -5
- package/dist/lib/extract-statements.d.mts +0 -21
- package/dist/lib/find-dynamic-imports.d.mts +0 -15
- package/dist/lib/find-dynamic-imports.mjs +0 -20
- package/dist/lib/find-exports.d.mts +0 -15
- package/dist/lib/find-exports.mjs +0 -53
- package/dist/lib/find-requires.d.mts +0 -17
- package/dist/lib/find-requires.mjs +0 -19
- package/dist/lib/find-static-imports.d.mts +0 -15
- package/dist/lib/find-static-imports.mjs +0 -20
- package/dist/lib/has-cjs-syntax.mjs +0 -6
- package/dist/lib/has-esm-syntax.mjs +0 -6
- package/dist/lib/index.d.mts +0 -20
- package/dist/lib/index.mjs +0 -34
- package/dist/lib/resolve-alias.d.mts +0 -20
- package/dist/lib/resolve-alias.mjs +0 -41
- package/dist/lib/resolve-aliases.d.mts +0 -17
- package/dist/lib/resolve-aliases.mjs +0 -34
- package/dist/lib/resolve-module.d.mts +0 -31
- package/dist/lib/resolve-module.mjs +0 -74
- package/dist/lib/resolve-modules.d.mts +0 -19
- package/dist/lib/to-absolute-specifier.mjs +0 -20
- package/dist/lib/to-bare-specifier.d.mts +0 -28
- package/dist/lib/to-bare-specifier.mjs +0 -78
- package/dist/types/declaration.mjs +0 -0
- package/dist/types/ext.d.mts +0 -9
- package/dist/types/ext.mjs +0 -0
- package/dist/types/mime-type.mjs +0 -0
- package/dist/types/specifier-type.d.mts +0 -11
- package/dist/types/specifier-type.mjs +0 -0
- package/dist/types/statement-type.d.mts +0 -9
- package/dist/types/statement-type.mjs +0 -0
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Internals - Constants
|
|
3
|
-
* @module mlly/internal/constants
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* CommonJS syntax regex.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
|
-
*
|
|
10
|
-
* @const {RegExp} CJS_SYNTAX_REGEX
|
|
11
|
-
*/
|
|
12
|
-
export declare const CJS_SYNTAX_REGEX: RegExp;
|
|
13
|
-
/**
|
|
14
|
-
* Dynamic import statement regex.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*
|
|
18
|
-
* @const {RegExp} DYNAMIC_IMPORT_REGEX
|
|
19
|
-
*/
|
|
20
|
-
export declare const DYNAMIC_IMPORT_REGEX: RegExp;
|
|
21
|
-
/**
|
|
22
|
-
* ESM syntax regex.
|
|
23
|
-
*
|
|
24
|
-
* @internal
|
|
25
|
-
*
|
|
26
|
-
* @const {RegExp} ESM_SYNTAX_REGEX
|
|
27
|
-
*/
|
|
28
|
-
export declare const ESM_SYNTAX_REGEX: RegExp;
|
|
29
|
-
/**
|
|
30
|
-
* Declaration export statement regex.
|
|
31
|
-
*
|
|
32
|
-
* **Note**: Captures [declaration type][1] and export name only.
|
|
33
|
-
*
|
|
34
|
-
* [1]: ./types/declaration.ts
|
|
35
|
-
*
|
|
36
|
-
* @const {RegExp} EXPORT_DECLARATION_REGEX
|
|
37
|
-
*/
|
|
38
|
-
export declare const EXPORT_DECLARATION_REGEX: RegExp;
|
|
39
|
-
/**
|
|
40
|
-
* Named export statement regex.
|
|
41
|
-
*
|
|
42
|
-
* @internal
|
|
43
|
-
*
|
|
44
|
-
* @const {RegExp} EXPORT_NAMED_REGEX
|
|
45
|
-
*/
|
|
46
|
-
export declare const EXPORT_NAMED_REGEX: RegExp;
|
|
47
|
-
/**
|
|
48
|
-
* Aggregate export statement (`export * ...`) regex.
|
|
49
|
-
*
|
|
50
|
-
* @internal
|
|
51
|
-
*
|
|
52
|
-
* @const {RegExp} EXPORT_STAR_REGEX
|
|
53
|
-
*/
|
|
54
|
-
export declare const EXPORT_STAR_REGEX: RegExp;
|
|
55
|
-
/**
|
|
56
|
-
* Require statement regex.
|
|
57
|
-
*
|
|
58
|
-
* @internal
|
|
59
|
-
*
|
|
60
|
-
* @const {RegExp} REQUIRE_STATEMENT_REGEX
|
|
61
|
-
*/
|
|
62
|
-
export declare const REQUIRE_STATEMENT_REGEX: RegExp;
|
|
63
|
-
/**
|
|
64
|
-
* Static import statement regex.
|
|
65
|
-
*
|
|
66
|
-
* @internal
|
|
67
|
-
*
|
|
68
|
-
* @const {RegExp} STATIC_IMPORT_REGEX
|
|
69
|
-
*/
|
|
70
|
-
export declare const STATIC_IMPORT_REGEX: RegExp;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const CJS_SYNTAX_REGEX = /(?<!(?:\/\/|\*).*)((?:module\.)?exports(?:\.\w+|(?<!\s+=))|require(?=\(.)|require\.\w+|__dirname|__filename|await import)/gm;
|
|
2
|
-
const DYNAMIC_IMPORT_REGEX = /(?<!(?:\/\/|\*).*)(?:(?:const|let|var)(?:(?<name>\s+\w+\s*)|\s*{\s*(?<names>\w+(?:,\s*\w+)*)\s*}\s*)(?:\s*=\s*?)?.)?(?:await)?\s+import\s*\((?<expression>(?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*)\)/gm;
|
|
3
|
-
const ESM_SYNTAX_REGEX = /(?<!(?:\/\/|\*).*)((?:export|import)[\s\w*,{}]*(?=\sfrom)|export\b\s*(?:[*{]|async function|(?:abstract\s)?class|const|default|enum|function|interface|let|type|var)|await import|import\.meta\.(?:env(?:\.\w+)?|resolve|url))/gm;
|
|
4
|
-
const EXPORT_DECLARATION_REGEX = /(?<!(?:\/\/|\*).*)\bexport(?: +declare)? +(?<declaration>(?:(?:abstract +)?class|(?:default +)?async +function\*?|(?:default +)?function\*?|default +async|default(?!(?: +async)? +function\*?)|(?:const +)?enum|const|interface|let|namespace|type(?! *{)|var)) +(?<name>[\w$]+(?!.*\b +=>))?/gm;
|
|
5
|
-
const EXPORT_NAMED_REGEX = /(?<!(?:\/\/|\*).*)\bexport(?:\s+type)?\s+{(?<exports>[^}]+?)[\s,]*}(?:\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/gm;
|
|
6
|
-
const EXPORT_STAR_REGEX = /(?<!(?:\/\/|\*).*)\bexport\s*\*(?:\s*as\s+(?<name>[\w$]+)\s+)?\s*(?:\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/gm;
|
|
7
|
-
const REQUIRE_STATEMENT_REGEX = /(?<!(?:\/\/|\*).*)(?:\bconst[ {]+(?<imports>[\w\t\n\r $*,/]+)[ =}]+)?(?<type>\brequire(?:\.resolve)?)\(["'] *(?<specifier>(?<="\s*)[^"']*[^\s"'](?=\s*")|(?<=["']\s*)[^']*[^\s'](?=\s*')) *["']\)/gm;
|
|
8
|
-
const STATIC_IMPORT_REGEX = /(?<!(?:\/\/|\*).*)(?<=\s|^|;)import\s*([\s"']*(?<imports>[\w\t\n\r $*,/{}]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gm;
|
|
9
|
-
export {
|
|
10
|
-
CJS_SYNTAX_REGEX,
|
|
11
|
-
DYNAMIC_IMPORT_REGEX,
|
|
12
|
-
ESM_SYNTAX_REGEX,
|
|
13
|
-
EXPORT_DECLARATION_REGEX,
|
|
14
|
-
EXPORT_NAMED_REGEX,
|
|
15
|
-
EXPORT_STAR_REGEX,
|
|
16
|
-
REQUIRE_STATEMENT_REGEX,
|
|
17
|
-
STATIC_IMPORT_REGEX
|
|
18
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Internals - getCompilerOptions
|
|
3
|
-
* @module mlly/internal/getCompilerOptions
|
|
4
|
-
*/
|
|
5
|
-
import type CompilerOptionsJson from './compiler-options-json.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves TypeScript compiler options from `path`.
|
|
8
|
-
*
|
|
9
|
-
* Supports [`extends`][1].
|
|
10
|
-
*
|
|
11
|
-
* [1]: https://typescriptlang.org/tsconfig#extends
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*
|
|
15
|
-
* @param {string} [path=upath.resolve('tsconfig.json')] - Tsconfig path
|
|
16
|
-
* @param {(path: string) => boolean} [exists] - File existence checker
|
|
17
|
-
* @param {(filename: string) => string} [read] - File content reader
|
|
18
|
-
* @return {CompilerOptionsJson} User compiler options
|
|
19
|
-
*/
|
|
20
|
-
declare const getCompilerOptions: (path?: string, exists?: ((path: string) => boolean) | undefined, read?: ((filename: string) => string) | undefined) => CompilerOptionsJson;
|
|
21
|
-
export default getCompilerOptions;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { loadTsconfig } from "tsconfig-paths/lib/tsconfig-loader.js";
|
|
2
|
-
import upath from "upath";
|
|
3
|
-
const getCompilerOptions = (path = upath.resolve("tsconfig.json"), exists, read) => {
|
|
4
|
-
const t = loadTsconfig(
|
|
5
|
-
path,
|
|
6
|
-
exists,
|
|
7
|
-
read
|
|
8
|
-
);
|
|
9
|
-
return !(t == null ? void 0 : t.compilerOptions) ? {} : t.compilerOptions;
|
|
10
|
-
};
|
|
11
|
-
var get_compiler_options_default = getCompilerOptions;
|
|
12
|
-
export {
|
|
13
|
-
get_compiler_options_default as default
|
|
14
|
-
};
|
package/dist/internal/index.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file extractStatements
|
|
3
|
-
* @module mlly/lib/extractStatements
|
|
4
|
-
*/
|
|
5
|
-
import type { Statement } from '../interfaces/index.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Finds all `export`, `import`, `require`, and/or `require.resolve` statements
|
|
8
|
-
* in `code`.
|
|
9
|
-
*
|
|
10
|
-
* Ignores matches in comments.
|
|
11
|
-
*
|
|
12
|
-
* @see {@link findDynamicImports}
|
|
13
|
-
* @see {@link findExports}
|
|
14
|
-
* @see {@link findRequires}
|
|
15
|
-
* @see {@link findStaticImports}
|
|
16
|
-
*
|
|
17
|
-
* @param {string} [code=''] - Code to extract statements from
|
|
18
|
-
* @return {Statement[]} Extracted statements
|
|
19
|
-
*/
|
|
20
|
-
declare const extractStatements: (code?: string) => Statement[];
|
|
21
|
-
export default extractStatements;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file findDynamicImports
|
|
3
|
-
* @module mlly/lib/findDynamicImports
|
|
4
|
-
*/
|
|
5
|
-
import type { DynamicImport } from '../interfaces/index.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Finds all dynamic import statements in `code`. Ignores matches in comments.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link DynamicImport}
|
|
10
|
-
*
|
|
11
|
-
* @param {string} code - Code to check
|
|
12
|
-
* @return {DynamicImport[]} Dynamic import statement objects
|
|
13
|
-
*/
|
|
14
|
-
declare const findDynamicImports: (code: string) => DynamicImport[];
|
|
15
|
-
export default findDynamicImports;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { DYNAMIC_IMPORT_REGEX } from "../internal/index.mjs";
|
|
2
|
-
const findDynamicImports = (code) => {
|
|
3
|
-
return [...code.matchAll(DYNAMIC_IMPORT_REGEX)].map((match) => {
|
|
4
|
-
const { 0: statement = "", index: start = 0, groups = {} } = match;
|
|
5
|
-
const { expression = "", name = "", names = "" } = groups;
|
|
6
|
-
return {
|
|
7
|
-
code: statement,
|
|
8
|
-
end: start + statement.length,
|
|
9
|
-
imports: name.trim() ? [name.trim()] : names.trim() ? names.split(",").map((name2) => name2.trim()) : [],
|
|
10
|
-
specifier: expression.replace(/["']/g, ""),
|
|
11
|
-
specifier_type: /^["']/g.test(expression) ? "static" : "dynamic",
|
|
12
|
-
start,
|
|
13
|
-
type: "dynamic"
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var find_dynamic_imports_default = findDynamicImports;
|
|
18
|
-
export {
|
|
19
|
-
find_dynamic_imports_default as default
|
|
20
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file findExports
|
|
3
|
-
* @module mlly/lib/findExports
|
|
4
|
-
*/
|
|
5
|
-
import type { ExportStatement } from '../interfaces/index.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Finds all export statements in `code`. Ignores matches in comments.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link ExportStatement}
|
|
10
|
-
*
|
|
11
|
-
* @param {string} code - Code to check
|
|
12
|
-
* @return {ExportStatement[]} Export statement objects
|
|
13
|
-
*/
|
|
14
|
-
declare const findExports: (code: string) => ExportStatement[];
|
|
15
|
-
export default findExports;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EXPORT_DECLARATION_REGEX,
|
|
3
|
-
EXPORT_NAMED_REGEX,
|
|
4
|
-
EXPORT_STAR_REGEX
|
|
5
|
-
} from "../internal/index.mjs";
|
|
6
|
-
const findExports = (code) => {
|
|
7
|
-
const statements = [];
|
|
8
|
-
for (const match of code.matchAll(EXPORT_DECLARATION_REGEX)) {
|
|
9
|
-
const { 0: statement = "", index: start = 0, groups = {} } = match;
|
|
10
|
-
const { declaration = "default", name = "" } = groups;
|
|
11
|
-
const stmt = statement.trim();
|
|
12
|
-
statements.push({
|
|
13
|
-
code: stmt,
|
|
14
|
-
declaration,
|
|
15
|
-
end: start + stmt.length,
|
|
16
|
-
exports: [name === "" ? "default" : name.trim()],
|
|
17
|
-
specifier: void 0,
|
|
18
|
-
start,
|
|
19
|
-
type: declaration === "default" ? "default" : "declaration"
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
for (const match of code.matchAll(EXPORT_NAMED_REGEX)) {
|
|
23
|
-
const { 0: statement = "", index: start = 0, groups = {} } = match;
|
|
24
|
-
const { exports: exp = "", specifier = "" } = groups;
|
|
25
|
-
statements.push({
|
|
26
|
-
code: statement,
|
|
27
|
-
declaration: void 0,
|
|
28
|
-
end: start + statement.length,
|
|
29
|
-
exports: exp.split(",").map((name) => name.trim()),
|
|
30
|
-
specifier,
|
|
31
|
-
start,
|
|
32
|
-
type: exp.trim() === "default" ? "default" : "named"
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
for (const match of code.matchAll(EXPORT_STAR_REGEX)) {
|
|
36
|
-
const { 0: statement = "", index: start = 0, groups = {} } = match;
|
|
37
|
-
const { name = "*", specifier = "" } = groups;
|
|
38
|
-
statements.push({
|
|
39
|
-
code: statement,
|
|
40
|
-
declaration: void 0,
|
|
41
|
-
end: start + statement.length,
|
|
42
|
-
exports: [name === "*" ? name : name.replace(/(\w+)/, "* as $1").trim()],
|
|
43
|
-
specifier,
|
|
44
|
-
start,
|
|
45
|
-
type: "star"
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return statements;
|
|
49
|
-
};
|
|
50
|
-
var find_exports_default = findExports;
|
|
51
|
-
export {
|
|
52
|
-
find_exports_default as default
|
|
53
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file findRequires
|
|
3
|
-
* @module mlly/lib/findRequires
|
|
4
|
-
*/
|
|
5
|
-
import type { RequireStatement } from '../interfaces/index.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Finds all `require` and `require.resolve` statements in `code`.
|
|
8
|
-
*
|
|
9
|
-
* Ignores matches in comments.
|
|
10
|
-
*
|
|
11
|
-
* @see {@link RequireStatement}
|
|
12
|
-
*
|
|
13
|
-
* @param {string} code - Code to check
|
|
14
|
-
* @return {RequireStatement[]} Require statement objects
|
|
15
|
-
*/
|
|
16
|
-
declare const findRequires: (code: string) => RequireStatement[];
|
|
17
|
-
export default findRequires;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { REQUIRE_STATEMENT_REGEX } from "../internal/index.mjs";
|
|
2
|
-
const findRequires = (code) => {
|
|
3
|
-
return [...code.matchAll(REQUIRE_STATEMENT_REGEX)].map((match) => {
|
|
4
|
-
const { 0: statement = "", index: start = 0, groups = {} } = match;
|
|
5
|
-
const { imports = "", specifier = "", type = "" } = groups;
|
|
6
|
-
return {
|
|
7
|
-
code: statement,
|
|
8
|
-
end: start + statement.length,
|
|
9
|
-
imports: imports === "" || type === "require.resolve" ? [] : /const *\w/.test(statement) ? ["default"] : imports.split(",").map((name) => name.trim()),
|
|
10
|
-
specifier,
|
|
11
|
-
start,
|
|
12
|
-
type
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var find_requires_default = findRequires;
|
|
17
|
-
export {
|
|
18
|
-
find_requires_default as default
|
|
19
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file findStaticImports
|
|
3
|
-
* @module mlly/lib/findStaticImports
|
|
4
|
-
*/
|
|
5
|
-
import type { StaticImport } from '../interfaces/index.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Finds all static import statements in `code`. Ignores matches in comments.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link StaticImport}
|
|
10
|
-
*
|
|
11
|
-
* @param {string} code - Code to check
|
|
12
|
-
* @return {StaticImport[]} Static import statement objects
|
|
13
|
-
*/
|
|
14
|
-
declare const findStaticImports: (code: string) => StaticImport[];
|
|
15
|
-
export default findStaticImports;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { STATIC_IMPORT_REGEX } from "../internal/index.mjs";
|
|
2
|
-
const findStaticImports = (code) => {
|
|
3
|
-
return [...code.matchAll(STATIC_IMPORT_REGEX)].map((match) => {
|
|
4
|
-
const { 0: statement = "", index: start = 0, groups = {} } = match;
|
|
5
|
-
const { imports = "", specifier = "" } = groups;
|
|
6
|
-
const star = imports.startsWith("* as");
|
|
7
|
-
return {
|
|
8
|
-
code: statement,
|
|
9
|
-
end: start + statement.length,
|
|
10
|
-
imports: star ? [imports.trim()] : imports.replace(/^type\s*|[{}]/gm, "").split(/,\n?/).map((name) => name.trim()),
|
|
11
|
-
specifier,
|
|
12
|
-
start,
|
|
13
|
-
type: star ? "star" : /{(?<imports>[\w\t\n\r ,]+)}/gm.test(statement) ? "named" : "default"
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
var find_static_imports_default = findStaticImports;
|
|
18
|
-
export {
|
|
19
|
-
find_static_imports_default as default
|
|
20
|
-
};
|
package/dist/lib/index.d.mts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Library
|
|
3
|
-
* @module mlly/lib
|
|
4
|
-
*/
|
|
5
|
-
export { default as detectSyntax } from './detect-syntax.mjs';
|
|
6
|
-
export { default as extractStatements } from './extract-statements.mjs';
|
|
7
|
-
export { default as findDynamicImports } from './find-dynamic-imports.mjs';
|
|
8
|
-
export { default as findExports } from './find-exports.mjs';
|
|
9
|
-
export { default as findRequires } from './find-requires.mjs';
|
|
10
|
-
export { default as findStaticImports } from './find-static-imports.mjs';
|
|
11
|
-
export { default as hasCJSSyntax } from './has-cjs-syntax.mjs';
|
|
12
|
-
export { default as hasESMSyntax } from './has-esm-syntax.mjs';
|
|
13
|
-
export { default as resolveAlias } from './resolve-alias.mjs';
|
|
14
|
-
export { default as resolveAliases } from './resolve-aliases.mjs';
|
|
15
|
-
export { default as resolveModule } from './resolve-module.mjs';
|
|
16
|
-
export { default as resolveModules } from './resolve-modules.mjs';
|
|
17
|
-
export { default as toAbsoluteSpecifier } from './to-absolute-specifier.mjs';
|
|
18
|
-
export { default as toBareSpecifier } from './to-bare-specifier.mjs';
|
|
19
|
-
export { default as toDataURL } from './to-data-url.mjs';
|
|
20
|
-
export { default as toRelativeSpecifier } from './to-relative-specifier.mjs';
|
package/dist/lib/index.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { default as default2 } from "./detect-syntax.mjs";
|
|
2
|
-
import { default as default3 } from "./extract-statements.mjs";
|
|
3
|
-
import { default as default4 } from "./find-dynamic-imports.mjs";
|
|
4
|
-
import { default as default5 } from "./find-exports.mjs";
|
|
5
|
-
import { default as default6 } from "./find-requires.mjs";
|
|
6
|
-
import { default as default7 } from "./find-static-imports.mjs";
|
|
7
|
-
import { default as default8 } from "./has-cjs-syntax.mjs";
|
|
8
|
-
import { default as default9 } from "./has-esm-syntax.mjs";
|
|
9
|
-
import { default as default10 } from "./resolve-alias.mjs";
|
|
10
|
-
import { default as default11 } from "./resolve-aliases.mjs";
|
|
11
|
-
import { default as default12 } from "./resolve-module.mjs";
|
|
12
|
-
import { default as default13 } from "./resolve-modules.mjs";
|
|
13
|
-
import { default as default14 } from "./to-absolute-specifier.mjs";
|
|
14
|
-
import { default as default15 } from "./to-bare-specifier.mjs";
|
|
15
|
-
import { default as default16 } from "./to-data-url.mjs";
|
|
16
|
-
import { default as default17 } from "./to-relative-specifier.mjs";
|
|
17
|
-
export {
|
|
18
|
-
default2 as detectSyntax,
|
|
19
|
-
default3 as extractStatements,
|
|
20
|
-
default4 as findDynamicImports,
|
|
21
|
-
default5 as findExports,
|
|
22
|
-
default6 as findRequires,
|
|
23
|
-
default7 as findStaticImports,
|
|
24
|
-
default8 as hasCJSSyntax,
|
|
25
|
-
default9 as hasESMSyntax,
|
|
26
|
-
default10 as resolveAlias,
|
|
27
|
-
default11 as resolveAliases,
|
|
28
|
-
default12 as resolveModule,
|
|
29
|
-
default13 as resolveModules,
|
|
30
|
-
default14 as toAbsoluteSpecifier,
|
|
31
|
-
default15 as toBareSpecifier,
|
|
32
|
-
default16 as toDataURL,
|
|
33
|
-
default17 as toRelativeSpecifier
|
|
34
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file resolveAlias
|
|
3
|
-
* @module mlly/lib/resolveAlias
|
|
4
|
-
*/
|
|
5
|
-
import type { ResolveAliasOptions } from '../interfaces/index.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Resolves a path alias in `specifier`; does nothing if a path match isn't
|
|
8
|
-
* found.
|
|
9
|
-
*
|
|
10
|
-
* If `options.tsconfig` is found, `options.baseUrl` and `options.paths` will
|
|
11
|
-
* be overridden with values from the config file.
|
|
12
|
-
*
|
|
13
|
-
* @see {@link ResolveAliasOptions}
|
|
14
|
-
*
|
|
15
|
-
* @param {string} specifier - Module specifier
|
|
16
|
-
* @param {ResolveAliasOptions} [options={}] - Resolve alias options
|
|
17
|
-
* @return {string} `specifier` unmodified or with path alias resolved
|
|
18
|
-
*/
|
|
19
|
-
declare const resolveAlias: (specifier: string, options?: ResolveAliasOptions) => string;
|
|
20
|
-
export default resolveAlias;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { RESOLVE_EXTENSIONS } from "../constants.mjs";
|
|
2
|
-
import { getCompilerOptions } from "../internal/index.mjs";
|
|
3
|
-
import { createMatchPath } from "tsconfig-paths";
|
|
4
|
-
import upath from "upath";
|
|
5
|
-
import toRelativeSpecifier from "./to-relative-specifier.mjs";
|
|
6
|
-
const resolveAlias = (specifier, options = {}) => {
|
|
7
|
-
const {
|
|
8
|
-
extensions = RESOLVE_EXTENSIONS,
|
|
9
|
-
fileExists,
|
|
10
|
-
mainFields = ["main", "module"],
|
|
11
|
-
parent,
|
|
12
|
-
readFile,
|
|
13
|
-
tsconfig
|
|
14
|
-
} = options;
|
|
15
|
-
let { baseUrl = process.cwd(), paths = {} } = options;
|
|
16
|
-
if (tsconfig) {
|
|
17
|
-
const { baseUrl: b = ".", paths: p = paths } = getCompilerOptions(tsconfig);
|
|
18
|
-
baseUrl = upath.resolve(upath.dirname(tsconfig), b);
|
|
19
|
-
paths = p;
|
|
20
|
-
}
|
|
21
|
-
const matcher = createMatchPath(
|
|
22
|
-
baseUrl,
|
|
23
|
-
paths,
|
|
24
|
-
mainFields,
|
|
25
|
-
baseUrl.length > 0
|
|
26
|
-
);
|
|
27
|
-
let match = matcher(
|
|
28
|
-
specifier,
|
|
29
|
-
readFile,
|
|
30
|
-
fileExists,
|
|
31
|
-
extensions
|
|
32
|
-
);
|
|
33
|
-
if (!match)
|
|
34
|
-
return specifier;
|
|
35
|
-
match = /\/node_modules\//.test(match) ? match.replace(/.+\/node_modules\//, "") : parent ? toRelativeSpecifier(match, parent) : match;
|
|
36
|
-
return match;
|
|
37
|
-
};
|
|
38
|
-
var resolve_alias_default = resolveAlias;
|
|
39
|
-
export {
|
|
40
|
-
resolve_alias_default as default
|
|
41
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file resolveAliases
|
|
3
|
-
* @module mlly/lib/resolveAliases
|
|
4
|
-
*/
|
|
5
|
-
import type { ResolveAliasOptions } from '../interfaces/index.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Resolves path aliases in `code`.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link ResolveAliasOptions}
|
|
10
|
-
* @see {@link resolveAlias}
|
|
11
|
-
*
|
|
12
|
-
* @param {string} code - Code containing path aliases
|
|
13
|
-
* @param {ResolveAliasOptions} [options={}] - Resolve alias options
|
|
14
|
-
* @return {string} `code` unmodified or with path aliases resolved
|
|
15
|
-
*/
|
|
16
|
-
declare const resolveAliases: (code: string, options?: ResolveAliasOptions) => string;
|
|
17
|
-
export default resolveAliases;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { getCompilerOptions } from "../internal/index.mjs";
|
|
2
|
-
import upath from "upath";
|
|
3
|
-
import extractStatements from "./extract-statements.mjs";
|
|
4
|
-
import resolveAlias from "./resolve-alias.mjs";
|
|
5
|
-
const resolveAliases = (code, options = {}) => {
|
|
6
|
-
const { tsconfig } = options;
|
|
7
|
-
let { baseUrl = process.cwd(), paths = {} } = options;
|
|
8
|
-
if (tsconfig) {
|
|
9
|
-
const { baseUrl: b = ".", paths: p = paths } = getCompilerOptions(tsconfig);
|
|
10
|
-
baseUrl = upath.resolve(upath.dirname(tsconfig), b);
|
|
11
|
-
paths = p;
|
|
12
|
-
}
|
|
13
|
-
for (const statement of extractStatements(code)) {
|
|
14
|
-
if (!statement.specifier)
|
|
15
|
-
continue;
|
|
16
|
-
const specifier = resolveAlias(statement.specifier, {
|
|
17
|
-
...options,
|
|
18
|
-
baseUrl,
|
|
19
|
-
paths,
|
|
20
|
-
tsconfig: void 0
|
|
21
|
-
});
|
|
22
|
-
if (specifier === statement.specifier)
|
|
23
|
-
continue;
|
|
24
|
-
code = code.replace(
|
|
25
|
-
statement.code,
|
|
26
|
-
statement.code.replace(statement.specifier, specifier)
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
return code;
|
|
30
|
-
};
|
|
31
|
-
var resolve_aliases_default = resolveAliases;
|
|
32
|
-
export {
|
|
33
|
-
resolve_aliases_default as default
|
|
34
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file resolveModule
|
|
3
|
-
* @module mlly/lib/resolveModule
|
|
4
|
-
*/
|
|
5
|
-
import type { ResolveOptions } from '../interfaces/index.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Resolves `specifier` according to the [ESM Resolver algorithm][1], mostly 😉.
|
|
8
|
-
*
|
|
9
|
-
* Adds support for:
|
|
10
|
-
*
|
|
11
|
-
* - Resolving without file extensions and explicit `/index` usage
|
|
12
|
-
* - Resolving `@types/*` with **and** without explicit `@types/*` usage
|
|
13
|
-
* - Converting resolved modules into [bare][2] and [relative][3] specifiers
|
|
14
|
-
* - Removing and replacing file extensions
|
|
15
|
-
*
|
|
16
|
-
* [1]: https://nodejs.org/api/esm.html#esm_resolver_algorithm
|
|
17
|
-
* [2]: {@link toBareSpecifier}
|
|
18
|
-
* [3]: {@link toRelativeSpecifier}
|
|
19
|
-
*
|
|
20
|
-
* @see {@link ResolveOptions}
|
|
21
|
-
* @see {@link ErrnoException}
|
|
22
|
-
*
|
|
23
|
-
* @async
|
|
24
|
-
*
|
|
25
|
-
* @param {string} specifier - Module specifier to resolve
|
|
26
|
-
* @param {ResolveOptions} [options={}] - Resolve options
|
|
27
|
-
* @return {Promise<string>} Resolved module
|
|
28
|
-
* @throws {ErrnoException}
|
|
29
|
-
*/
|
|
30
|
-
declare const resolveModule: (specifier: string, options?: ResolveOptions) => Promise<string>;
|
|
31
|
-
export default resolveModule;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { CONDITIONS, RESOLVE_EXTENSIONS } from "../constants.mjs";
|
|
2
|
-
import isBuiltin from "@flex-development/is-builtin";
|
|
3
|
-
import { moduleResolve } from "import-meta-resolve";
|
|
4
|
-
import { pathToFileURL, URL } from "node:url";
|
|
5
|
-
import upath from "upath";
|
|
6
|
-
import toBareSpecifier from "./to-bare-specifier.mjs";
|
|
7
|
-
import toRelativeSpecifier from "./to-relative-specifier.mjs";
|
|
8
|
-
const resolveModule = async (specifier, options = {}) => {
|
|
9
|
-
const {
|
|
10
|
-
conditions = CONDITIONS,
|
|
11
|
-
ext,
|
|
12
|
-
extensions = RESOLVE_EXTENSIONS,
|
|
13
|
-
parent = import.meta.url,
|
|
14
|
-
preserveSymlinks = false,
|
|
15
|
-
...opts
|
|
16
|
-
} = options;
|
|
17
|
-
const base = typeof parent === "string" ? parent.startsWith("file:") ? new URL(parent) : pathToFileURL(parent) : parent;
|
|
18
|
-
const tries = isBuiltin(specifier) || /^(?:data|https?):/.test(specifier) ? [] : extensions.flatMap((ext2) => {
|
|
19
|
-
return [specifier + ext2, specifier + "/index" + ext2].flatMap(($try) => {
|
|
20
|
-
return [$try, "@types/" + $try];
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
tries.unshift(specifier);
|
|
24
|
-
const ignore = /* @__PURE__ */ new Set([
|
|
25
|
-
"ERR_MODULE_NOT_FOUND",
|
|
26
|
-
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
27
|
-
"ERR_UNSUPPORTED_DIR_IMPORT"
|
|
28
|
-
]);
|
|
29
|
-
let error;
|
|
30
|
-
let resolved;
|
|
31
|
-
for (const id of tries) {
|
|
32
|
-
try {
|
|
33
|
-
resolved = moduleResolve(
|
|
34
|
-
id,
|
|
35
|
-
base,
|
|
36
|
-
new Set(conditions),
|
|
37
|
-
preserveSymlinks
|
|
38
|
-
).href;
|
|
39
|
-
} catch (e) {
|
|
40
|
-
if (id === specifier)
|
|
41
|
-
error = e;
|
|
42
|
-
if (ignore.has(e.code))
|
|
43
|
-
continue;
|
|
44
|
-
throw e;
|
|
45
|
-
}
|
|
46
|
-
if (resolved)
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
if (!resolved)
|
|
50
|
-
throw error;
|
|
51
|
-
if (isBuiltin(resolved) || /^(?:data|https?):/.test(resolved))
|
|
52
|
-
return resolved;
|
|
53
|
-
const type = typeof opts.type === "function" ? await opts.type(resolved) : opts.type ?? "absolute";
|
|
54
|
-
if (type === "bare")
|
|
55
|
-
resolved = await toBareSpecifier(resolved, conditions);
|
|
56
|
-
if (type === "relative")
|
|
57
|
-
resolved = toRelativeSpecifier(resolved, parent);
|
|
58
|
-
if (ext !== void 0) {
|
|
59
|
-
if (ext === false) {
|
|
60
|
-
resolved = upath.removeExt(resolved, upath.extname(resolved));
|
|
61
|
-
} else if (type === "relative") {
|
|
62
|
-
resolved = upath.changeExt(
|
|
63
|
-
resolved,
|
|
64
|
-
typeof ext === "function" ? await ext(specifier, resolved) : ext
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
resolved = resolved.replace(/\/index$/, "");
|
|
68
|
-
}
|
|
69
|
-
return resolved;
|
|
70
|
-
};
|
|
71
|
-
var resolve_module_default = resolveModule;
|
|
72
|
-
export {
|
|
73
|
-
resolve_module_default as default
|
|
74
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file resolveModules
|
|
3
|
-
* @module mlly/lib/resolveModules
|
|
4
|
-
*/
|
|
5
|
-
import type { ResolveOptions } from '../interfaces/index.mjs';
|
|
6
|
-
/**
|
|
7
|
-
* Resolves all modules in `code`.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link ResolveOptions}
|
|
10
|
-
* @see {@link resolveModule}
|
|
11
|
-
*
|
|
12
|
-
* @async
|
|
13
|
-
*
|
|
14
|
-
* @param {string} code - Code containing module specifiers
|
|
15
|
-
* @param {ResolveOptions} [options={}] - Resolve options
|
|
16
|
-
* @return {Promise<string>} `code` with modules resolved
|
|
17
|
-
*/
|
|
18
|
-
declare const resolveModules: (code: string, options?: ResolveOptions) => Promise<string>;
|
|
19
|
-
export default resolveModules;
|