@flex-development/mlly 1.0.0-alpha.16 → 1.0.0-alpha.17
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 +14 -0
- package/dist/index.mjs.map +4 -5
- package/dist/internal/dequote.mjs +1 -0
- package/dist/internal/dequote.mjs.map +8 -0
- package/dist/internal/format-type-map.mjs +1 -0
- package/dist/internal/format-type-map.mjs.map +8 -0
- package/dist/internal/get-specifier-kind.mjs +1 -0
- package/dist/internal/get-specifier-kind.mjs.map +8 -0
- package/dist/internal/get-subpaths.mjs +1 -0
- package/dist/internal/get-subpaths.mjs.map +8 -0
- package/dist/internal/regex-encoded-sep.mjs +1 -0
- package/dist/internal/regex-encoded-sep.mjs.map +8 -0
- package/dist/internal/regex-internal-specifier.mjs +1 -0
- package/dist/internal/regex-internal-specifier.mjs.map +8 -0
- package/dist/internal/regex-invalid-segment.mjs +1 -0
- package/dist/internal/regex-invalid-segment.mjs.map +8 -0
- package/dist/internal/regex-package-name.mjs +1 -0
- package/dist/internal/regex-package-name.mjs.map +8 -0
- package/dist/internal/regex-package-path.mjs +1 -0
- package/dist/internal/regex-package-path.mjs.map +8 -0
- package/dist/internal/resolver.mjs +1 -0
- package/dist/internal/resolver.mjs.map +8 -0
- package/dist/internal/validate-array-set.mjs +1 -0
- package/dist/internal/validate-array-set.mjs.map +8 -0
- package/dist/internal/validate-boolean.mjs +1 -0
- package/dist/internal/validate-boolean.mjs.map +8 -0
- package/dist/internal/validate-map.mjs +1 -0
- package/dist/internal/validate-map.mjs.map +8 -0
- package/dist/internal/validate-object.mjs +1 -0
- package/dist/internal/validate-object.mjs.map +8 -0
- package/dist/internal/validate-set.mjs +1 -0
- package/dist/internal/validate-set.mjs.map +8 -0
- package/dist/internal/validate-string.mjs +1 -0
- package/dist/internal/validate-string.mjs.map +8 -0
- package/dist/internal/validate-url-string.mjs +1 -0
- package/dist/internal/validate-url-string.mjs.map +8 -0
- package/dist/utils/compare-subpaths.mjs.map +4 -5
- package/dist/utils/conditions.mjs.map +4 -5
- package/dist/utils/detect-syntax.mjs.map +4 -5
- package/dist/utils/extension-format-map.mjs.map +4 -5
- package/dist/utils/extract-statements.mjs.map +4 -5
- package/dist/utils/fill-modules.mjs.map +5 -8
- package/dist/utils/find-dynamic-imports.mjs.map +5 -8
- package/dist/utils/find-exports.mjs.map +5 -8
- package/dist/utils/find-requires.mjs.map +5 -8
- package/dist/utils/find-static-imports.mjs.map +5 -8
- package/dist/utils/find-subpath.mjs.map +5 -9
- package/dist/utils/get-format.mjs.map +5 -8
- package/dist/utils/get-source.mjs.map +4 -5
- package/dist/utils/has-cjs-syntax.mjs.map +4 -5
- package/dist/utils/has-esm-syntax.mjs.map +4 -5
- package/dist/utils/index.mjs.map +5 -8
- package/dist/utils/is-absolute-specifier.mjs.map +4 -5
- package/dist/utils/is-bare-specifier.mjs.map +4 -5
- package/dist/utils/is-directory.mjs.map +4 -5
- package/dist/utils/is-exports-sugar.mjs.map +4 -5
- package/dist/utils/is-file.mjs.map +4 -5
- package/dist/utils/is-relative-specifier.mjs.map +4 -5
- package/dist/utils/lookup-package-scope.mjs.map +4 -5
- package/dist/utils/parse-data-url.mjs.map +4 -5
- package/dist/utils/parse-module-id.mjs.map +5 -9
- package/dist/utils/parse-subpath.mjs.map +5 -8
- package/dist/utils/pattern-character.mjs.map +4 -5
- package/dist/utils/read-package-json.mjs.map +4 -5
- package/dist/utils/resolve-alias.mjs.map +5 -9
- package/dist/utils/resolve-aliases.mjs.map +4 -5
- package/dist/utils/resolve-extensions.mjs.map +4 -5
- package/dist/utils/resolve-module.mjs.map +4 -5
- package/dist/utils/resolve-modules.mjs.map +4 -5
- package/dist/utils/to-absolute-specifier.mjs.map +4 -5
- package/dist/utils/to-bare-specifier.mjs.map +4 -5
- package/dist/utils/to-data-url.mjs.map +4 -5
- package/dist/utils/to-node-url.mjs.map +4 -5
- package/dist/utils/to-relative-specifier.mjs.map +4 -5
- package/dist/utils/to-url.mjs.map +4 -5
- package/dist/utils/validate-assertions.mjs.map +5 -8
- package/dist/utils/validate-exports.mjs.map +4 -5
- package/package.json +8 -9
- package/src/enums/assert-type.ts +0 -23
- package/src/enums/format.ts +0 -19
- package/src/enums/index.ts +0 -11
- package/src/enums/kind-specifier-syntax.ts +0 -16
- package/src/enums/kind-specifier.ts +0 -19
- package/src/enums/kind-statement-syntax.ts +0 -24
- package/src/enums/kind-statement.ts +0 -17
- package/src/index.ts +0 -9
- package/src/interfaces/import-assertions.ts +0 -24
- package/src/interfaces/import-dynamic.ts +0 -46
- package/src/interfaces/import-static.ts +0 -46
- package/src/interfaces/index.ts +0 -25
- package/src/interfaces/options-fill-module.ts +0 -26
- package/src/interfaces/options-find-subpath.ts +0 -57
- package/src/interfaces/options-get-format.ts +0 -80
- package/src/interfaces/options-get-source.ts +0 -59
- package/src/interfaces/options-parse-module-id.ts +0 -39
- package/src/interfaces/options-parse-subpath.ts +0 -57
- package/src/interfaces/options-resolve-alias.ts +0 -59
- package/src/interfaces/options-resolve-module.ts +0 -72
- package/src/interfaces/options-resolve.ts +0 -17
- package/src/interfaces/package-scope.ts +0 -30
- package/src/interfaces/parsed-data-url.ts +0 -63
- package/src/interfaces/parsed-module-id.ts +0 -90
- package/src/interfaces/parsed-subpath.ts +0 -56
- package/src/interfaces/statement-export.ts +0 -52
- package/src/interfaces/statement-import.ts +0 -45
- package/src/interfaces/statement-require.ts +0 -45
- package/src/interfaces/statement.ts +0 -64
- package/src/internal/dequote.ts +0 -18
- package/src/internal/format-type-map.ts +0 -28
- package/src/internal/get-specifier-kind.ts +0 -41
- package/src/internal/get-subpaths.ts +0 -43
- package/src/internal/regex-encoded-sep.ts +0 -17
- package/src/internal/regex-internal-specifier.ts +0 -19
- package/src/internal/regex-invalid-segment.ts +0 -25
- package/src/internal/regex-package-name.ts +0 -18
- package/src/internal/regex-package-path.ts +0 -20
- package/src/internal/resolver.ts +0 -790
- package/src/internal/validate-array-set.ts +0 -35
- package/src/internal/validate-boolean.ts +0 -30
- package/src/internal/validate-map.ts +0 -36
- package/src/internal/validate-object.ts +0 -30
- package/src/internal/validate-set.ts +0 -32
- package/src/internal/validate-string.ts +0 -31
- package/src/internal/validate-url-string.ts +0 -34
- package/src/types/declaration.ts +0 -22
- package/src/types/fn-change-ext.ts +0 -33
- package/src/types/index.ts +0 -14
- package/src/types/mime-type.ts +0 -19
- package/src/types/module-id.ts +0 -15
- package/src/types/module-specifier-type.ts +0 -13
- package/src/types/protocol.ts +0 -40
- package/src/types/syntax-kind-export.ts +0 -20
- package/src/types/syntax-kind-import.ts +0 -22
- package/src/types/syntax-kind-require.ts +0 -15
- package/src/utils/compare-subpaths.ts +0 -100
- package/src/utils/conditions.ts +0 -15
- package/src/utils/detect-syntax.ts +0 -40
- package/src/utils/extension-format-map.ts +0 -34
- package/src/utils/extract-statements.ts +0 -46
- package/src/utils/fill-modules.ts +0 -133
- package/src/utils/find-dynamic-imports.ts +0 -75
- package/src/utils/find-exports.ts +0 -156
- package/src/utils/find-requires.ts +0 -75
- package/src/utils/find-static-imports.ts +0 -86
- package/src/utils/find-subpath.ts +0 -251
- package/src/utils/get-format.ts +0 -249
- package/src/utils/get-source.ts +0 -144
- package/src/utils/has-cjs-syntax.ts +0 -44
- package/src/utils/has-esm-syntax.ts +0 -40
- package/src/utils/index.ts +0 -45
- package/src/utils/is-absolute-specifier.ts +0 -53
- package/src/utils/is-bare-specifier.ts +0 -36
- package/src/utils/is-directory.ts +0 -25
- package/src/utils/is-exports-sugar.ts +0 -81
- package/src/utils/is-file.ts +0 -25
- package/src/utils/is-relative-specifier.ts +0 -34
- package/src/utils/lookup-package-scope.ts +0 -97
- package/src/utils/parse-data-url.ts +0 -71
- package/src/utils/parse-module-id.ts +0 -197
- package/src/utils/parse-subpath.ts +0 -331
- package/src/utils/pattern-character.ts +0 -13
- package/src/utils/read-package-json.ts +0 -113
- package/src/utils/resolve-alias.ts +0 -224
- package/src/utils/resolve-aliases.ts +0 -58
- package/src/utils/resolve-extensions.ts +0 -33
- package/src/utils/resolve-module.ts +0 -181
- package/src/utils/resolve-modules.ts +0 -60
- package/src/utils/to-absolute-specifier.ts +0 -30
- package/src/utils/to-bare-specifier.ts +0 -211
- package/src/utils/to-data-url.ts +0 -42
- package/src/utils/to-node-url.ts +0 -27
- package/src/utils/to-relative-specifier.ts +0 -55
- package/src/utils/to-url.ts +0 -30
- package/src/utils/validate-assertions.ts +0 -126
- package/src/utils/validate-exports.ts +0 -131
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/resolve-module.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file resolveModule\n * @module mlly/utils/resolveModule\n */\n\nimport type { ResolveModuleOptions } from '#src/interfaces'\nimport Resolver from '#src/internal/resolver'\nimport validateArraySet from '#src/internal/validate-array-set'\nimport validateBoolean from '#src/internal/validate-boolean'\nimport validateString from '#src/internal/validate-string'\nimport validateURLString from '#src/internal/validate-url-string'\nimport { ErrorCode, type NodeError } from '@flex-development/errnode'\nimport { isBuiltin } from '@flex-development/is-builtin'\nimport pathe from '@flex-development/pathe'\nimport { cast, isFunction, type Nullable } from '@flex-development/tutils'\nimport { URL, fileURLToPath } from 'node:url'\nimport CONDITIONS from './conditions'\nimport RESOLVE_EXTENSIONS from './resolve-extensions'\n\n/**\n * Resolves `specifier` according to the [ESM Resolver algorithm][1], mostly 😉.\n *\n * Adds support for:\n *\n * - Extensionless file and directory index resolution\n * - Replacing file extensions\n *\n * Other differences between Node.js:\n *\n * - [Subpath import][2] targets (that are strings) must be relative to the\n * current working directory (e.g. `'./src/index.ts'`, `'./src/*.ts'`) or\n * start with a [NPM valid package name][3]. See [`nodejs/node#40579`][4] for\n * details.\n *\n * [1]: https://nodejs.org/api/esm.html#esm_resolver_algorithm\n * [2]: https://nodejs.org/api/packages.html#subpath-imports\n * [3]: https://regex101.com/r/BHcJfc\n * [4]: https://github.com/nodejs/node/issues/40579\n *\n * @see {@linkcode NodeError}\n * @see {@linkcode ResolveModuleOptions}\n * @see {@linkcode URL}\n *\n * @async\n *\n * @param {string} specifier - Module specifier to resolve\n * @param {ResolveModuleOptions} [options={}] - Module resolution options\n * @return {Promise<URL>} Resolved module URL\n * @throws {NodeError}\n */\nconst resolveModule = async (\n specifier: string,\n options: ResolveModuleOptions = {}\n): Promise<URL> => {\n const {\n condition = 'default',\n conditions = CONDITIONS,\n extensions = RESOLVE_EXTENSIONS,\n parent = import.meta.url,\n preserveSymlinks = false\n } = options\n\n // ensure specifier is a string\n validateString(specifier, 'specifier')\n\n // ensure option schemas\n validateString(condition, 'options.condition')\n validateArraySet(conditions, 'options.conditions')\n validateArraySet(extensions, 'options.extensions')\n validateURLString(parent, 'options.parent')\n validateBoolean(preserveSymlinks, 'options.preserveSymlinks')\n\n /**\n * Module resolver.\n *\n * @const {Resolver} resolver\n */\n const resolver: Resolver = new Resolver()\n\n /**\n * Boolean indicating only module id should be tried for resolution.\n *\n * @const {boolean} onetry\n */\n const onetry: boolean =\n isBuiltin(specifier) ||\n (/^\\S+:/.test(specifier) && !specifier.startsWith('file:'))\n\n /**\n * Module ids to try resolving.\n *\n * @const {string[]} tries\n */\n const tries: string[] = onetry\n ? []\n : [...extensions]\n .flatMap(ext => [\n specifier + (ext = pathe.formatExt(ext)),\n specifier.startsWith('#') ? specifier + '/index' : '',\n specifier + '/index' + ext\n ])\n .filter(id => !!id.length)\n\n // try @types resolution\n if (!onetry) {\n specifier.startsWith('@types')\n ? tries.unshift(specifier + '/index.d.ts')\n : tries.unshift('@types/' + specifier + '/index.d.ts')\n }\n\n // ensure attempt to resolve original specifier is first\n tries.unshift(specifier)\n\n /**\n * Error codes to ignore when attempting to resolve {@linkcode specifier}.\n *\n * **Note**: If an error is thrown, it'll be reported **_after_** all module\n * ids in {@linkcode tries} have been evaluated.\n *\n * @const {Set<ErrorCode>} ignore\n */\n const ignore: Set<ErrorCode> = new Set<ErrorCode>([\n ErrorCode.ERR_INVALID_MODULE_SPECIFIER,\n ErrorCode.ERR_MODULE_NOT_FOUND,\n ErrorCode.ERR_PACKAGE_PATH_NOT_EXPORTED,\n ErrorCode.ERR_UNSUPPORTED_DIR_IMPORT\n ])\n\n /**\n * Module resolution error.\n *\n * @var {NodeError} error\n */\n let error: NodeError\n\n /**\n * Resolved module URL.\n *\n * @var {Nullable<URL>} url\n */\n let url: Nullable<URL> = null\n\n // try module resolution\n for (const id of tries) {\n try {\n url = resolver.resolveModule(\n id,\n parent,\n condition,\n new Set(conditions),\n preserveSymlinks\n )\n } catch (e: unknown) {\n url = null\n if (id === specifier) error = cast(e)\n if (!ignore.has(cast<NodeError>(e).code)) throw e\n }\n\n // stop resolution attempts if module was resolved\n if (url) break\n }\n\n // throw if module was not resolved\n if (!url) throw error!\n\n // replace file extension\n if (url.protocol === 'file:') {\n let { ext } = options\n\n // get replacement extension\n ext = isFunction(ext) ? await ext(specifier, url) : ext\n\n // replace file extension in url href and pathname\n url.href = pathe.changeExt(url.href, ext).replace(/\\/index$/, '')\n url.pathname = fileURLToPath(url.href)\n }\n\n return url\n}\n\nexport default resolveModule\n"],
|
|
7
6
|
"mappings": "AAMA,OAAO,cAAc;AACrB,OAAO,sBAAsB;AAC7B,OAAO,qBAAqB;AAC5B,OAAO,oBAAoB;AAC3B,OAAO,uBAAuB;AAC9B,SAAS,iBAAiC;AAC1C,SAAS,iBAAiB;AAC1B,OAAO,WAAW;AAClB,SAAS,MAAM,kBAAiC;AAChD,SAAS,KAAK,qBAAqB;AACnC,OAAO,gBAAgB;AACvB,OAAO,wBAAwB;AAiC/B,MAAM,gBAAgB,OACpB,WACA,UAAgC,CAAC,MAChB;AACjB,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,aAAa;AAAA,IACb,SAAS,YAAY;AAAA,IACrB,mBAAmB;AAAA,EACrB,IAAI;AAGJ,iBAAe,WAAW,WAAW,GAGrC,eAAe,WAAW,mBAAmB,GAC7C,iBAAiB,YAAY,oBAAoB,GACjD,iBAAiB,YAAY,oBAAoB,GACjD,kBAAkB,QAAQ,gBAAgB,GAC1C,gBAAgB,kBAAkB,0BAA0B;AAO5D,QAAM,WAAqB,IAAI,SAAS,GAOlC,SACJ,UAAU,SAAS,KAClB,QAAQ,KAAK,SAAS,KAAK,CAAC,UAAU,WAAW,OAAO,GAOrD,QAAkB,SACpB,CAAC,IACD,CAAC,GAAG,UAAU,EACX,QAAQ,SAAO;AAAA,IACd,aAAa,MAAM,MAAM,UAAU,GAAG;AAAA,IACtC,UAAU,WAAW,GAAG,IAAI,YAAY,WAAW;AAAA,IACnD,YAAY,WAAW;AAAA,EACzB,CAAC,EACA,OAAO,QAAM,CAAC,CAAC,GAAG,MAAM;AAG/B,EAAK,WACH,UAAU,WAAW,QAAQ,IACzB,MAAM,QAAQ,YAAY,aAAa,IACvC,MAAM,QAAQ,YAAY,YAAY,aAAa,IAIzD,MAAM,QAAQ,SAAS;AAUvB,QAAM,SAAyB,oBAAI,IAAe;AAAA,IAChD,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,IACV,UAAU;AAAA,EACZ,CAAC;AAOD,MAAI,OAOA,MAAqB;AAGzB,aAAW,MAAM,OAAO;AACtB,QAAI;AACF,YAAM,SAAS;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,QACA,IAAI,IAAI,UAAU;AAAA,QAClB;AAAA,MACF;AAAA,IACF,SAAS,GAAY;AAGnB,UAFA,MAAM,MACF,OAAO,cAAW,QAAQ,KAAK,CAAC,IAChC,CAAC,OAAO,IAAI,KAAgB,CAAC,EAAE,IAAI;AAAG,cAAM;AAAA,IAClD;AAGA,QAAI;AAAK;AAAA,EACX;AAGA,MAAI,CAAC;AAAK,UAAM;AAGhB,MAAI,IAAI,aAAa,SAAS;AAC5B,QAAI,EAAE,IAAI,IAAI;AAGd,UAAM,WAAW,GAAG,IAAI,MAAM,IAAI,WAAW,GAAG,IAAI,KAGpD,IAAI,OAAO,MAAM,UAAU,IAAI,MAAM,GAAG,EAAE,QAAQ,YAAY,EAAE,GAChE,IAAI,WAAW,cAAc,IAAI,IAAI;AAAA,EACvC;AAEA,SAAO;AACT;AAEA,IAAO,yBAAQ;",
|
|
8
7
|
"names": []
|
|
9
|
-
}
|
|
8
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/resolve-modules.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file resolveModules\n * @module mlly/utils/resolveModules\n */\n\nimport { SpecifierSyntaxKind } from '#src/enums'\nimport type { ResolveModuleOptions } from '#src/interfaces'\nimport { regexp } from '@flex-development/tutils'\nimport type { URL } from 'node:url'\nimport extractStatements from './extract-statements'\nimport resolveModule from './resolve-module'\n\n/**\n * Converts all module specifiers in `code` to absolute specifiers.\n *\n * ::: info\n * Useful for converting code to [`data:` URLs][1].\n * :::\n *\n * [1]: https://nodejs.org/api/esm.html#data-imports\n *\n * @see {@linkcode ResolveModuleOptions}\n * @see https://nodejs.org/api/esm.html#terminology\n *\n * @async\n *\n * @param {string} code - Code to evaluate\n * @param {ResolveModuleOptions} [options={}] - Module resolution options\n * @return {Promise<string>} `code` with module specifiers fully resolved\n */\nconst resolveModules = async (\n code: string,\n options: ResolveModuleOptions = {}\n): Promise<string> => {\n for (const statement of extractStatements(code)) {\n if (statement.specifier) {\n if (statement.specifier_syntax !== SpecifierSyntaxKind.DYNAMIC) {\n /**\n * Resolved module URL.\n *\n * @const {URL} url\n */\n const url: URL = await resolveModule(statement.specifier, options)\n\n // replace original specifier\n code = code.replace(\n statement.code,\n statement.code.replace(\n new RegExp(`(?<=[\"'])${regexp(statement.specifier)}(?=[\"'])`),\n url.href\n )\n )\n }\n }\n }\n\n return code\n}\n\nexport default resolveModules\n"],
|
|
7
6
|
"mappings": "AAKA,SAAS,2BAA2B;AAEpC,SAAS,cAAc;AAEvB,OAAO,uBAAuB;AAC9B,OAAO,mBAAmB;AAoB1B,MAAM,iBAAiB,OACrB,MACA,UAAgC,CAAC,MACb;AACpB,aAAW,aAAa,kBAAkB,IAAI;AAC5C,QAAI,UAAU,aACR,UAAU,qBAAqB,oBAAoB,SAAS;AAM9D,YAAM,MAAW,MAAM,cAAc,UAAU,WAAW,OAAO;AAGjE,aAAO,KAAK;AAAA,QACV,UAAU;AAAA,QACV,UAAU,KAAK;AAAA,UACb,IAAI,OAAO,YAAY,OAAO,UAAU,SAAS,CAAC,UAAU;AAAA,UAC5D,IAAI;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAIJ,SAAO;AACT;AAEA,IAAO,0BAAQ;",
|
|
8
7
|
"names": []
|
|
9
|
-
}
|
|
8
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/to-absolute-specifier.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file toAbsoluteSpecifier\n * @module mlly/utils/toAbsoluteSpecifier\n */\n\nimport type { ModuleId } from '#src/types'\nimport { pathToFileURL } from 'node:url'\nimport toURL from './to-url'\n\n/**\n * Converts `specifier` into an absolute specifier.\n *\n * ::: info\n * The absolute specifier will only include a file extension if `specifier`\n * includes a file extension.\n * :::\n *\n * @see {@linkcode ModuleId}\n * @see https://nodejs.org/api/esm.html#terminology\n *\n * @param {ModuleId} specifier - Module specifier to convert\n * @param {ModuleId} [cwd=pathToFileURL('./')] - Current working directory\n * @return {string} `specifier` as absolute specifier (file url)\n */\nconst toAbsoluteSpecifier = (\n specifier: ModuleId,\n cwd: ModuleId = pathToFileURL('./')\n): string => toURL(specifier, cwd).href\n\nexport default toAbsoluteSpecifier\n"],
|
|
7
6
|
"mappings": "AAMA,SAAS,qBAAqB;AAC9B,OAAO,WAAW;AAiBlB,MAAM,sBAAsB,CAC1B,WACA,MAAgB,cAAc,IAAI,MACvB,MAAM,WAAW,GAAG,EAAE;AAEnC,IAAO,gCAAQ;",
|
|
8
7
|
"names": []
|
|
9
|
-
}
|
|
8
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/to-bare-specifier.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file toBareSpecifier\n * @module mlly/utils/toBareSpecifier\n */\n\nimport type { PackageScope, ParsedModuleId } from '#src/interfaces'\nimport validateSet from '#src/internal/validate-set'\nimport validateURLString from '#src/internal/validate-url-string'\nimport type { ModuleId } from '#src/types'\nimport {\n ERR_OPERATION_FAILED,\n ERR_PACKAGE_PATH_NOT_EXPORTED,\n ErrorCode,\n type NodeError\n} from '@flex-development/errnode'\nimport { isBuiltin } from '@flex-development/is-builtin'\nimport pathe from '@flex-development/pathe'\nimport {\n DOT,\n cast,\n isNIL,\n regexp,\n type Nullable\n} from '@flex-development/tutils'\nimport { URL, fileURLToPath, pathToFileURL } from 'node:url'\nimport CONDITIONS from './conditions'\nimport findSubpath from './find-subpath'\nimport isAbsoluteSpecifier from './is-absolute-specifier'\nimport isRelativeSpecifier from './is-relative-specifier'\nimport lookupPackageScope from './lookup-package-scope'\nimport parseModuleId from './parse-module-id'\nimport parseSubpath from './parse-subpath'\nimport PATTERN_CHARACTER from './pattern-character'\nimport toAbsoluteSpecifier from './to-absolute-specifier'\nimport toNodeURL from './to-node-url'\nimport toURL from './to-url'\n\n/**\n * Converts the given module `specifier` into a bare specifier.\n *\n * The new specifier is **not** guaranteed to resolve to an existing module, nor\n * is it guaranteed to have a file extension, but it *is* guaranteed to be a\n * package path containing a valid [subpath export][1] if the specifier's parent\n * package uses package [`exports`][2]. If the parent package does not use\n * `exports`, the new specifier is only guaranteed to begin with a valid NPM\n * package name or Node.js [builtin module][3] name.\n *\n * The given module `specifier` should be absolute, syntactically bare (i.e. not\n * begin with `'/'` or `'.'`), or relative to the current working directory\n * (e.g. `'./dist/index.mjs'`).\n *\n * ::: warning\n * Internal specifier (i.e. [subpath import][4]; `'#src'`, `'#src/utils'`)\n * conversion is not supported. Converting *_to_* an internal specifier will be\n * supported in the future.\n * :::\n *\n * [1]: https://nodejs.org/api/packages.html#subpath-exports\n * [2]: https://nodejs.org/api/packages.html#exports\n * [3]: https://nodejs.org/api/module.html#modulebuiltinmodules\n * [4]: https://nodejs.org/api/packages.html#subpath-imports\n *\n * @see {@linkcode CONDITIONS}\n * @see {@linkcode ModuleId}\n * @see https://nodejs.org/api/esm.html#terminology\n *\n * @param {ModuleId} specifier - Module specifier to convert\n * @param {ModuleId} parent - URL of module to resolve from\n * @param {Set<string>?} [conditions=CONDITIONS] - Export conditions\n * @return {string} `specifier` as bare specifier\n * @throws {NodeError}\n */\nconst toBareSpecifier = (\n specifier: ModuleId,\n parent: ModuleId,\n conditions: Set<string> = CONDITIONS\n): string => {\n validateURLString(specifier, 'specifier')\n validateURLString(parent, 'parent')\n validateSet(conditions, 'conditions')\n\n // ensure specifier is a string\n if (specifier instanceof URL) specifier = specifier.href\n\n // exit early if specifier is builtin module\n if (isBuiltin(specifier)) return toNodeURL(specifier)\n\n // ensure specifier is a path\n if (specifier.startsWith('file:')) specifier = fileURLToPath(specifier)\n\n // convert relative specifiers to absolute paths\n if (isRelativeSpecifier(specifier)) {\n specifier = fileURLToPath(toAbsoluteSpecifier(specifier))\n }\n\n /**\n * Location to begin package scope search for {@linkcode specifier}.\n *\n * @const {URL} url\n */\n const url: URL = toURL(\n isAbsoluteSpecifier(specifier) || specifier.startsWith('node_modules')\n ? specifier\n : `node_modules/${specifier}`\n )\n\n /**\n * Package scope result for {@linkcode specifier}.\n *\n * @const {Nullable<PackageScope>} scope\n */\n const scope: Nullable<PackageScope> =\n lookupPackageScope(url, pathToFileURL(DOT)) ??\n lookupPackageScope(specifier, pathToFileURL(DOT))\n\n // throw if package scope was not found\n if (!scope) {\n throw new ERR_OPERATION_FAILED(`Package scope for '${specifier}' not found`)\n }\n\n // get package exports and name\n const { exports, main, name = '', types } = scope.pkgjson\n\n // convert specifier to bare specifier\n specifier = url.pathname.includes(name)\n ? name + url.pathname.replace(new RegExp(`.*?${regexp(name)}`), '')\n : name + specifier.replace(fileURLToPath(scope.dir.replace(/\\/$/, '')), '')\n\n /**\n * Parsed module specifier.\n *\n * Ensures {@linkcode specifier} has become a bare specifier.\n *\n * @const {ParsedModuleId} id\n */\n const id: ParsedModuleId = parseModuleId(specifier, {\n internal: false,\n parent,\n pkgname: true\n })\n\n // exit early if subpath does not need to be validated\n if (isNIL(exports)) {\n // set specifier to package name if specifier is main or types entry point\n if ([main, types].some(ep => ep === id.path || ep === id.path.slice(2))) {\n specifier = id.pkg\n }\n\n // remove '@types/' prefix to avoid 'Cannot import type declaration files.\n // Consider importing \"*\" instead of \"@types/*\"' (TS6137) error\n specifier = specifier.replace(/^@types\\//, '')\n\n return specifier\n }\n\n // check if specifier contains valid subpath export\n try {\n parseSubpath(specifier, exports, { dir: scope.dir, parent })\n } catch (e: unknown) {\n // try finding defined subpath if specifier is invalid package path\n if (cast<NodeError>(e).code === ErrorCode.ERR_PACKAGE_PATH_NOT_EXPORTED) {\n /**\n * Package target to find defined subpath for.\n *\n * @const {string} target\n */\n const target: string = specifier.replace(name, DOT)\n\n /**\n * Subpath in {@linkcode exports} thats maps to {@linkcode target}, if any\n * at all.\n *\n * @var {Nullable<string>} subpath\n */\n let subpath: Nullable<string> = findSubpath(target, exports, {\n conditions,\n dir: scope.dir,\n parent\n })\n\n // throw if target was not matched to a subpath\n if (subpath === null) {\n throw new ERR_PACKAGE_PATH_NOT_EXPORTED(\n fileURLToPath(scope.dir),\n id.path,\n fileURLToPath(parent)\n )\n }\n\n // replace pattern character in subpath\n if (subpath.includes(PATTERN_CHARACTER)) {\n subpath = subpath.slice(0, subpath.indexOf(PATTERN_CHARACTER)).slice(1)\n subpath = DOT + target.slice(target.indexOf(subpath))\n }\n\n // subpath should not include extension if extension is already included\n // via package target\n if (pathe.extname(target) === pathe.extname(subpath)) {\n subpath = pathe.changeExt(subpath, '')\n }\n\n return name + subpath.slice(1)\n } /* c8 ignore next 3 */\n // throw original error if package path error is not encountered\n throw e\n }\n\n return specifier\n}\n\nexport default toBareSpecifier\n"],
|
|
7
6
|
"mappings": "AAMA,OAAO,iBAAiB;AACxB,OAAO,uBAAuB;AAE9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,iBAAiB;AAC1B,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,KAAK,eAAe,qBAAqB;AAClD,OAAO,gBAAgB;AACvB,OAAO,iBAAiB;AACxB,OAAO,yBAAyB;AAChC,OAAO,yBAAyB;AAChC,OAAO,wBAAwB;AAC/B,OAAO,mBAAmB;AAC1B,OAAO,kBAAkB;AACzB,OAAO,uBAAuB;AAC9B,OAAO,yBAAyB;AAChC,OAAO,eAAe;AACtB,OAAO,WAAW;AAqClB,MAAM,kBAAkB,CACtB,WACA,QACA,aAA0B,eACf;AASX,MARA,kBAAkB,WAAW,WAAW,GACxC,kBAAkB,QAAQ,QAAQ,GAClC,YAAY,YAAY,YAAY,GAGhC,qBAAqB,QAAK,YAAY,UAAU,OAGhD,UAAU,SAAS;AAAG,WAAO,UAAU,SAAS;AAGpD,EAAI,UAAU,WAAW,OAAO,MAAG,YAAY,cAAc,SAAS,IAGlE,oBAAoB,SAAS,MAC/B,YAAY,cAAc,oBAAoB,SAAS,CAAC;AAQ1D,QAAM,MAAW;AAAA,IACf,oBAAoB,SAAS,KAAK,UAAU,WAAW,cAAc,IACjE,YACA,gBAAgB,SAAS;AAAA,EAC/B,GAOM,QACJ,mBAAmB,KAAK,cAAc,GAAG,CAAC,KAC1C,mBAAmB,WAAW,cAAc,GAAG,CAAC;AAGlD,MAAI,CAAC;AACH,UAAM,IAAI,qBAAqB,sBAAsB,SAAS,aAAa;AAI7E,QAAM,EAAE,SAAS,MAAM,OAAO,IAAI,MAAM,IAAI,MAAM;AAGlD,cAAY,IAAI,SAAS,SAAS,IAAI,IAClC,OAAO,IAAI,SAAS,QAAQ,IAAI,OAAO,MAAM,OAAO,IAAI,CAAC,EAAE,GAAG,EAAE,IAChE,OAAO,UAAU,QAAQ,cAAc,MAAM,IAAI,QAAQ,OAAO,EAAE,CAAC,GAAG,EAAE;AAS5E,QAAM,KAAqB,cAAc,WAAW;AAAA,IAClD,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAGD,MAAI,MAAM,OAAO;AAEf,WAAI,CAAC,MAAM,KAAK,EAAE,KAAK,QAAM,OAAO,GAAG,QAAQ,OAAO,GAAG,KAAK,MAAM,CAAC,CAAC,MACpE,YAAY,GAAG,MAKjB,YAAY,UAAU,QAAQ,aAAa,EAAE,GAEtC;AAIT,MAAI;AACF,iBAAa,WAAW,SAAS,EAAE,KAAK,MAAM,KAAK,OAAO,CAAC;AAAA,EAC7D,SAAS,GAAY;AAEnB,QAAI,KAAgB,CAAC,EAAE,SAAS,UAAU,+BAA+B;AAMvE,YAAM,SAAiB,UAAU,QAAQ,MAAM,GAAG;AAQlD,UAAI,UAA4B,YAAY,QAAQ,SAAS;AAAA,QAC3D;AAAA,QACA,KAAK,MAAM;AAAA,QACX;AAAA,MACF,CAAC;AAGD,UAAI,YAAY;AACd,cAAM,IAAI;AAAA,UACR,cAAc,MAAM,GAAG;AAAA,UACvB,GAAG;AAAA,UACH,cAAc,MAAM;AAAA,QACtB;AAIF,aAAI,QAAQ,SAAS,iBAAiB,MACpC,UAAU,QAAQ,MAAM,GAAG,QAAQ,QAAQ,iBAAiB,CAAC,EAAE,MAAM,CAAC,GACtE,UAAU,MAAM,OAAO,MAAM,OAAO,QAAQ,OAAO,CAAC,IAKlD,MAAM,QAAQ,MAAM,MAAM,MAAM,QAAQ,OAAO,MACjD,UAAU,MAAM,UAAU,SAAS,EAAE,IAGhC,OAAO,QAAQ,MAAM,CAAC;AAAA,IAC/B;AAEA,UAAM;AAAA,EACR;AAEA,SAAO;AACT;AAEA,IAAO,4BAAQ;",
|
|
8
7
|
"names": []
|
|
9
|
-
}
|
|
8
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/to-data-url.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file toDataURL\n * @module mlly/utils/toDataURL\n */\n\nimport validateString from '#src/internal/validate-string'\nimport type { MimeType } from '#src/types'\nimport type { NodeError } from '@flex-development/errnode'\n\n/**\n * Converts `code` into a [`data:` URL][1] using `base64` encoding.\n *\n * ::: tip\n * `data:` URLs only resolve [bare specifiers][2] for builtin modules and\n * [absolute specifiers][2].\n *\n * Call [`await resolveModules(code)`][3] to ensure all specifiers are absolute\n * or bare.\n * :::\n *\n * [1]: https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs\n * [2]: https://nodejs.org/api/esm.html#terminology\n * [3]: {@link ./resolve-modules.ts}\n *\n * @see {@linkcode MimeType}\n * @see https://nodejs.org/api/esm.html#esm_data_imports\n *\n * @param {string} code - Code to convert\n * @param {MimeType} [mime='text/javascript'] - MIME type\n * @return {string} `code` as `data:` URL\n * @throws {NodeError<TypeError>} If `code` or `mime` is not a string\n */\nconst toDataURL = (\n code: string,\n mime: MimeType = 'text/javascript'\n): string => {\n validateString(code, 'code')\n validateString(mime, 'mime')\n return `data:${mime};base64,${Buffer.from(code).toString('base64')}`\n}\n\nexport default toDataURL\n"],
|
|
7
6
|
"mappings": "AAKA,OAAO,oBAAoB;AA2B3B,MAAM,YAAY,CAChB,MACA,OAAiB,uBAEjB,eAAe,MAAM,MAAM,GAC3B,eAAe,MAAM,MAAM,GACpB,QAAQ,IAAI,WAAW,OAAO,KAAK,IAAI,EAAE,SAAS,QAAQ,CAAC;AAGpE,IAAO,sBAAQ;",
|
|
8
7
|
"names": []
|
|
9
|
-
}
|
|
8
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/to-node-url.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file toNodeURL\n * @module mlly/utils/toNodeURL\n */\n\nimport validateString from '#src/internal/validate-string'\nimport type { NodeError } from '@flex-development/errnode'\n\n/**\n * Converts the given module `specifier` to a `node:` URL.\n *\n * ::: warning\n * Does not guarantee the new specifier is an existing Node.js builtin module.\n * :::\n *\n * @see https://nodejs.org/api/esm.html#node-imports\n *\n * @param {string} specifier - Module specifier to convert\n * @return {string} `specifier` as `node:` URL\n * @throws {NodeError<TypeError>} If `specifier` is not a string\n */\nconst toNodeURL = (specifier: string): string => {\n validateString(specifier, 'specifier')\n return specifier.startsWith('node:') ? specifier : `node:${specifier}`\n}\n\nexport default toNodeURL\n"],
|
|
7
6
|
"mappings": "AAKA,OAAO,oBAAoB;AAgB3B,MAAM,YAAY,CAAC,eACjB,eAAe,WAAW,WAAW,GAC9B,UAAU,WAAW,OAAO,IAAI,YAAY,QAAQ,SAAS;AAGtE,IAAO,sBAAQ;",
|
|
8
7
|
"names": []
|
|
9
|
-
}
|
|
8
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/to-relative-specifier.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file toRelativeSpecifier\n * @module mlly/utils/toRelativeSpecifier\n */\n\nimport validateURLString from '#src/internal/validate-url-string'\nimport type { ModuleId } from '#src/types'\nimport type { NodeError } from '@flex-development/errnode'\nimport pathe from '@flex-development/pathe'\nimport { DOT } from '@flex-development/tutils'\nimport { URL, fileURLToPath } from 'node:url'\n\n/**\n * Converts `specifier` into a relative specifier.\n *\n * ::: info\n * The relative specifier will only include a file extension if `specifier`\n * includes a file extension.\n * :::\n *\n * @see {@linkcode ModuleId}\n * @see https://nodejs.org/api/esm.html#terminology\n *\n * @param {ModuleId} specifier - Module specifier to convert\n * @param {ModuleId} parent - Parent module URL or path to resolve from\n * @return {string} `specifier` as relative specifier\n * @throws {NodeError<TypeError>} If either `specifier` or `parent` is not a\n * string or an instance of {@linkcode URL}\n */\nconst toRelativeSpecifier = (specifier: ModuleId, parent: ModuleId): string => {\n validateURLString(specifier, 'specifier')\n validateURLString(parent, 'parent')\n\n // convert file url objects to file url strings\n if (parent instanceof URL) parent = parent.href\n if (specifier instanceof URL) specifier = specifier.href\n\n // convert file url strings to paths\n if (parent.startsWith('file:')) parent = fileURLToPath(parent)\n if (specifier.startsWith('file:')) specifier = fileURLToPath(specifier)\n\n // convert specifier to relative specifier\n specifier = pathe\n .relative(pathe.resolve(parent), pathe.resolve(specifier))\n .replace(/^\\.\\.\\/?/, '')\n .replace(/^(\\w)/, './$1')\n\n // set specifier to dot character if empty string\n // this occurs when specifier is a directory, but is not fully specified\n if (!specifier) specifier = DOT\n\n return specifier\n}\n\nexport default toRelativeSpecifier\n"],
|
|
7
6
|
"mappings": "AAKA,OAAO,uBAAuB;AAG9B,OAAO,WAAW;AAClB,SAAS,WAAW;AACpB,SAAS,KAAK,qBAAqB;AAmBnC,MAAM,sBAAsB,CAAC,WAAqB,YAChD,kBAAkB,WAAW,WAAW,GACxC,kBAAkB,QAAQ,QAAQ,GAG9B,kBAAkB,QAAK,SAAS,OAAO,OACvC,qBAAqB,QAAK,YAAY,UAAU,OAGhD,OAAO,WAAW,OAAO,MAAG,SAAS,cAAc,MAAM,IACzD,UAAU,WAAW,OAAO,MAAG,YAAY,cAAc,SAAS,IAGtE,YAAY,MACT,SAAS,MAAM,QAAQ,MAAM,GAAG,MAAM,QAAQ,SAAS,CAAC,EACxD,QAAQ,YAAY,EAAE,EACtB,QAAQ,SAAS,MAAM,GAIrB,cAAW,YAAY,MAErB;AAGT,IAAO,gCAAQ;",
|
|
8
7
|
"names": []
|
|
9
|
-
}
|
|
8
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/to-url.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file toURL\n * @module mlly/utils/toURL\n */\n\nimport validateURLString from '#src/internal/validate-url-string'\nimport type { ModuleId } from '#src/types'\nimport type { NodeError } from '@flex-development/errnode'\nimport { URL, pathToFileURL } from 'node:url'\n\n/**\n * Converts the given module `id` to an instance of [`URL`][1].\n *\n * [1]: https://nodejs.org/api/url.html#class-url\n *\n * @see {@linkcode ModuleId}\n *\n * @param {ModuleId} id - Module id to evaluate\n * @param {ModuleId?} [base=pathToFileURL('./')] - Base URL to resolve against\n * @return {URL} `id` as instance of {@linkcode URL}\n * @throws {NodeError<TypeError>} If either `id` or `base` is not a string or an\n * instance of {@linkcode URL}\n */\nconst toURL = (id: ModuleId, base: ModuleId = pathToFileURL('./')): URL => {\n validateURLString(id, 'id')\n validateURLString(base, 'base')\n return id instanceof URL ? id : new URL(id, base)\n}\n\nexport default toURL\n"],
|
|
7
6
|
"mappings": "AAKA,OAAO,uBAAuB;AAG9B,SAAS,KAAK,qBAAqB;AAenC,MAAM,QAAQ,CAAC,IAAc,OAAiB,cAAc,IAAI,OAC9D,kBAAkB,IAAI,IAAI,GAC1B,kBAAkB,MAAM,MAAM,GACvB,cAAc,MAAM,KAAK,IAAI,IAAI,IAAI,IAAI;AAGlD,IAAO,iBAAQ;",
|
|
8
7
|
"names": []
|
|
9
|
-
}
|
|
8
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/validate-assertions.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file validateAssertions\n * @module mlly/utils/validateAssertions\n */\n\nimport { AssertType, type Format } from '#src/enums'\nimport type { ImportAssertions } from '#src/interfaces'\nimport FORMAT_TYPE_MAP from '#src/internal/format-type-map'\nimport validateObject from '#src/internal/validate-object'\nimport validateString from '#src/internal/validate-string'\nimport validateURLString from '#src/internal/validate-url-string'\nimport type { ModuleId } from '#src/types'\nimport {\n ERR_IMPORT_ASSERTION_TYPE_FAILED,\n ERR_IMPORT_ASSERTION_TYPE_MISSING,\n ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED,\n type NodeError\n} from '@flex-development/errnode'\nimport {\n cast,\n hasOwn,\n includes,\n type LiteralUnion,\n type Optional\n} from '@flex-development/tutils'\nimport { URL } from 'node:url'\n\n/**\n * Test a module's `import` assertions.\n *\n * @see {@linkcode Format}\n * @see {@linkcode ImportAssertions}\n * @see {@linkcode ModuleId}\n *\n * @param {ModuleId} url - Module URL of imported module (for error reporting)\n * @param {LiteralUnion<Format, string>} format - Module format\n * @param {ImportAssertions} [assertions={}] - `import` assertions\n * @return {true} `true` if `assertions` are valid\n * @throws {NodeError<TypeError>}\n */\nconst validateAssertions = (\n url: ModuleId,\n format: LiteralUnion<Format, string>,\n assertions: ImportAssertions = {}\n): true => {\n validateURLString(url, 'url')\n validateString(format, 'format')\n validateObject(assertions, 'assertions')\n\n // ensure url is a string\n if (url instanceof URL) url = url.href\n\n /**\n * `type` property check for {@linkcode assertions}.\n *\n * @const {boolean} has_type\n */\n const has_type: boolean = hasOwn(assertions, 'type')\n\n /**\n * `import` assertion type.\n *\n * @const {Optional<AssertType>} type\n */\n const type: Optional<AssertType> = FORMAT_TYPE_MAP.get(cast(format))\n\n /**\n * `import` assertion error check.\n *\n * @var {boolean} err\n */\n let err: boolean = false\n\n // validate import assertions\n switch (type) {\n case undefined:\n // ignore assertions for unrecognized module formats to allow for new\n // formats in the future\n break\n case AssertType.IMPLICIT:\n // format doesn't allow an import assertion type, so the `type` property\n // must not be set on the import assertions object\n if (has_type) err = true\n break\n case assertions.type:\n // asserted type is compatible with format\n break\n default:\n // format has an expected type, but asserted type is not compatible\n err = true\n }\n\n // throw if error was encountered\n if (err) {\n // import assertion type was not specified\n if (!has_type) throw new ERR_IMPORT_ASSERTION_TYPE_MISSING(url, type!)\n\n // import assertion type may have not been a string\n validateString(assertions.type, 'assertions.type')\n\n /**\n * Supported `import` assertion types.\n *\n * @const {AssertType[]} supported\n */\n const supported: AssertType[] = []\n\n // get supported import assertion types\n for (const [, type] of FORMAT_TYPE_MAP) {\n if (type === AssertType.IMPLICIT) continue\n supported.push(type)\n }\n\n // throw if asserted type is not supported\n if (!includes(supported, assertions.type)) {\n throw new ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED(assertions.type!)\n }\n\n // unknown error\n throw new ERR_IMPORT_ASSERTION_TYPE_FAILED(url, assertions.type!)\n }\n\n return true\n}\n\nexport default validateAssertions\n"],
|
|
7
6
|
"mappings": "AAKA,SAAS,kBAA+B;AAExC,OAAO,qBAAqB;AAC5B,OAAO,oBAAoB;AAC3B,OAAO,oBAAoB;AAC3B,OAAO,uBAAuB;AAE9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,WAAW;AAepB,MAAM,qBAAqB,CACzB,KACA,QACA,aAA+B,CAAC,MACvB;AACT,oBAAkB,KAAK,KAAK,GAC5B,eAAe,QAAQ,QAAQ,GAC/B,eAAe,YAAY,YAAY,GAGnC,eAAe,QAAK,MAAM,IAAI;AAOlC,QAAM,WAAoB,OAAO,YAAY,MAAM,GAO7C,OAA6B,gBAAgB,IAAI,KAAK,MAAM,CAAC;AAOnE,MAAI,MAAe;AAGnB,UAAQ,MAAM;AAAA,IACZ,KAAK;AAGH;AAAA,IACF,KAAK,WAAW;AAGd,MAAI,aAAU,MAAM;AACpB;AAAA,IACF,KAAK,WAAW;AAEd;AAAA,IACF;AAEE,YAAM;AAAA,EACV;AAGA,MAAI,KAAK;AAEP,QAAI,CAAC;AAAU,YAAM,IAAI,kCAAkC,KAAK,IAAK;AAGrE,mBAAe,WAAW,MAAM,iBAAiB;AAOjD,UAAM,YAA0B,CAAC;AAGjC,eAAW,CAAC,EAAEA,KAAI,KAAK;AACrB,MAAIA,UAAS,WAAW,YACxB,UAAU,KAAKA,KAAI;AAIrB,UAAK,SAAS,WAAW,WAAW,IAAI,IAKlC,IAAI,iCAAiC,KAAK,WAAW,IAAK,IAJxD,IAAI,sCAAsC,WAAW,IAAK;AAAA,EAKpE;AAEA,SAAO;AACT;AAEA,IAAO,8BAAQ;",
|
|
8
|
-
"names": [
|
|
9
|
-
|
|
10
|
-
]
|
|
11
|
-
}
|
|
7
|
+
"names": ["type"]
|
|
8
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
|
|
5
|
-
],
|
|
6
|
-
"sourceRoot": "https:/github.com/flex-development/mlly/blob/1.0.0-alpha.16",
|
|
3
|
+
"sources": ["../../src/utils/validate-exports.ts"],
|
|
4
|
+
"sourceRoot": "file://",
|
|
5
|
+
"sourcesContent": ["/**\n * @file validateExports\n * @module mlly/utils/validateExports\n */\n\nimport validateURLString from '#src/internal/validate-url-string'\nimport type { ModuleId } from '#src/types'\nimport {\n ERR_INVALID_PACKAGE_CONFIG,\n type NodeError\n} from '@flex-development/errnode'\nimport type { Exports } from '@flex-development/pkg-types'\nimport {\n DOT,\n at,\n cast,\n isArray,\n isArrayIndex,\n isNIL,\n isObjectCurly,\n isString,\n type Optional\n} from '@flex-development/tutils'\nimport { URL, fileURLToPath } from 'node:url'\n\n/**\n * Validates the given package [`exports`][1] configuration and schema.\n *\n * [1]: https://nodejs.org/api/packages.html#exports\n *\n * @see {@linkcode Exports}\n * @see {@linkcode ModuleId}\n *\n * @param {Optional<Exports>} exports - Package `exports`\n * @param {ModuleId} pkg - URL of relevant `package.json` file\n * @param {ModuleId} parent - URL of module to resolve from\n * @return {true} `true` if `exports` configuration and schema are valid\n * @throws {NodeError<Error | TypeError>} If either `pkg` or `parent` is not a\n * string or an instance of {@linkcode URL}, or if `exports` configuration or\n * schema is invalid\n */\nconst validateExports = (\n exports: Optional<Exports>,\n pkg: ModuleId,\n parent: ModuleId\n): true => {\n validateURLString(pkg, 'pkg')\n validateURLString(parent, 'parent')\n\n switch (true) {\n case isArray(exports):\n for (const item of cast<unknown[]>(exports)) {\n switch (true) {\n case !isObjectCurly(item) && !isString(item):\n throw new ERR_INVALID_PACKAGE_CONFIG(\n fileURLToPath(pkg),\n fileURLToPath(parent),\n 'The \"exports\" array must contain either objects of package subpath keys, objects of condition name keys, or strings'\n )\n default:\n validateExports(\n cast<Record<string, Exports> | string>(item),\n pkg,\n parent\n )\n break\n }\n }\n\n break\n case isNIL(exports):\n case isString(exports):\n break\n case !isObjectCurly(exports):\n throw new ERR_INVALID_PACKAGE_CONFIG(\n fileURLToPath(pkg),\n fileURLToPath(parent),\n '\"exports\" must be null, undefined, a string, an object of package subpath keys or condition name keys, or an array containing objects of package subpath keys, objects of condition name keys, or strings'\n )\n default:\n exports = cast<Record<string, Exports>>(exports)\n\n /**\n * Keys defined in {@linkcode exports}.\n *\n * @const {string[]} keys\n */\n const keys: string[] = Object.getOwnPropertyNames(exports)\n\n // validate keys\n for (const [index, key] of keys.entries()) {\n // ensure key is not an array index\n if (isArrayIndex(key)) {\n throw new ERR_INVALID_PACKAGE_CONFIG(\n fileURLToPath(new URL(DOT, pkg)),\n fileURLToPath(parent),\n '\"exports\" cannot contain numeric property keys'\n )\n }\n\n // if more than one key in keys, ensure all keys are either syntactical\n // export conditions or subpath exports\n if (index) {\n /**\n * Key before {@linkcode key} in {@linkcode keys}.\n *\n * @const {string} prev\n */\n const prev: string = at(keys, index - 1)\n\n // ensure keys are syntactical export conditions or subpath exports\n if (\n (!key.startsWith(DOT) && prev.startsWith(DOT)) ||\n (key.startsWith(DOT) && !prev.startsWith(DOT))\n ) {\n throw new ERR_INVALID_PACKAGE_CONFIG(\n fileURLToPath(pkg),\n fileURLToPath(parent),\n '\"exports\" cannot contain some keys starting with \\'.\\' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.'\n )\n }\n }\n }\n\n break\n }\n\n return true\n}\n\nexport default validateExports\n"],
|
|
7
6
|
"mappings": "AAKA,OAAO,uBAAuB;AAE9B;AAAA,EACE;AAAA,OAEK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,KAAK,qBAAqB;AAkBnC,MAAM,kBAAkB,CACtB,SACA,KACA,WACS;AAIT,UAHA,kBAAkB,KAAK,KAAK,GAC5B,kBAAkB,QAAQ,QAAQ,GAE1B,IAAM;AAAA,IACZ,KAAK,QAAQ,OAAO;AAClB,iBAAW,QAAQ,KAAgB,OAAO;AACxC,gBAAQ,IAAM;AAAA,UACZ,MAAK,CAAC,cAAc,IAAI,KAAK,CAAC,SAAS,IAAI;AACzC,kBAAM,IAAI;AAAA,cACR,cAAc,GAAG;AAAA,cACjB,cAAc,MAAM;AAAA,cACpB;AAAA,YACF;AAAA,UACF;AACE;AAAA,cACE,KAAuC,IAAI;AAAA,cAC3C;AAAA,cACA;AAAA,YACF;AACA;AAAA,QACJ;AAGF;AAAA,IACF,KAAK,MAAM,OAAO;AAAA,IAClB,KAAK,SAAS,OAAO;AACnB;AAAA,IACF,KAAK,CAAC,cAAc,OAAO;AACzB,YAAM,IAAI;AAAA,QACR,cAAc,GAAG;AAAA,QACjB,cAAc,MAAM;AAAA,QACpB;AAAA,MACF;AAAA,IACF;AACE,gBAAU,KAA8B,OAAO;AAO/C,YAAM,OAAiB,OAAO,oBAAoB,OAAO;AAGzD,iBAAW,CAAC,OAAO,GAAG,KAAK,KAAK,QAAQ,GAAG;AAEzC,YAAI,aAAa,GAAG;AAClB,gBAAM,IAAI;AAAA,YACR,cAAc,IAAI,IAAI,KAAK,GAAG,CAAC;AAAA,YAC/B,cAAc,MAAM;AAAA,YACpB;AAAA,UACF;AAKF,YAAI,OAAO;AAMT,gBAAM,OAAe,GAAG,MAAM,QAAQ,CAAC;AAGvC,cACG,CAAC,IAAI,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,KAC3C,IAAI,WAAW,GAAG,KAAK,CAAC,KAAK,WAAW,GAAG;AAE5C,kBAAM,IAAI;AAAA,cACR,cAAc,GAAG;AAAA,cACjB,cAAc,MAAM;AAAA,cACpB;AAAA,YACF;AAAA,QAEJ;AAAA,MACF;AAEA;AAAA,EACJ;AAEA,SAAO;AACT;AAEA,IAAO,2BAAQ;",
|
|
8
7
|
"names": []
|
|
9
|
-
}
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flex-development/mlly",
|
|
3
3
|
"description": "ECMAScript module utilities",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.17",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecmascript",
|
|
7
7
|
"esm",
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
"type": "module",
|
|
25
25
|
"files": [
|
|
26
26
|
"CHANGELOG.md",
|
|
27
|
-
"dist"
|
|
28
|
-
"src"
|
|
27
|
+
"dist"
|
|
29
28
|
],
|
|
30
29
|
"exports": {
|
|
31
30
|
".": "./dist/index.mjs",
|
|
@@ -85,7 +84,7 @@
|
|
|
85
84
|
"@flex-development/is-builtin": "3.1.0",
|
|
86
85
|
"@flex-development/pathe": "2.0.0",
|
|
87
86
|
"@flex-development/pkg-types": "3.0.0",
|
|
88
|
-
"@flex-development/tutils": "6.0.0-alpha.
|
|
87
|
+
"@flex-development/tutils": "6.0.0-alpha.18"
|
|
89
88
|
},
|
|
90
89
|
"devDependencies": {
|
|
91
90
|
"@arethetypeswrong/cli": "0.7.1",
|
|
@@ -117,8 +116,8 @@
|
|
|
117
116
|
"@types/prettier": "3.0.0",
|
|
118
117
|
"@types/semver": "7.5.0",
|
|
119
118
|
"@types/unist": "3.0.0",
|
|
120
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
121
|
-
"@typescript-eslint/parser": "6.
|
|
119
|
+
"@typescript-eslint/eslint-plugin": "6.3.0",
|
|
120
|
+
"@typescript-eslint/parser": "6.3.0",
|
|
122
121
|
"@vates/toggle-scripts": "1.0.0",
|
|
123
122
|
"@vitest/coverage-v8": "0.34.1",
|
|
124
123
|
"@vue/runtime-core": "3.3.4",
|
|
@@ -138,7 +137,7 @@
|
|
|
138
137
|
"cspell": "7.0.1-alpha.8",
|
|
139
138
|
"dateformat": "5.0.3",
|
|
140
139
|
"dotenv": "16.3.1",
|
|
141
|
-
"esbuild": "0.
|
|
140
|
+
"esbuild": "0.19.0",
|
|
142
141
|
"eslint": "8.46.0",
|
|
143
142
|
"eslint-config-prettier": "9.0.0",
|
|
144
143
|
"eslint-import-resolver-typescript": "3.5.5",
|
|
@@ -180,10 +179,10 @@
|
|
|
180
179
|
"unist-util-remove": "4.0.0",
|
|
181
180
|
"unist-util-source": "5.0.0",
|
|
182
181
|
"unist-util-visit": "5.0.0",
|
|
183
|
-
"vercel": "31.2.
|
|
182
|
+
"vercel": "31.2.3",
|
|
184
183
|
"version-bump-prompt": "6.1.0",
|
|
185
184
|
"vfile": "6.0.1",
|
|
186
|
-
"vite": "4.4.
|
|
185
|
+
"vite": "4.4.9",
|
|
187
186
|
"vite-tsconfig-paths": "4.2.0",
|
|
188
187
|
"vitepress": "1.0.0-beta.7",
|
|
189
188
|
"vitest": "0.34.1",
|
package/src/enums/assert-type.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Enums - AssertType
|
|
3
|
-
* @module mlly/enums/AssertType
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* `import` assertion types.
|
|
8
|
-
*
|
|
9
|
-
* ::: info
|
|
10
|
-
* It's unclear whether or not the HTML spec will require assertion types for
|
|
11
|
-
* WebAssembly modules.
|
|
12
|
-
* :::
|
|
13
|
-
*
|
|
14
|
-
* @see https://github.com/WebAssembly/esm-integration/issues/42
|
|
15
|
-
*
|
|
16
|
-
* @enum {Lowercase<string>}
|
|
17
|
-
*/
|
|
18
|
-
enum AssertType {
|
|
19
|
-
IMPLICIT = 'javascript',
|
|
20
|
-
JSON = 'json'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default AssertType
|
package/src/enums/format.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Enums - Format
|
|
3
|
-
* @module mlly/enums/Format
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Module formats.
|
|
8
|
-
*
|
|
9
|
-
* @enum {Lowercase<string>}
|
|
10
|
-
*/
|
|
11
|
-
enum Format {
|
|
12
|
-
BUILTIN = 'builtin',
|
|
13
|
-
COMMONJS = 'commonjs',
|
|
14
|
-
JSON = 'json',
|
|
15
|
-
MODULE = 'module',
|
|
16
|
-
WASM = 'wasm'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default Format
|
package/src/enums/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Entry Point - Enums
|
|
3
|
-
* @module mlly/enums
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export { default as AssertType } from './assert-type'
|
|
7
|
-
export { default as Format } from './format'
|
|
8
|
-
export { default as SpecifierKind } from './kind-specifier'
|
|
9
|
-
export { default as SpecifierSyntaxKind } from './kind-specifier-syntax'
|
|
10
|
-
export { default as StatementKind } from './kind-statement'
|
|
11
|
-
export { default as StatementSyntaxKind } from './kind-statement-syntax'
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Enums - SpecifierSyntaxKind
|
|
3
|
-
* @module mlly/enums/SpecifierSyntaxKind
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Module specifier syntax types.
|
|
8
|
-
*
|
|
9
|
-
* @enum {Lowercase<string>}
|
|
10
|
-
*/
|
|
11
|
-
enum SpecifierSyntaxKind {
|
|
12
|
-
DYNAMIC = 'dynamic',
|
|
13
|
-
STATIC = 'static'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default SpecifierSyntaxKind
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Enums - SpecifierKind
|
|
3
|
-
* @module mlly/enums/SpecifierKind
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Module specifier types.
|
|
8
|
-
*
|
|
9
|
-
* @see https://nodejs.org/api/esm.html#terminology
|
|
10
|
-
*
|
|
11
|
-
* @enum {Lowercase<string>}
|
|
12
|
-
*/
|
|
13
|
-
enum SpecifierKind {
|
|
14
|
-
ABSOLUTE = 'absolute',
|
|
15
|
-
BARE = 'bare',
|
|
16
|
-
RELATIVE = 'relative'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default SpecifierKind
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Enums - StatementSyntaxKind
|
|
3
|
-
* @module mlly/enums/StatementSyntaxKind
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* CommonJS and ESM statement syntax kinds.
|
|
8
|
-
*
|
|
9
|
-
* @enum {Lowercase<string>}
|
|
10
|
-
*/
|
|
11
|
-
enum StatementSyntaxKind {
|
|
12
|
-
DECLARATION = 'declaration',
|
|
13
|
-
DEFAULT = 'default',
|
|
14
|
-
DEFAULT_WITH_NAMED = 'default-with-named',
|
|
15
|
-
DEFAULT_WITH_NAMESPACE = 'default-with-namespace',
|
|
16
|
-
DYNAMIC = 'dynamic',
|
|
17
|
-
LIST = 'list',
|
|
18
|
-
NAMED = 'named',
|
|
19
|
-
NAMESPACE = 'namespace',
|
|
20
|
-
REQUIRE = 'require',
|
|
21
|
-
SIDE_EFFECT = 'side-effect'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default StatementSyntaxKind
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Enums - StatementKind
|
|
3
|
-
* @module mlly/enums/StatementKind
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* CommonJS and ESM statement kinds.
|
|
8
|
-
*
|
|
9
|
-
* @enum {Lowercase<string>}
|
|
10
|
-
*/
|
|
11
|
-
enum StatementKind {
|
|
12
|
-
EXPORT = 'export',
|
|
13
|
-
IMPORT = 'import',
|
|
14
|
-
REQUIRE = 'require'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default StatementKind
|
package/src/index.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Interfaces - ImportAssertions
|
|
3
|
-
* @module mlly/interfaces/ImportAssertions
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { AssertType } from '#src/enums'
|
|
7
|
-
import type { LiteralUnion } from '@flex-development/tutils'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* `import` assertions schema.
|
|
11
|
-
*
|
|
12
|
-
* @see {@linkcode AssertType}
|
|
13
|
-
* @see https://github.com/tc39/proposal-import-assertions
|
|
14
|
-
*/
|
|
15
|
-
interface ImportAssertions {
|
|
16
|
-
[key: string]: string
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Assertion type.
|
|
20
|
-
*/
|
|
21
|
-
type?: LiteralUnion<AssertType, string>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type { ImportAssertions as default }
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Interfaces - DynamicImport
|
|
3
|
-
* @module mlly/interfaces/DynamicImport
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { StatementSyntaxKind } from '#src/enums'
|
|
7
|
-
import type { EmptyString, LiteralUnion } from '@flex-development/tutils'
|
|
8
|
-
import type ImportStatement from './statement-import'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Dynamic import statement object.
|
|
12
|
-
*
|
|
13
|
-
* @see {@linkcode ImportStatement}
|
|
14
|
-
* @see {@linkcode StatementSyntaxKind}
|
|
15
|
-
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/import
|
|
16
|
-
*
|
|
17
|
-
* @extends {ImportStatement}
|
|
18
|
-
*/
|
|
19
|
-
interface DynamicImport extends ImportStatement {
|
|
20
|
-
/**
|
|
21
|
-
* Import expression.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* 'import("foo.json")'
|
|
25
|
-
* @example
|
|
26
|
-
* 'import(foo)'
|
|
27
|
-
*/
|
|
28
|
-
expression: LiteralUnion<EmptyString, string>
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Options bag.
|
|
32
|
-
*
|
|
33
|
-
* @see https://github.com/tc39/proposal-import-assertions#dynamic-import
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* '{ assert: { type: "json" } }'
|
|
37
|
-
*/
|
|
38
|
-
options: LiteralUnion<EmptyString, string>
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Statement syntax kind.
|
|
42
|
-
*/
|
|
43
|
-
syntax: StatementSyntaxKind.DYNAMIC
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type { DynamicImport as default }
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Interfaces - StaticImport
|
|
3
|
-
* @module mlly/interfaces/StaticImport
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { StatementSyntaxKind } from '#src/enums'
|
|
7
|
-
import type { EmptyString, LiteralUnion } from '@flex-development/tutils'
|
|
8
|
-
import type ImportStatement from './statement-import'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Static import statement object.
|
|
12
|
-
*
|
|
13
|
-
* @see {@linkcode ImportStatement}
|
|
14
|
-
* @see {@linkcode StatementSyntaxKind}
|
|
15
|
-
*
|
|
16
|
-
* @extends {ImportStatement}
|
|
17
|
-
*/
|
|
18
|
-
interface StaticImport extends ImportStatement {
|
|
19
|
-
/**
|
|
20
|
-
* Assertion options.
|
|
21
|
-
*
|
|
22
|
-
* @see https://github.com/tc39/proposal-import-assertions#import-statements
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* '{ type: "json" }'
|
|
26
|
-
*/
|
|
27
|
-
assertion: LiteralUnion<EmptyString, string>
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Statement syntax kind.
|
|
31
|
-
*/
|
|
32
|
-
syntax:
|
|
33
|
-
| StatementSyntaxKind.DEFAULT
|
|
34
|
-
| StatementSyntaxKind.DEFAULT_WITH_NAMED
|
|
35
|
-
| StatementSyntaxKind.DEFAULT_WITH_NAMESPACE
|
|
36
|
-
| StatementSyntaxKind.NAMED
|
|
37
|
-
| StatementSyntaxKind.NAMESPACE
|
|
38
|
-
| StatementSyntaxKind.SIDE_EFFECT
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Type-only import statement check.
|
|
42
|
-
*/
|
|
43
|
-
type: boolean
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type { StaticImport as default }
|
package/src/interfaces/index.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Interfaces
|
|
3
|
-
* @module mlly/interfaces
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export type { default as ImportAssertions } from './import-assertions'
|
|
7
|
-
export type { default as DynamicImport } from './import-dynamic'
|
|
8
|
-
export type { default as StaticImport } from './import-static'
|
|
9
|
-
export type { default as FillModuleOptions } from './options-fill-module'
|
|
10
|
-
export type { default as FindSubpathOptions } from './options-find-subpath'
|
|
11
|
-
export type { default as GetFormatOptions } from './options-get-format'
|
|
12
|
-
export type { default as GetSourceOptions } from './options-get-source'
|
|
13
|
-
export type { default as ParseModuleIdOptions } from './options-parse-module-id'
|
|
14
|
-
export type { default as ParseSubpathOptions } from './options-parse-subpath'
|
|
15
|
-
export type { default as ResolveOptions } from './options-resolve'
|
|
16
|
-
export type { default as ResolveAliasOptions } from './options-resolve-alias'
|
|
17
|
-
export type { default as ResolveModuleOptions } from './options-resolve-module'
|
|
18
|
-
export type { default as PackageScope } from './package-scope'
|
|
19
|
-
export type { default as ParsedDataUrl } from './parsed-data-url'
|
|
20
|
-
export type { default as ParsedModuleId } from './parsed-module-id'
|
|
21
|
-
export type { default as ParsedSubpath } from './parsed-subpath'
|
|
22
|
-
export type { default as Statement } from './statement'
|
|
23
|
-
export type { default as ExportStatement } from './statement-export'
|
|
24
|
-
export type { default as ImportStatement } from './statement-import'
|
|
25
|
-
export type { default as RequireStatement } from './statement-require'
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Interfaces - FillModuleOptions
|
|
3
|
-
* @module mlly/interfaces/FillModuleOptions
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { ChangeExtFn } from '#src/types'
|
|
7
|
-
import type ResolveModuleOptions from './options-resolve-module'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Options for fully specifying modules.
|
|
11
|
-
*
|
|
12
|
-
* @see {@linkcode ChangeExtFn}
|
|
13
|
-
* @see {@linkcode ResolveModuleOptions}
|
|
14
|
-
* @see https://nodejs.org/api/esm.html#mandatory-file-extensions
|
|
15
|
-
*
|
|
16
|
-
* @extends {ResolveModuleOptions}
|
|
17
|
-
*/
|
|
18
|
-
interface FillModuleOptions extends ResolveModuleOptions {
|
|
19
|
-
/**
|
|
20
|
-
* File extension to add to absolute and relative specifiers or a function
|
|
21
|
-
* that returns a file extension.
|
|
22
|
-
*/
|
|
23
|
-
ext: ChangeExtFn<string> | string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type { FillModuleOptions as default }
|