{"name":"resolve-import","version":"2.2.0","author":{"url":"https://blog.izs.me","name":"Isaac Z. Schlueter","email":"i@izs.me"},"license":"BlueOak-1.0.0","_id":"resolve-import@2.2.0","maintainers":[{"name":"isaacs","email":"i@izs.me"}],"homepage":"https://github.com/isaacs/resolve-import#readme","bugs":{"url":"https://github.com/isaacs/resolve-import/issues"},"dist":{"shasum":"39b9c0bd95350155c838b0cd10c3d0d9c3ef27db","tarball":"http://registry-npm.ywwl.com/resolve-import/download/resolve-import-2.2.0.tgz","fileCount":237,"integrity":"sha512-OCFmk2a7IOHFkqjDmlRIKk36XJkxdlhovNpWz/OZgysulKA2zrU5kivjXXYFBv6Hwx+9dpwWRY941WYi4tzEyw==","signatures":[{"sig":"MEUCIQCbefw9p6942Qy55ssSQZs7xh3OLikSMouKoHWxBBT8XwIgF2+6xwomFr/b6gGTSxjz4zHbDtYAyT8ADP02v3x6H8I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":524083,"size":52099,"noattachment":false,"key":"/resolve-import/-/resolve-import-2.2.0.tgz"},"main":"./dist/commonjs/index.min.js","tshy":{"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.min.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.min.js"}},"./raw":"./src/index.ts","./package.json":"./package.json","./resolve-import":"./src/resolve-import.ts","./get-all-conditions":"./src/get-all-conditions.ts","./is-relative-require":"./src/is-relative-require.ts","./resolve-all-exports":"./src/resolve-all-exports.ts","./resolve-all-local-imports":"./src/resolve-all-local-imports.ts","./resolve-conditional-value":"./src/resolve-conditional-value.ts","./get-all-conditional-values":"./src/get-all-conditional-values.ts","./get-conditional-values-list":"./src/get-conditional-values-list.ts"},"compiler":"tsgo","selfLink":false},"type":"module","types":"./dist/commonjs/index.d.ts","module":"./dist/esm/index.min.js","engines":{"node":"20 || >=22"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.min.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.min.js"}},"./raw":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json","./resolve-import":{"import":{"types":"./dist/esm/resolve-import.d.ts","default":"./dist/esm/resolve-import.js"},"require":{"types":"./dist/commonjs/resolve-import.d.ts","default":"./dist/commonjs/resolve-import.js"}},"./get-all-conditions":{"import":{"types":"./dist/esm/get-all-conditions.d.ts","default":"./dist/esm/get-all-conditions.js"},"require":{"types":"./dist/commonjs/get-all-conditions.d.ts","default":"./dist/commonjs/get-all-conditions.js"}},"./is-relative-require":{"import":{"types":"./dist/esm/is-relative-require.d.ts","default":"./dist/esm/is-relative-require.js"},"require":{"types":"./dist/commonjs/is-relative-require.d.ts","default":"./dist/commonjs/is-relative-require.js"}},"./resolve-all-exports":{"import":{"types":"./dist/esm/resolve-all-exports.d.ts","default":"./dist/esm/resolve-all-exports.js"},"require":{"types":"./dist/commonjs/resolve-all-exports.d.ts","default":"./dist/commonjs/resolve-all-exports.js"}},"./resolve-all-local-imports":{"import":{"types":"./dist/esm/resolve-all-local-imports.d.ts","default":"./dist/esm/resolve-all-local-imports.js"},"require":{"types":"./dist/commonjs/resolve-all-local-imports.d.ts","default":"./dist/commonjs/resolve-all-local-imports.js"}},"./resolve-conditional-value":{"import":{"types":"./dist/esm/resolve-conditional-value.d.ts","default":"./dist/esm/resolve-conditional-value.js"},"require":{"types":"./dist/commonjs/resolve-conditional-value.d.ts","default":"./dist/commonjs/resolve-conditional-value.js"}},"./get-all-conditional-values":{"import":{"types":"./dist/esm/get-all-conditional-values.d.ts","default":"./dist/esm/get-all-conditional-values.js"},"require":{"types":"./dist/commonjs/get-all-conditional-values.d.ts","default":"./dist/commonjs/get-all-conditional-values.js"}},"./get-conditional-values-list":{"import":{"types":"./dist/esm/get-conditional-values-list.d.ts","default":"./dist/esm/get-conditional-values-list.js"},"require":{"types":"./dist/commonjs/get-conditional-values-list.d.ts","default":"./dist/commonjs/get-conditional-values-list.js"}}},"funding":{"url":"https://github.com/sponsors/isaacs"},"gitHead":"76cf3c19b1287de0c49c6814b7db2f965dd6a8d1","scripts":{"snap":"tap","test":"tap","format":"prettier --write . --loglevel warn","prepare":"tshy","presnap":"npm run prepare","pretest":"npm run prepare","typedoc":"typedoc","preversion":"npm test","postprepare":"bash scripts/build.sh","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"repository":{"url":"git://github.com/isaacs/resolve-import.git","type":"git"},"_npmVersion":"11.6.2","description":"Look up the file that an `import()` statement will resolve to, possibly relative to a given parentURL","directories":{},"_nodeVersion":"24.11.1","dependencies":{"glob":"^13.0.0","walk-up-path":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^21.5.1","tshy":"^3.3.1","esbuild":"^0.27.3","typedoc":"^0.28.17","prettier":"^3.6.2","@types/node":"^25.2.3"},"_npmOperationalInternal":{"tmp":"tmp/resolve-import_2.2.0_1771441594598_0.6629381138207842","host":"s3://npm-registry-packages-npm-production"},"readme":"# resolve-import\n\nLook up the file that an `import()` statement will resolve to,\nfor use in node esm loaders.\n\nReturns a `file://` URL object for file resolutions, or the\nbuiltin module ID string for node builtins.\n\n## USAGE\n\n```js\nimport { resolveImport } from 'resolve-import'\n// or: const { resolveImport } = require('resolve-import')\n\n// sync versions provided as well\nimport { resolveImportSync } from 'resolve-import'\n\n// resolving a full file URL just returns it\nconsole.log(await resolveImport(new URL('file:///blah/foo.js')))\n\n// same result in sync mode\nconsole.log(resolveImportSync(new URL('file:///blah/foo.js')))\n\n// resolving a node built in returns the string\nconsole.log(await resolveImport('node:fs')) // 'node:fs'\n\n// resolving an absolute full path just file-url-ifies it\nconsole.log(await resolveImport('/a/b/c.js')) // URL(file:///a/b/c.js)\n\n// resolving a relative path resolves it from the parent module\n// URL(file:///path/to/x.js)\nconsole.log(await resolveImport('./x.js', '/path/to/y.js'))\n\n// packages resolved according to their exports, main, etc.\n// eg: URL(file:///path/node_modules/pkg/dist/mjs/index.js)\nconsole.log(await resolveImport('pkg', '/path/to/y.js'))\n```\n\nTo get very minified versions of just the top level\n`resolveImport` or `resolveImportSync` methods, load them like\nthis:\n\n```ts\n// minified tree-shaken bundle, just the async version\nimport { resolveImport } from 'resolve-import/resolve-import-async'\n\n// minified tree-shaken bundle, just the sync version\nimport { resolveImportSync } from 'resolve-import/resolve-import-sync'\n```\n\n\n## API\n\nThese functions are all exported on the main module, as well as\nbeing available on `resolve-import/{hyphen-name}`, for example:\n\n```js\nimport {\n  resolveAllExports,\n  resolveAllExportsSync,\n} from 'resolve-import/resolve-all-exports'\n```\n\n### Interface `ResolveImportOpts`\n\n- `conditions: string[]` The list of conditions to match on.\n  `'default'` is always accepted. Defaults to `['import', 'node']`.\n\n### resolveImport, resolveImportSync\n\n```ts\nresolveImport(\n  url: string | URL,\n  parentURL?: string | URL,\n  options?: ResolveImportOpts):\n    Promise<string | URL>\n\nresolveImportSync(\n  url: string | URL,\n  parentURL?: string | URL,\n  options?: ResolveImportOpts):\n    string | URL\n```\n\n- `url` The string or file URL object being imported.\n- `parentURL` The string or file URL object that the import is\n  coming from.\n- `options` A ResolveImportOpts object (optional)\n\nReturns the string provided for node builtins, like `'fs'` or\n`'node:path'`.\n\nOtherwise, resolves to a `file://` URL object corresponding to\nthe file that will be imported.\n\nRaises roughly the same errors that `import()` will raise if the\nlookup fails. For example, if a package is not found, if a\nsubpath is not exported, etc.\n\n### resolveAllExports, resolveAllExportsSync\n\n```ts\nresolveAllExports(\n  packageJsonPath: string | URL,\n  options: ResolveImportOpts):\n    Promise<Record<string, string | URL>>\n\nresolveAllExportsSync(\n  packageJsonPath: string | URL,\n  options: ResolveImportOpts):\n    Record<string, string | URL>\n```\n\nGiven a `package.json` path or file URL, resolve all valid\nexports from that package.\n\nIf the pattern contains a `*` in both the pattern and the target,\nthen it will search for all possible files that could match the\npattern, and expand them appropriately in the returned object.\n\nIn the case where a `*` exists in the pattern, but does not exist\nin the target, no expansion can be done, because _any_ string\nthere would resolve to the same file. In that case, the `*` is\nleft in the pattern.\n\nIf the target is a node built-in module, it will be a string.\nOtherwise, it will be a `file://` URL object.\n\nAny exports that fail to load (ie, if the target is invalid, the\nfile does not exist, etc.) will be omitted from the returned\nobject.\n\n### resolveAllLocalImports, resolveAllLocalImportsSync\n\n```ts\nresolveAllLocalImports(\n  packageJsonPath: string | URL,\n  options: ResolveImportOpts):\n    Promise<Record<string, string | URL>>\n\nresolveAllLocalImportsSync(\n  packageJsonPath: string | URL,\n  options: ResolveImportOpts):\n    Record<string, string | URL>\n```\n\nSimilar to `resolveAllExports`, but this resolves the entries in\nthe package.json's `imports` object.\n\n### isRelativeRequire\n\n```ts\nisRelativeRequire(specifier: string): boolean\n```\n\nSimple utility function that returns true if the import or\nrequire specifier starts with `./` or `../` (or `.\\` or `..\\` on\nWindows).\n\n### getAllConditions\n\n```ts\ngetAllConditions(\n  importsExports: Imports | Exports\n): string[]\n```\n\nGiven an `exports` or `imports` value from a package, return the\nlist of conditions that it is sensitive to.\n\n`default` is not included in the returned list, since that's\nalways effectively relevant.\n\nNote that a condition being returned by this method does not mean\nthat the export/import object actually has a _target_ for that\ncondition, since it may map to `null`, be nested under another\ncondition, etc. But it does potentially have some kind of\nconditional behavior for all the conditions returned.\n\nOrdering of returned conditions is arbitrary, and does not imply\nprecedence or object shape.\n\n### resolveConditionalValue\n\n```ts\nresolveConditionalValue(\n  cond: ConditionalValue,\n  options: ResolveImportOpts): string | null\n```\n\nGiven an entry from an `imports` or `exports` object, resolve the\nconditional value based on the `conditions` list in the provided\n`options` object. By default, resolves with the conditions\n`['import', 'node']`. `'default'` is always allowed (except if you pass the\nnegative condition `'!default'`).\n\n### getAllConditionalValues\n\n```ts\ngetAllConditionalValues(\n  importsExports: Imports | Exports\n): string[]\n```\n\nGiven an `exports` or `imports` value from a package, return the\nlist of all possible conditional values that it might potentially\nresolve to, for any possible set of import conditions.\n\nFilters out cases that are unreachable, such as conditions that\nappear after a `default` value, or after a set of conditions that\nwould have been satisfied previously.\n\nFor example:\n\n```json\n{\n  \"import\": { \"node\": \"./x.js\" },\n  \"node\": { \"import\": { \"blah\": \"./y.js\" } }\n}\n```\n\nWill return `['./x.js']`, omitting the unreachable `'./y.js'`,\nbecause the conditions ['import','node','blah'] would have been\nsatisfied by the earlier condition.\n\nNote that this does _not_ mean that the target actually can be\nimported, as it may not exist, be an incorrect module type, etc.\n\nStar values are not expanded. For that, use `resolveAllExports`\nor `resolveAllLocalImports`.\n\n### getConditionalValuesList\n\n```ts\ngetConditionalValuesList(\n  importsExports: Imports | Exports\n): [string, Set<string>, string | null][]\n```\n\nGiven an `exports` or `imports` value from a package, return the\nlist of all possible conditional values that it might potentially\nresolve to, for any possible set of import conditions, along with\nthe `Set<string>` of conditions, any superset of which will\nresult in the condition.\n\nThe first entry in the returned list is the submodule path, or\n`'.'` if the value provided did not have submodule paths.\n\nThe list includes null results, since while these are not a valid\nresolution per se, they do _prevent_ valid resolutions that match\nthe same conditions.\n","publish_time":1771441594801,"_cnpm_publish_time":1771441594801,"dist-tags":{"latest":"2.4.2"}}