{"name":"rewrite-imports","version":"1.1.0","repository":{"type":"git","url":"git+https://github.com/lukeed/rewrite-imports.git"},"description":"Rewrite `import` statements as `require()`s; via RegExp","browser":"dist/rewrite-imports.es5.js","main":"dist/rewrite-imports.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"prepublishOnly":"node builder","test":"tape test/*.js | tap-spec"},"files":["dist"],"keywords":["regex","rewrite","modules","imports","requires","aliases"],"devDependencies":{"buble":"^0.19.3","mk-dirs":"^1.0.0","tap-spec":"^4.1.1","tape":"^4.7.0"},"gitHead":"fb5b20fea5a34eae9e27de6f3f6e3b3b54b6c065","bugs":{"url":"https://github.com/lukeed/rewrite-imports/issues"},"homepage":"https://github.com/lukeed/rewrite-imports#readme","_id":"rewrite-imports@1.1.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-FZ2yECKTUzTKeDzdUOxDXj0RKPk8+rE3zLQ44xbIoojbO5vlIoE/dfDGwtn/bxC0kWFkioxxJXs4hkQHOhloIQ==","shasum":"27defc0eef137ce151c0fad6c2457779d4f8564b","tarball":"http://registry-npm.ywwl.com/rewrite-imports/download/rewrite-imports-1.1.0.tgz","fileCount":5,"unpackedSize":5153,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbaqvICRA9TVsSAnZWagAAUrgP+waMx/8KRStTPa5cK9d1\nD6FBq2+jIac45TL+7Fu5U9eHojqXvMImbExh7muX7k/MMxR3lnSYovrRnYqU\nwYWqOXl1+++sivkGTf4W591nFI/ISTBuejyb/FTDrWHvg0DbUd6IlLKnZ2jU\nSgcxHYGF1fN2/9XogLGdk417RBHQGnun6lCaaP5oj3j36zeU5BUHetfx6QQ6\ntALx9lg5uYD8pdWyopuTOTXW51zVZw3JdIy0Xf4SNqUGy0ymmBN92M/yr5va\ndB83KU8w39Zd0BKTsBvSdsOA4h8xJU+LjHCVgu4ZzIW6qkYimPGJq83/StqJ\n9agpQvf/F+MSKZITaL4wyNBmXgHB2lUW3Ow9jrb4HY/C6gFlSkz+Thu4IdqS\nPy7Gn/En6e3BTCKLw/a8bIJVm9t1mpF8tGz3r6S6o7/ThF/CvjHO6768c67w\n+nFHbyZqcq/DXnmMy4SCsGMiJhXo8WTla5NeyQWCug3RTfhVn22F374ljZOx\nlmmtMpyc/56euoXoCFvSAyHloT8HSx+DpNBN0WhhSMMvO7xT0u5XIcKrkj28\n5PDP78QyxQUF6tHtEeWu3GPqLiKFGgr5AjGvHjXSC/Nmbsi7XukWt5uZr9Jz\n0GpFmOKQsSgJM9QsL7o2lZzIHtsHmMjFjgBxsaqr+Mw7UFz8b9BhpSeim0xR\npFZU\r\n=NFZv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHalDDXMc7NrK1Vyig65he0upmtSw49KOxAU+ZriMLuSAiEAqoHIyNnQh5h6B50LzoMAefP7FRwIGC0bpDj/TTfVqms="}],"size":2357,"noattachment":false,"key":"/rewrite-imports/-/rewrite-imports-1.1.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rewrite-imports_1.1.0_1533717448315_0.34313973322980806"},"_hasShrinkwrap":false,"readme":"# rewrite-imports [![CI](https://github.com/lukeed/rewrite-imports/actions/workflows/ci.yml/badge.svg)](https://github.com/lukeed/rewrite-imports/actions/workflows/ci.yml)\n\nA tiny (349B) utility to transform various `import` statements into `require()` calls, using regular expressions.\n\n> ***Looking for something _more_ backwards compatible?*** <br>\n> Check out [`v1.4.0`](https://github.com/lukeed/rewrite-imports/tree/v1.4.0) which does not rely on destructured assignment!\n\n\n## Caveats\n\nThis module returns a string and **does not** provide a runtime nor does it evaluate the output.\n\n> :bulb: For this behavior, use [`rewrite-module`](https://github.com/lukeed/rewrite-module) or check out [`@taskr/esnext`](https://github.com/lukeed/taskr/tree/master/packages/esnext) for an example.\n\nThe output requires a JavaScript runtime that supports `require` calls and [destructuring assignments](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring) with Objects.\n\n  * At least `Node 6.x` is required\n\n  * Or, for browsers:\n    * A `require` shim is always needed – see [`fn`](#fn)\n    * Ensure your target browsers support destructuring – see [chart](https://kangax.github.io/compat-table/es6/#test-destructuring,_assignment)\n\nIf you have [false positives](https://github.com/lukeed/rewrite-imports/issues/8), you may want to use an AST to find actual `import` statements before transformation.\n\n> Check out an [example implementation](https://github.com/styleguidist/react-styleguidist/blob/82f22d217044dee6215e60696c39791ee168fc14/src/client/utils/transpileImports.js).\n\n\n## Install\n\n```\n$ npm install --save rewrite-imports\n```\n\n\n## Usage\n\n```js\nimport { rewrite } from 'rewrite-imports';\n// or\nconst { rewrite } = require('rewrite-imports');\n\nrewrite(`import foo from '../bar'`);\n//=> const foo = require('../bar');\n\nrewrite(`import { foo } from 'bar'`);\n//=> const { foo } = require('bar');\n\nrewrite(`import * as path from 'path';`);\n//=> const path = require('path');\n\nrewrite(`import { foo as bar, baz as bat, lol } from 'quz';`);\n//=> const { foo:bar, baz:bat, lol } = require('quz');\n\nrewrite(`import foobar, { foo as FOO, bar } from 'foobar';`);\n//=> const foobar = require('foobar');\n//=> const { foo:FOO, bar } = foobar;\n```\n\n\n## API\n\n### rewrite(input, fn)\n\n#### input\nType: `String`\n\nThe `import` statement(s) or the code containing `import` statement(s).\n\n> See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) for valid `import` statement syntax.\n\n#### fn\nType: `String`<br>\nDefault: `'require'`\n\nThe `require`-like function name to use. Defaults to `require` but you may choose to pass the name of a custom shim function; for example, `__webpack_require__` may work for webpack in the browser.\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","publish_time":1533717448364,"_cnpm_publish_time":1533717448364,"dist-tags":{"latest":"3.0.0"}}