{"_id":"esm-resolve","_rev":"3913939","name":"esm-resolve","description":"Resolves ESM imports in Node","dist-tags":{"latest":"1.0.11"},"maintainers":[{"name":"samthor","email":""}],"time":{"modified":"2025-09-01T01:16:32.000Z","created":"2021-02-07T05:33:15.198Z","1.0.11":"2024-04-17T23:39:38.194Z","1.0.10":"2024-04-17T23:38:01.524Z","1.0.9":"2024-03-15T22:33:38.398Z","1.0.8":"2022-05-22T06:20:41.921Z","1.0.7":"2022-05-22T06:03:21.424Z","1.0.6":"2021-12-03T22:30:24.037Z","1.0.5":"2021-12-01T21:12:31.336Z","1.0.4":"2021-05-04T06:21:41.972Z","1.0.3":"2021-05-02T23:19:38.355Z","1.0.2":"2021-02-08T08:02:05.227Z","1.0.1":"2021-02-07T05:35:28.110Z","1.0.0":"2021-02-07T05:33:15.198Z"},"users":{},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"versions":{"1.0.11":{"name":"esm-resolve","version":"1.0.11","description":"Resolves ESM imports in Node","main":"bundle.js","exports":{".":{"node":{"import":"./bundle.js","require":"./bundle.cjs","types":"./index.d.ts"}}},"type":"module","author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2.0","devDependencies":{"@types/node":"^20.12.7","esbuild":"^0.14.54","tsx":"^4.7.1"},"types":"./index.d.ts","scripts":{"test":"npx tsx test/resolve.ts"},"bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.11","_integrity":"sha512-LxF0wfUQm3ldUDHkkV2MIbvvY0TgzIpJ420jHSV1Dm+IlplBEWiJTKWM61GtxUfvjV6iD4OtTYFGAGM2uuIUWg==","_resolved":"/private/var/folders/ky/s3zbsg1d5_q27f30kvr6sxyc0000gp/T/387772ec8eef85bd2c3042cdb287acc3/esm-resolve-1.0.11.tgz","_from":"file:esm-resolve-1.0.11.tgz","_nodeVersion":"21.7.3","_npmVersion":"10.5.0","dist":{"shasum":"93f0021d5c06fb9bed77fcd010eb9de54538e1db","size":12198,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.11.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.11.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.11_1713397178024_0.6473358328887115"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-04-17T23:39:38.194Z","publish_time":1713397178194,"_source_registry_name":"default","_cnpm_publish_time":1713397178194},"1.0.10":{"name":"esm-resolve","version":"1.0.10","description":"Resolves ESM imports in Node","main":"bundle.js","exports":{".":{"node":{"import":"./bundle.js","require":"./bundle.cjs","types":"./index.d.ts"}}},"type":"module","author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2.0","devDependencies":{"@types/node":"^20.12.7","esbuild":"^0.14.54","tsx":"^4.7.1"},"types":"./index.d.ts","scripts":{"test":"npx tsx test/resolve.ts"},"bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.10","_integrity":"sha512-gEuZxEND2BTt4qiQjuNrvuAimkW4bZp0Lxxn1551/TnGHe32UyqKWhSM/ZE/pq5xJww/M3/5mL44JngAdIFBXA==","_resolved":"/private/var/folders/ky/s3zbsg1d5_q27f30kvr6sxyc0000gp/T/de91d43fbc76fc7f80eb150adf6d11bf/esm-resolve-1.0.10.tgz","_from":"file:esm-resolve-1.0.10.tgz","_nodeVersion":"21.7.3","_npmVersion":"10.5.0","dist":{"shasum":"3efe8e2b594a3bf9a1792ea6a2529d250ecd6bc8","size":8889,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.10.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.10.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.10_1713397081377_0.3304501408796192"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-04-17T23:38:01.524Z","publish_time":1713397081524,"_source_registry_name":"default","_cnpm_publish_time":1713397081524},"1.0.9":{"name":"esm-resolve","version":"1.0.9","description":"Resolves ESM imports in Node","main":"bundle.js","exports":{".":{"node":{"import":"./bundle.js","require":"./bundle.cjs"}}},"type":"module","author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2.0","devDependencies":{"@types/node":"^20.11.28","esbuild":"^0.14.1","tsx":"^4.7.1"},"types":"index.d.ts","scripts":{"test":"npx tsx test/resolve.ts"},"bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.9","_integrity":"sha512-qVENG+4e2s5HO/TMV9LvjpOVNW4HlaZn98q7h0y9R524M1chXNAwrn2bKx+wQs9Qryb22qX8P0rQ5N3e3Udq/w==","_resolved":"/private/var/folders/2w/x4lk1hdj26g01xwtj7w03fx40000gp/T/2a8c2b14a1e9a58622966d39efb568bc/esm-resolve-1.0.9.tgz","_from":"file:esm-resolve-1.0.9.tgz","_nodeVersion":"21.7.0","_npmVersion":"10.5.0","dist":{"shasum":"8d454de9ccef92799797811b0b9b952f199ecfdc","size":11927,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.9.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.9.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.9_1710542018219_0.09384975032407716"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-03-15T22:33:38.398Z","publish_time":1710542018398,"_source_registry_name":"default","_cnpm_publish_time":1710542018398},"1.0.8":{"name":"esm-resolve","version":"1.0.8","description":"Resolves ESM imports in JS","main":"index.js","exports":{".":{"node":{"import":"./index.js","require":"./bundle.cjs"}}},"type":"module","scripts":{"test":"ava","prepublishOnly":"esbuild index.js --bundle --platform=node --target=node12 --outfile=bundle.cjs"},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2","devDependencies":{"@types/node":"^14.14.25","ava":"^3.15.0","esbuild":"^0.14.1"},"types":"index.d.ts","gitHead":"c8e9155821bba6e54c8cc98c7828e5d622df54cf","bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.8","_nodeVersion":"18.0.0","_npmVersion":"8.6.0","dist":{"shasum":"1a8121a85a914863463cf05883492e0a55b872d4","size":11665,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.8.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.8.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.8_1653200441743_0.03421847404010414"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-22T06:20:45.859Z","publish_time":1653200441921,"_cnpm_publish_time":1653200441921},"1.0.7":{"name":"esm-resolve","version":"1.0.7","description":"Resolves ESM imports in JS","main":"index.js","exports":{".":{"node":{"import":"./index.js","require":"./bundle.cjs"}}},"type":"module","scripts":{"test":"ava","prepublishOnly":"esbuild index.js --bundle --platform=node --target=es2015 --outfile=bundle.cjs"},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2","devDependencies":{"@types/node":"^14.14.25","ava":"^3.15.0","esbuild":"^0.14.1"},"types":"index.d.ts","gitHead":"34dd36b20532f749da8f52410e8bd361ef08c863","bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.7","_nodeVersion":"18.0.0","_npmVersion":"8.6.0","dist":{"shasum":"0e91abc2d551b05d3bdaadc91c0727df71780659","size":11439,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.7.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.7.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.7_1653199401269_0.5527239370317423"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-22T06:03:25.886Z","publish_time":1653199401424,"_cnpm_publish_time":1653199401424},"1.0.6":{"name":"esm-resolve","version":"1.0.6","description":"Resolves ESM imports in JS","main":"index.js","exports":{".":{"import":"./index.js","require":"./bundle.cjs"}},"type":"module","scripts":{"test":"ava","prepublishOnly":"esbuild index.js --bundle --platform=node --target=es2015 --outfile=bundle.cjs"},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2","devDependencies":{"@types/node":"^14.14.25","ava":"^3.15.0","esbuild":"^0.14.1"},"types":"index.d.ts","gitHead":"b8a124c49720c0b09bb846db6c1d90449c3f93f6","bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.6","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"shasum":"f5c0927ca3cd98bd17bc871a869283621a3ad3d9","size":11299,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.6.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.6_1638570623892_0.4629652554518786"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-26T22:30:06.599Z","publish_time":1638570624037,"_cnpm_publish_time":1638570624037},"1.0.5":{"name":"esm-resolve","version":"1.0.5","description":"Resolves ESM imports in JS","main":"index.js","exports":{".":{"import":"./index.js","require":"./bundle.cjs"}},"type":"module","scripts":{"test":"ava","prepublishOnly":"rollup -o bundle.cjs -f cjs index.js --output.exports=named"},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2","devDependencies":{"@types/node":"^14.14.25","ava":"^3.15.0","rollup":"^2.60.2"},"types":"index.d.ts","gitHead":"07fee9a403298f057ef93a31279ea5ce3c7ba032","bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.5","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"shasum":"a1b39cf6e53c11e388ba61da6a999b46b2cd7dfc","size":10289,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.5.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.5_1638393151171_0.16678201294770756"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-26T22:30:05.517Z","publish_time":1638393151336,"_cnpm_publish_time":1638393151336},"1.0.4":{"name":"esm-resolve","version":"1.0.4","description":"Resolves ESM imports in JS","main":"index.js","exports":{".":{"import":"./index.js"}},"type":"module","scripts":{"test":"ava"},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2","devDependencies":{"@types/node":"^14.14.25","ava":"^3.15.0"},"types":"index.d.ts","gitHead":"e1ddcba2a66c22b2a6577e3312a7b187bbdd58d3","bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.4","_nodeVersion":"15.14.0","_npmVersion":"7.7.6","dist":{"shasum":"682cdca5c1d20de9a37842554bf5dc3a31f4e2b8","size":9582,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.4.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.4_1620109301849_0.964932980450836"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-26T22:30:04.624Z","publish_time":1620109301972,"_cnpm_publish_time":1620109301972},"1.0.3":{"name":"esm-resolve","version":"1.0.3","description":"Resolves ESM imports in JS","main":"index.js","exports":{".":{"import":"./index.js"}},"type":"module","scripts":{"test":"ava"},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2","devDependencies":{"@types/node":"^14.14.25","ava":"^3.15.0"},"types":"index.d.ts","gitHead":"1cf3d7bf8b55f506c63aed9a7f68d91227cc1c10","bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.3","_nodeVersion":"15.14.0","_npmVersion":"7.7.6","dist":{"shasum":"6e823be2b8ad9f17d0b32a6bbfccc278e89eaf53","size":9488,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.3.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.3_1619997578204_0.3347279233962204"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-26T22:30:03.754Z","publish_time":1619997578355,"_cnpm_publish_time":1619997578355},"1.0.2":{"name":"esm-resolve","version":"1.0.2","description":"Resolves ESM imports in JS","main":"index.js","exports":{".":{"import":"./index.js"}},"type":"module","scripts":{"test":"ava"},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/samthor/esm-resolve.git"},"license":"Apache-2","devDependencies":{"@types/node":"^14.14.25","ava":"^3.15.0"},"types":"index.d.ts","gitHead":"3306862562d5f6a0f85c535e6cb21a3cd6beaaac","bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"homepage":"https://github.com/samthor/esm-resolve#readme","_id":"esm-resolve@1.0.2","_nodeVersion":"15.8.0","_npmVersion":"7.5.0","dist":{"shasum":"3a8b5d415f859eaafb043ac468e9c061c97e96ea","size":9484,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.2.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.2_1612771324993_0.5766150845093758"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-26T22:30:02.862Z","publish_time":1612771325227,"_cnpm_publish_time":1612771325227},"1.0.1":{"name":"esm-resolve","version":"1.0.1","description":"Resolves ESM imports in JS","main":"index.js","exports":{".":{"import":"./index.js"}},"type":"module","scripts":{"test":"ava"},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"license":"Apache-2.0","devDependencies":{"@types/node":"^14.14.25","ava":"^3.15.0"},"types":"index.d.ts","gitHead":"9b121be712988659c6c3d471f8e72fad11949f6b","_id":"esm-resolve@1.0.1","_nodeVersion":"15.8.0","_npmVersion":"7.5.0","dist":{"shasum":"7e12c649a0e27471292806e1c64041f2a177bfbf","size":9303,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.1.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.1_1612676127966_0.745211112934747"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-26T22:30:01.953Z","publish_time":1612676128110,"_cnpm_publish_time":1612676128110},"1.0.0":{"name":"esm-resolve","version":"1.0.0","description":"Resolves ESM imports in JS","main":"index.js","exports":{".":{"import":"./index.js"}},"type":"module","scripts":{"test":"ava"},"author":{"name":"Sam Thorogood","email":"sam.thorogood@gmail.com"},"license":"Apache-2.0","devDependencies":{"@types/node":"^14.14.25","ava":"^3.15.0"},"types":"index.d.ts","gitHead":"a6a6594963efd49b0b84b96b4718eac5e0281cf8","_id":"esm-resolve@1.0.0","_nodeVersion":"15.8.0","_npmVersion":"7.5.0","dist":{"shasum":"6bcae925181e87ea5dba5eade42b421123f485c5","size":9103,"noattachment":false,"key":"/esm-resolve/-/esm-resolve-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/esm-resolve/download/esm-resolve-1.0.0.tgz"},"_npmUser":{"name":"samthor","email":"sam.thorogood@gmail.com"},"directories":{},"maintainers":[{"name":"samthor","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-resolve_1.0.0_1612675995064_0.3553174494299083"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-26T22:30:01.044Z","publish_time":1612675995198,"_cnpm_publish_time":1612675995198}},"readme":"[![Tests](https://github.com/samthor/esm-resolve/workflows/Tests/badge.svg)](https://github.com/samthor/esm-resolve/actions)\n\nSync ESM import resolver for Node written in pure JS.\nThis is written to be part of an [ESM dev server](https://github.com/samthor/dhost) or build process.\nIt is permissive by default, allowing some cases which would normally be failures.\n\n⚠️ This resolver was writtem before [`import.meta.resolve()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve) was widely available&mdash;it may work for you without adding _yet another_ dependency.\nHowever, \"esm-resolve\" is a bit more permissive.\n\n## Usage\n\nInstall and import \"esm-resolve\" via your favorite package manager.\nCreate a resolver based on the importing file.\n\n```js\nimport buildResolver from 'esm-resolve';\nimport { buildResolver } from 'esm-resolve'; // also works\n\nconst r = buildResolver('./lib/file.js');\n\nr('./relative'); // './relative.js'\nr('foo-test-package-name'); // '../node_modules/foo-test-package-name/index.js'\n```\n\nResolution logic is actually the same for any files in the same directory, so resolver objects can be reused (and they have a small bit of cache).\n\nThe resolved path is returned relative _to the importer_ of that file, not your process' current directory.\nYou can set the `resolveToAbsolute` option if you'd always like an absolute path.\n\n## Notes\n\nThis implements modern Node resolution, i.e., [subpath exports](https://nodejs.org/api/packages.html#packages_subpath_exports), [subpath imports](https://nodejs.org/api/packages.html#subpath-imports) and [conditional exports](https://nodejs.org/api/packages.html#packages_conditional_exports).\nBy default, it will rewrite to the \"browser\", \"import\" or \"default\" keys (not \"node\", as it's expected that you'll use this for browser builds).\n\nIt fails gracefully in many ways, including falling back to real paths if exports aren't defined.\nIt will also remove imports that point purely to \".d.ts\" files (you don't need to create [peer JS](https://whistlr.info/2021/check-js-with-ts/#import-your-types)).\n\nYou can [configure all these options](./types/external.d.ts) via the resolver's second argument, e.g.:\n\n```js\n// Resolves for Node, and allows .mjs files.\nconst r = buildResolver('./lib/file.js', {\n  constraints: 'node',\n  matchNakedMjs: true,\n});\n\n// If there's a file \"foo.mjs\", this will now work:\nr('./foo'); // './foo.mjs'\n\n// Or if we're importing package with a node constraint:\nr('node-only'); // '../node-modules/node-only/build-for-node.js'\n```\n","_attachments":{},"homepage":"https://github.com/samthor/esm-resolve#readme","bugs":{"url":"https://github.com/samthor/esm-resolve/issues"},"license":"Apache-2.0"}