{"_id":"@jspm/resolve","_rev":"131418","name":"@jspm/resolve","description":"jspm 2.0 resolver","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"guybedford","email":"guybedford@gmail.com"}],"time":{"modified":"2021-06-03T11:11:25.000Z","created":"2019-04-23T23:04:21.238Z","1.0.0":"2019-04-23T23:04:21.238Z"},"users":{},"author":{"name":"Guy Bedford"},"repository":{"type":"git","url":"git://git@github.com/jspm/resolve.git"},"versions":{"1.0.0":{"name":"@jspm/resolve","version":"1.0.0","description":"jspm 2.0 resolver","main":"resolve.js","scripts":{"test":"jspm test/test.js"},"repository":{"type":"git","url":"git://git@github.com/jspm/resolve.git"},"keywords":["jspm","resolver"],"author":{"name":"Guy Bedford"},"license":"Apache-2.0","bugs":{"url":"https://github.com/jspm/resolve/issues"},"homepage":"https://github.com/jspm/resolve#readme","devDependencies":{"@jspm/core":"^1.0.0","mocha":"^4.1.0"},"type":"commonjs","gitHead":"d8c88aeaa6febca1e3573e7b892be938752dddb1","_id":"@jspm/resolve@1.0.0","_nodeVersion":"11.14.0","_npmVersion":"6.7.0","dist":{"shasum":"211b138bfa751202d5c9f62084451026bf71ff55","size":13180,"noattachment":false,"key":"/@jspm/resolve/-/@jspm/resolve-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@jspm/resolve/download/@jspm/resolve-1.0.0.tgz"},"maintainers":[{"name":"guybedford","email":"guybedford@gmail.com"}],"_npmUser":{"name":"guybedford","email":"guybedford@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/resolve_1.0.0_1556060661102_0.09093605023800366"},"_hasShrinkwrap":false,"publish_time":1556060661238,"_cnpm_publish_time":1556060661238}},"readme":"# JSPM 2 Resolver\n\nThis implements the `jspm_packages/[registry]/[name]@[version]/` module resolution lookup while checking the rules defined in `package.json` and `json.json` for jspm.\n\nFor the full detailed specification of jspm resolution, see the [jspm 2.0 resolver specification](https://github.com/jspm/jspm-resolve/blob/master/resolver-spec.md).\n\nThe resolver is fully backwards-compatible with the Node.js --experimental-modules resolver, which in turn is fully-backwards compatible with the traditional CommonJS resolver.\n\n### Usage\n\nInstall with:\n\n```\nnpm install @jspm/resolve\n```\n\nThen basic usage is:\n\n```js\nimport jspmResolve from '@jspm/resolve';\n\nconst { resolved, format } = await jspmResolve('specifier', '/path/to/parent/module.js');\n```\n\nThe jspm resolver works on file paths that are `/`-separated. It will still correctly handle the URL normalization rules of the ES Module resolver though, but works on file paths for convenience and performance.\n\nFormat, like the Node.js --experimental-modules resolver, is one of `commonjs`, `module`, `json`, `builtin`, `addon` or `unknown` for asset files.\n\n### API\n\n#### Cache\n\nA cache object can be passed to the resolution function that will maintain all the lookup state for fast resolution:\n\n```js\nconst cache = {};\njspmResolve(name, parent, { cache });\n```\n\n#### Environment\n\nA custom environment can be provided to `jspmResolve`, representing the conditional paths to take in the resolver.\n\nThe default environment is the Node.js development environment:\n\n```js\n{\n  browser: false,\n  node: true,\n  production: false,\n  dev: true,\n  'react-native': false,\n  electron: false,\n  deno: false,\n  default: true\n}\n```\n\nSo a browser production resolution can be made with eg:\n\n```js\njspmResolve(name, parent, {\n  env: {\n    browser: true,\n    production: true\n  }\n});\n```\n\nThe `browser` main and map will then be respected, as well as any custom production mappings.\n\n#### CommonJS Resolve\n\nBy default the jspm resolver assumes resolution is coming from an ES module context.\n\nCommonJS modules in Node.js always load all dependencies as CommonJS and this can also be supported in the jspm resolve options by passing the `cjsResolve: true` option.\n\nThis then implements automatic file extension searching as well as always loading the CommonJS format if not an addon or json path.\n\n#### Synchronous Resolution\n\n`jspmResolve.sync` can be used to perform synchronous resolution, with an otherwise identical API.\n\n#### Loader\n\nA `loader.mjs` file is provided which supports the Node.js `--experimental-modules` loader API:\n\n```\nnode --experimental-modules --loader @jspm/resolve/loader.mjs x.js\n```\n\nThis applies the jspm resolution to Node.js.\n\n### License\n\nApache 2.0","_attachments":{},"homepage":"https://github.com/jspm/resolve#readme","bugs":{"url":"https://github.com/jspm/resolve/issues"},"license":"Apache-2.0"}