{"_id":"rollup-utils","_rev":"7-baf7e9400120bdd2a13806537548ae19","name":"rollup-utils","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.1":{"name":"rollup-utils","version":"0.0.1","keywords":["rollup","plugin","utils"],"author":{"name":"Rich Harris","email":"richard.a.harris@gmail.com"},"license":"MIT","_id":"rollup-utils@0.0.1","maintainers":[{"name":"zmjs","email":"zhiyuanzmj@gmail.com"}],"homepage":"https://github.com/zhiyuanzmj/rollup-utils#readme","bugs":{"url":"https://github.com/zhiyuanzmj/rollup-utils/issues"},"ava":{"files":["!**/fixtures/**","!**/helpers/**","!**/recipes/**","!**/types.ts"],"require":["ts-node/register"],"extensions":["ts"],"workerThreads":false},"nyc":{"extension":[".js",".ts"]},"dist":{"shasum":"18277ab235276fb378f123670755e4d3c7c0120d","tarball":"https://registry.npmjs.org/rollup-utils/-/rollup-utils-0.0.1.tgz","fileCount":6,"integrity":"sha512-+aXa+q+uUN+jv+X408kTdUAtVHoAKmocrRXkxgcFny+8+db40L7rIWkxtL9g3kljZqA0TE1TlZtK/agDJNeAEw==","signatures":[{"sig":"MEUCIQDpiWsQDuK/Z9XIGHl5/P0avFUU2ChO88W8ssQrvFwgSgIgb22I8Z6t8LEJH4v4ySpLrQZWHxJh6SvGuQqwndP9J6M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":42376},"main":"./dist/cjs/index.js","type":"commonjs","_from":"file:rollup-utils-0.0.1.tgz","types":"./types/index.d.ts","module":"./dist/es/index.js","engines":{"node":">=14.0.0"},"exports":{"types":"./types/index.d.ts","import":"./dist/es/index.js","default":"./dist/cjs/index.js"},"scripts":{"test":"ava","build":"rollup -c","ci:lint":"pnpm build && pnpm lint","ci:test":"pnpm test -- --verbose","pretest":"pnpm build --sourcemap","test:ts":"tsc --noEmit","prebuild":"del-cli dist","prerelease":"pnpm build","ci:coverage":"nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}"},"_npmUser":{"name":"zmjs","email":"zhiyuanzmj@gmail.com"},"_resolved":"/private/var/folders/25/34_3hk_j1055wx930zmg8lkc0000gn/T/f142995f3f47b6fd95830a757b45e4aa/rollup-utils-0.0.1.tgz","_integrity":"sha512-+aXa+q+uUN+jv+X408kTdUAtVHoAKmocrRXkxgcFny+8+db40L7rIWkxtL9g3kljZqA0TE1TlZtK/agDJNeAEw==","repository":{"url":"git+https://github.com/zhiyuanzmj/rollup-utils.git","type":"git"},"_npmVersion":"10.8.2","description":"A set of utility functions commonly used by Rollup plugins","directories":{},"_nodeVersion":"20.17.0","dependencies":{"pathe":"^2.0.2","picomatch":"^4.0.2","@types/estree":"^1.0.0","estree-walker":"^2.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^6.2.0","acorn":"^8.8.0","tslib":"^2.8.1","rollup":"^4.0.0-24","del-cli":"^6.0.0","ts-node":"^10.9.2","typescript":"^4.8.3","@types/node":"^14.18.30","@types/picomatch":"^2.3.0","@rollup/plugin-commonjs":"^23.0.0","@rollup/plugin-typescript":"^9.0.1","@rollup/plugin-node-resolve":"^15.0.0"},"peerDependencies":{"rollup":"^1.20.0||^2.0.0||^3.0.0||^4.0.0"},"peerDependenciesMeta":{"rollup":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/rollup-utils_0.0.1_1737212130779_0.7218912538206423","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"rollup-utils","version":"0.0.2","keywords":["rollup","plugin","utils"],"author":{"name":"Rich Harris","email":"richard.a.harris@gmail.com"},"license":"MIT","_id":"rollup-utils@0.0.2","maintainers":[{"name":"zmjs","email":"zhiyuanzmj@gmail.com"}],"homepage":"https://github.com/zhiyuanzmj/rollup-utils#readme","bugs":{"url":"https://github.com/zhiyuanzmj/rollup-utils/issues"},"ava":{"files":["!**/fixtures/**","!**/helpers/**","!**/recipes/**","!**/types.ts"],"require":["ts-node/register"],"extensions":["ts"],"workerThreads":false},"nyc":{"extension":[".js",".ts"]},"dist":{"shasum":"72a73b9119dac7274189e5ef27f0f573e56d8b6b","tarball":"https://registry.npmjs.org/rollup-utils/-/rollup-utils-0.0.2.tgz","fileCount":6,"integrity":"sha512-AG1m8fwwkm20WELaXubxgs8ir1gEN7sv+1FfFyEPJA8HtPjL0JndzpLIVzbXyQ5meBfWfv8OnouZ9AC+OsNP+A==","signatures":[{"sig":"MEUCIAa4Z/AQa9AsrrSXmmyNC286NbUuFIBIxSC35QDTddRPAiEArwdQNU4aDAFM7MIX1PQ59RTMqNwyh5ilCtnWbwS2qyg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":41948},"main":"./dist/cjs/index.js","type":"commonjs","_from":"file:rollup-utils-0.0.2.tgz","types":"./types/index.d.ts","module":"./dist/es/index.js","engines":{"node":">=14.0.0"},"exports":{"types":"./types/index.d.ts","import":"./dist/es/index.js","default":"./dist/cjs/index.js"},"scripts":{"test":"ava","build":"rollup -c","ci:lint":"pnpm build && pnpm lint","ci:test":"pnpm test -- --verbose","pretest":"pnpm build --sourcemap","test:ts":"tsc --noEmit","prebuild":"del-cli dist","prerelease":"pnpm build","ci:coverage":"nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}"},"_npmUser":{"name":"zmjs","email":"zhiyuanzmj@gmail.com"},"_resolved":"/private/var/folders/25/34_3hk_j1055wx930zmg8lkc0000gn/T/06d0db41da5abce79b681a7f061f52d9/rollup-utils-0.0.2.tgz","_integrity":"sha512-AG1m8fwwkm20WELaXubxgs8ir1gEN7sv+1FfFyEPJA8HtPjL0JndzpLIVzbXyQ5meBfWfv8OnouZ9AC+OsNP+A==","repository":{"url":"git+https://github.com/zhiyuanzmj/rollup-utils.git","type":"git"},"_npmVersion":"10.8.2","description":"A set of utility functions commonly used by Rollup plugins","directories":{},"_nodeVersion":"20.17.0","dependencies":{"pathe":"^2.0.2","picomatch":"^4.0.2","@types/estree":"^1.0.0","estree-walker":"^2.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^6.2.0","acorn":"^8.8.0","tslib":"^2.8.1","rollup":"^4.0.0-24","del-cli":"^6.0.0","ts-node":"^10.9.2","typescript":"^4.8.3","@types/node":"^14.18.30","@types/picomatch":"^2.3.0","@rollup/plugin-commonjs":"^23.0.0","@rollup/plugin-typescript":"^9.0.1","@rollup/plugin-node-resolve":"^15.0.0"},"peerDependencies":{"rollup":"^1.20.0||^2.0.0||^3.0.0||^4.0.0"},"peerDependenciesMeta":{"rollup":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/rollup-utils_0.0.2_1737372313877_0.0138216430418443","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"rollup-utils","version":"0.0.3","keywords":["rollup","plugin","utils"],"author":{"name":"Rich Harris","email":"richard.a.harris@gmail.com"},"license":"MIT","_id":"rollup-utils@0.0.3","maintainers":[{"name":"zmjs","email":"zhiyuanzmj@gmail.com"}],"homepage":"https://github.com/zhiyuanzmj/rollup-utils#readme","bugs":{"url":"https://github.com/zhiyuanzmj/rollup-utils/issues"},"ava":{"files":["!**/fixtures/**","!**/helpers/**","!**/recipes/**","!**/types.ts"],"require":["ts-node/register"],"extensions":["ts"],"workerThreads":false},"nyc":{"extension":[".js",".ts"]},"dist":{"shasum":"0572f1ea49a6a8271f61ec2989e45d69a97d1d9a","tarball":"https://registry.npmjs.org/rollup-utils/-/rollup-utils-0.0.3.tgz","fileCount":6,"integrity":"sha512-5aMmOPg3kbeRdFpDSSEDwfWC9xnPyTv3dJ40iF26CQ84YCsiAM9TjVq0GEHN8woqEfeRmvaOGrSoLdKlUOYZHA==","signatures":[{"sig":"MEUCIGgbU5YXQXJhx8fEprMyPq04rHtCF1XkncGpOaEvTp+DAiEAw+LsE0RufO4pK6FzFKCexP/kGfufeQ0syvThyrFfkZo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":42526},"main":"./dist/cjs/index.js","type":"commonjs","_from":"file:rollup-utils-0.0.3.tgz","types":"./types/index.d.ts","module":"./dist/es/index.js","engines":{"node":">=14.0.0"},"exports":{"types":"./types/index.d.ts","import":"./dist/es/index.js","default":"./dist/cjs/index.js"},"scripts":{"test":"ava","build":"rollup -c","ci:lint":"pnpm build && pnpm lint","ci:test":"pnpm test -- --verbose","pretest":"pnpm build --sourcemap","test:ts":"tsc --noEmit","prebuild":"del-cli dist","prerelease":"pnpm build","ci:coverage":"nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}"},"_npmUser":{"name":"zmjs","email":"zhiyuanzmj@gmail.com"},"_resolved":"/private/var/folders/25/34_3hk_j1055wx930zmg8lkc0000gn/T/8dff0b30997e420fc4ccc81145861b17/rollup-utils-0.0.3.tgz","_integrity":"sha512-5aMmOPg3kbeRdFpDSSEDwfWC9xnPyTv3dJ40iF26CQ84YCsiAM9TjVq0GEHN8woqEfeRmvaOGrSoLdKlUOYZHA==","repository":{"url":"git+https://github.com/zhiyuanzmj/rollup-utils.git","type":"git"},"_npmVersion":"10.8.2","description":"A set of utility functions commonly used by Rollup plugins","directories":{},"_nodeVersion":"18.20.8","dependencies":{"picomatch":"^4.0.2","@types/estree":"^1.0.0","estree-walker":"^2.0.2","path-browserify":"^1.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^6.2.0","acorn":"^8.8.0","tslib":"^2.8.1","rollup":"^4.0.0-24","del-cli":"^6.0.0","ts-node":"^10.9.2","typescript":"^4.8.3","@types/node":"^14.18.30","@types/picomatch":"^2.3.0","@types/path-browserify":"^1.0.3","@rollup/plugin-commonjs":"^23.0.0","@rollup/plugin-typescript":"^9.0.1","@rollup/plugin-node-resolve":"^15.0.0"},"peerDependencies":{"rollup":"^1.20.0||^2.0.0||^3.0.0||^4.0.0"},"peerDependenciesMeta":{"rollup":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/rollup-utils_0.0.3_1747746270549_0.43497917049623513","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"rollup-utils","version":"0.0.4","keywords":["rollup","plugin","utils"],"author":{"name":"Rich Harris","email":"richard.a.harris@gmail.com"},"license":"MIT","_id":"rollup-utils@0.0.4","maintainers":[{"name":"zmjs","email":"zhiyuanzmj@gmail.com"}],"homepage":"https://github.com/zhiyuanzmj/rollup-utils#readme","bugs":{"url":"https://github.com/zhiyuanzmj/rollup-utils/issues"},"ava":{"files":["!**/fixtures/**","!**/helpers/**","!**/recipes/**","!**/types.ts"],"require":["ts-node/register"],"extensions":["ts"],"workerThreads":false},"nyc":{"extension":[".js",".ts"]},"dist":{"shasum":"6c04582fe5b604151ed126e7f2bdc75466dcb03a","tarball":"https://registry.npmjs.org/rollup-utils/-/rollup-utils-0.0.4.tgz","fileCount":6,"integrity":"sha512-17vRD+lRJ/x2Quksu8Wh3dS3zdRQ9nhB0YCCURzYvW46EHb1LyOhFlLa62KBB4fD75E0wp8ZI7cnWQZp4FKvow==","signatures":[{"sig":"MEUCIQDgH3AK6ZVxdr+uEQC5N3bTyQQvr1SWc4Y8zjKL46eNsAIgV1WB6fxGiugNUpN5rMYfOAQNJ8R4PZuZKUc7yIf1eSc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":42514},"main":"./dist/cjs/index.js","type":"module","_from":"file:rollup-utils-0.0.4.tgz","types":"./types/index.d.ts","module":"./dist/es/index.js","engines":{"node":">=14.0.0"},"exports":{"types":"./types/index.d.ts","import":"./dist/es/index.js","default":"./dist/cjs/index.js"},"scripts":{"test":"ava","build":"rollup -c","ci:lint":"pnpm build && pnpm lint","ci:test":"pnpm test -- --verbose","pretest":"pnpm build --sourcemap","test:ts":"tsc --noEmit","prebuild":"del-cli dist","prerelease":"pnpm build","ci:coverage":"nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}"},"_npmUser":{"name":"zmjs","email":"zhiyuanzmj@gmail.com"},"_resolved":"/private/var/folders/25/34_3hk_j1055wx930zmg8lkc0000gn/T/a702bcc019df37d282103d19a4909685/rollup-utils-0.0.4.tgz","_integrity":"sha512-17vRD+lRJ/x2Quksu8Wh3dS3zdRQ9nhB0YCCURzYvW46EHb1LyOhFlLa62KBB4fD75E0wp8ZI7cnWQZp4FKvow==","repository":{"url":"git+https://github.com/zhiyuanzmj/rollup-utils.git","type":"git"},"_npmVersion":"10.9.2","description":"A set of utility functions commonly used by Rollup plugins","directories":{},"_nodeVersion":"22.15.1","dependencies":{"picomatch":"^4.0.2","@types/estree":"^1.0.0","estree-walker":"^2.0.2","path-browserify":"^1.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^6.2.0","acorn":"^8.8.0","tslib":"^2.8.1","rollup":"^4.0.0-24","del-cli":"^6.0.0","ts-node":"^10.9.2","typescript":"^4.8.3","@types/node":"^14.18.30","@types/picomatch":"^2.3.0","@types/path-browserify":"^1.0.3","@rollup/plugin-commonjs":"^23.0.0","@rollup/plugin-typescript":"^9.0.1","@rollup/plugin-node-resolve":"^15.0.0"},"peerDependencies":{"rollup":"^1.20.0||^2.0.0||^3.0.0||^4.0.0"},"peerDependenciesMeta":{"rollup":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/rollup-utils_0.0.4_1748753633083_0.2755582819897351","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"rollup-utils","version":"0.0.5","publishConfig":{"access":"public"},"description":"A set of utility functions commonly used by Rollup plugins","license":"MIT","repository":{"type":"git","url":"git+https://github.com/zhiyuanzmj/rollup-utils.git"},"author":{"name":"Rich Harris","email":"richard.a.harris@gmail.com"},"homepage":"https://github.com/zhiyuanzmj/rollup-utils#readme","bugs":{"url":"https://github.com/zhiyuanzmj/rollup-utils/issues"},"main":"./dist/cjs/index.js","module":"./dist/es/index.js","type":"commonjs","exports":{"types":"./types/index.d.ts","import":"./dist/es/index.js","default":"./dist/cjs/index.js"},"engines":{"node":">=14.0.0"},"keywords":["rollup","plugin","utils"],"peerDependencies":{"rollup":"^1.20.0||^2.0.0||^3.0.0||^4.0.0"},"peerDependenciesMeta":{"rollup":{"optional":true}},"dependencies":{"@types/estree":"^1.0.0","estree-walker":"^2.0.2","path-browserify":"^1.0.1","picomatch":"^4.0.2"},"devDependencies":{"@types/path-browserify":"^1.0.3","@rollup/plugin-commonjs":"^23.0.0","@rollup/plugin-node-resolve":"^15.0.0","@rollup/plugin-typescript":"^9.0.1","@types/node":"^14.18.30","@types/picomatch":"^2.3.0","acorn":"^8.8.0","ava":"^6.2.0","del-cli":"^6.0.0","rollup":"^4.0.0-24","ts-node":"^10.9.2","tslib":"^2.8.1","typescript":"^4.8.3"},"types":"./types/index.d.ts","ava":{"extensions":["ts"],"require":["ts-node/register"],"workerThreads":false,"files":["!**/fixtures/**","!**/helpers/**","!**/recipes/**","!**/types.ts"]},"nyc":{"extension":[".js",".ts"]},"scripts":{"build":"rollup -c","ci:coverage":"nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov","ci:lint":"pnpm build && pnpm lint","ci:lint:commits":"commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}","ci:test":"pnpm test -- --verbose","prebuild":"del-cli dist","prerelease":"pnpm build","pretest":"pnpm build --sourcemap","test":"ava","test:ts":"tsc --noEmit"},"_id":"rollup-utils@0.0.5","_integrity":"sha512-Naai1vGKHGTrvrSuWOX1rSJSKodmJ8aZ3mtF0hHFP64NOtsKvnOGbxD4162fWGePdCWxAckEBNHQ/QX7S81H4g==","_resolved":"/private/var/folders/25/34_3hk_j1055wx930zmg8lkc0000gn/T/dd757a434c0e49f18107b5055f37e462/rollup-utils-0.0.5.tgz","_from":"file:rollup-utils-0.0.5.tgz","_nodeVersion":"22.15.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-Naai1vGKHGTrvrSuWOX1rSJSKodmJ8aZ3mtF0hHFP64NOtsKvnOGbxD4162fWGePdCWxAckEBNHQ/QX7S81H4g==","shasum":"fe6716d297e90eec9b488da3e59aa56130c473fb","tarball":"https://registry.npmjs.org/rollup-utils/-/rollup-utils-0.0.5.tgz","fileCount":6,"unpackedSize":42516,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCTAQXsi76VW8zQTbFTDBrbxZCOG/EJklxGStqpPNgJXwIgBxDOOH5PSQ3SP+AzhE99TrIx8Zvh/yfusoBifqauVuY="}]},"_npmUser":{"name":"zmjs","email":"zhiyuanzmj@gmail.com"},"directories":{},"maintainers":[{"name":"zmjs","email":"zhiyuanzmj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rollup-utils_0.0.5_1748754865983_0.7139130101263498"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-18T14:55:30.686Z","modified":"2025-06-01T05:14:26.484Z","1.0.0":"2021-12-06T03:37:14.577Z","0.0.1":"2025-01-18T14:55:30.984Z","0.0.2":"2025-01-20T11:25:14.055Z","0.0.3":"2025-05-20T13:04:30.713Z","0.0.4":"2025-06-01T04:53:53.279Z","0.0.5":"2025-06-01T05:14:26.279Z"},"bugs":{"url":"https://github.com/zhiyuanzmj/rollup-utils/issues"},"author":{"name":"Rich Harris","email":"richard.a.harris@gmail.com"},"license":"MIT","homepage":"https://github.com/zhiyuanzmj/rollup-utils#readme","keywords":["rollup","plugin","utils"],"repository":{"type":"git","url":"git+https://github.com/zhiyuanzmj/rollup-utils.git"},"description":"A set of utility functions commonly used by Rollup plugins","maintainers":[{"name":"zmjs","email":"zhiyuanzmj@gmail.com"}],"readme":"[npm]: https://img.shields.io/npm/v/rollup-utils\n[npm-url]: https://www.npmjs.com/package/rollup-utils\n[size]: https://packagephobia.now.sh/badge?p=rollup-utils\n[size-url]: https://packagephobia.now.sh/result?p=rollup-utils\n\n[![npm][npm]][npm-url]\n[![size][size]][size-url]\n[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)\n\n# rollup-utils\n\nForked from [@rollup/pluginutils](https://github.com/rollup/plugins/tree/master/packages/pluginutils), using [path-browserify](https://github.com/browserify/path-browserify) instead of the native `path` module to support browser environments.\n\nA set of utility functions commonly used by 🍣 Rollup plugins.\n\n## Requirements\n\nThe plugin utils require an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.\n\n## Install\n\nUsing npm:\n\n```console\nnpm install rollup-utils --save-dev\n```\n\n## Usage\n\n```js\nimport utils from 'rollup-utils';\n//...\n```\n\n## API\n\nAvailable utility functions are listed below:\n\n_Note: Parameter names immediately followed by a `?` indicate that the parameter is optional._\n\n### addExtension\n\nAdds an extension to a module ID if one does not exist.\n\nParameters: `(filename: String, ext?: String)`<br>\nReturns: `String`\n\n```js\nimport { addExtension } from 'rollup-utils';\n\nexport default function myPlugin(options = {}) {\n  return {\n    resolveId(code, id) {\n      // only adds an extension if there isn't one already\n      id = addExtension(id); // `foo` -> `foo.js`, `foo.js` -> `foo.js`\n      id = addExtension(id, '.myext'); // `foo` -> `foo.myext`, `foo.js` -> `foo.js`\n    }\n  };\n}\n```\n\n### attachScopes\n\nAttaches `Scope` objects to the relevant nodes of an AST. Each `Scope` object has a `scope.contains(name)` method that returns `true` if a given name is defined in the current scope or a parent scope.\n\nParameters: `(ast: Node, propertyName?: String)`<br>\nReturns: `Object`\n\nSee [@rollup/plugin-inject](https://github.com/rollup/plugins/tree/master/packages/inject) or [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/master/packages/commonjs) for an example of usage.\n\n```js\nimport { attachScopes } from 'rollup-utils';\nimport { walk } from 'estree-walker';\n\nexport default function myPlugin(options = {}) {\n  return {\n    transform(code) {\n      const ast = this.parse(code);\n\n      let scope = attachScopes(ast, 'scope');\n\n      walk(ast, {\n        enter(node) {\n          if (node.scope) scope = node.scope;\n\n          if (!scope.contains('foo')) {\n            // `foo` is not defined, so if we encounter it,\n            // we assume it's a global\n          }\n        },\n        leave(node) {\n          if (node.scope) scope = scope.parent;\n        }\n      });\n    }\n  };\n}\n```\n\n### createFilter\n\nConstructs a filter function which can be used to determine whether or not certain modules should be operated upon.\n\nParameters: `(include?: <picomatch>, exclude?: <picomatch>, options?: Object)`<br>\nReturns: `(id: string | unknown) => boolean`\n\n#### `include` and `exclude`\n\nType: `String | RegExp | Array[...String|RegExp]`<br>\n\nA valid [`picomatch`](https://github.com/micromatch/picomatch#globbing-features) pattern, or array of patterns. If `options.include` is omitted or has zero length, filter will return `true` by default. Otherwise, an ID must match one or more of the `picomatch` patterns, and must not match any of the `options.exclude` patterns.\n\nNote that `picomatch` patterns are very similar to [`minimatch`](https://github.com/isaacs/minimatch#readme) patterns, and in most use cases, they are interchangeable. If you have more specific pattern matching needs, you can view [this comparison table](https://github.com/micromatch/picomatch#library-comparisons) to learn more about where the libraries differ.\n\n#### `options`\n\n##### `resolve`\n\nType: `String | Boolean | null`\n\nOptionally resolves the patterns against a directory other than `process.cwd()`. If a `String` is specified, then the value will be used as the base directory. Relative paths will be resolved against `process.cwd()` first. If `false`, then the patterns will not be resolved against any directory. This can be useful if you want to create a filter for virtual module names.\n\n#### Usage\n\n```js\nimport { createFilter } from 'rollup-utils';\n\nexport default function myPlugin(options = {}) {\n  // assume that the myPlugin accepts options of `options.include` and `options.exclude`\n  var filter = createFilter(options.include, options.exclude, {\n    resolve: '/my/base/dir'\n  });\n\n  return {\n    transform(code, id) {\n      if (!filter(id)) return;\n\n      // proceed with the transformation...\n    }\n  };\n}\n```\n\n### dataToEsm\n\nTransforms objects into tree-shakable ES Module imports.\n\nParameters: `(data: Object, options: DataToEsmOptions)`<br>\nReturns: `String`\n\n#### `data`\n\nType: `Object`\n\nAn object to transform into an ES module.\n\n#### `options`\n\nType: `DataToEsmOptions`\n\n_Note: Please see the TypeScript definition for complete documentation of these options_\n\n#### Usage\n\n```js\nimport { dataToEsm } from 'rollup-utils';\n\nconst esModuleSource = dataToEsm(\n  {\n    custom: 'data',\n    to: ['treeshake']\n  },\n  {\n    compact: false,\n    indent: '\\t',\n    preferConst: true,\n    objectShorthand: true,\n    namedExports: true,\n    includeArbitraryNames: false\n  }\n);\n/*\nOutputs the string ES module source:\n  export const custom = 'data';\n  export const to = ['treeshake'];\n  export default { custom, to };\n*/\n```\n\n### extractAssignedNames\n\nExtracts the names of all assignment targets based upon specified patterns.\n\nParameters: `(param: Node)`<br>\nReturns: `Array[...String]`\n\n#### `param`\n\nType: `Node`\n\nAn `acorn` AST Node.\n\n#### Usage\n\n```js\nimport { extractAssignedNames } from 'rollup-utils';\nimport { walk } from 'estree-walker';\n\nexport default function myPlugin(options = {}) {\n  return {\n    transform(code) {\n      const ast = this.parse(code);\n\n      walk(ast, {\n        enter(node) {\n          if (node.type === 'VariableDeclarator') {\n            const declaredNames = extractAssignedNames(node.id);\n            // do something with the declared names\n            // e.g. for `const {x, y: z} = ...` => declaredNames = ['x', 'z']\n          }\n        }\n      });\n    }\n  };\n}\n```\n\n### makeLegalIdentifier\n\nConstructs a bundle-safe identifier from a `String`.\n\nParameters: `(str: String)`<br>\nReturns: `String`\n\n#### Usage\n\n```js\nimport { makeLegalIdentifier } from 'rollup-utils';\n\nmakeLegalIdentifier('foo-bar'); // 'foo_bar'\nmakeLegalIdentifier('typeof'); // '_typeof'\n```\n\n### normalizePath\n\nConverts path separators to forward slash.\n\nParameters: `(filename: String)`<br>\nReturns: `String`\n\n#### Usage\n\n```js\nimport { normalizePath } from 'rollup-utils';\n\nnormalizePath('foo\\\\bar'); // 'foo/bar'\nnormalizePath('foo/bar'); // 'foo/bar'\n```\n\n## Meta\n\n[CONTRIBUTING](/.github/CONTRIBUTING.md)\n\n[LICENSE (MIT)](/LICENSE)\n","readmeFilename":"README.md"}