{"name":"rewrite-imports","version":"1.4.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":{"build":"node builder","test":"tape test/*.js | tap-spec"},"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":"dc5f7326f26ab85d124950b0f9c83fce709e195a","bugs":{"url":"https://github.com/lukeed/rewrite-imports/issues"},"homepage":"https://github.com/lukeed/rewrite-imports#readme","_id":"rewrite-imports@1.4.0","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-k4pGuRsZ6UMSLW4mxpKVxqvGAwXCC81ZnLD+o+S9/7b3+fZ/pguNLHZpZ7qgi/5AmtqzuzppInhaARBjjDquOA==","shasum":"198ebb73f59cfee8d214516c774b6aeef2c54a6e","tarball":"http://registry-npm.ywwl.com/rewrite-imports/download/rewrite-imports-1.4.0.tgz","fileCount":5,"unpackedSize":5589,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb9wgVCRA9TVsSAnZWagAAo2sP/Rvdzhtaa0SYU7RJrPxq\nWNjcLdDZSJs7rEeBttu7DFwHom1pD25pRSI/mOKR7fLDQInzsw4dExHmhfIL\nFo92r1SGgKX1+f1AZeV3RNVMznGbiiMaeTWBqUY4zLcttwFQaoggQKFpd0Fv\n0JkFz8FT4yTfrJmSoP9/9E0wm8x57rBQeB3Q4i54ITTBc8McEUK9caXGdkQJ\n8cY8t0/hJbJqNJVdLHpQz9s/FcLnuipUMoA95Vyh1ZCJSj0r78551WZ0aygY\nHvT9nQWLNXAM4bbwhzXz/3TXlcVrzKQQUsQSBBQcvO9xRy0bU3jp5kRcEKLa\nQSXHEQLcbZBZWBBtW5uz4v2xQcUZvaSh57DSoq1mOoLl2CvVs9v+q2P3IcGG\nttQr8AcJVP6qvu4Y77x4pTq5UwjJT3bchXBpp2jHt4ta2E3nOAqkm7vZpa4w\nc7Fb0WT4c3RHjlw7EmLKzYz0z/8E6tAzSkexWiRa6hH+dF+aQkaS4r6qakny\nCnrRleUgAC2l+Sdkrwmz5pFRMKfycWfdpOr1cB4pUDfTa+YyM2i9nLaEShkK\niEsBplDJuApVfNC2OYiWBdrrApSj0dLIwWn3kHe1JHOEDkK+AnTwEEEj0CAF\nW1ZvsTgQxwe8pfWXzUMtkVNjmd007apOLpHmMu9ndqdLirOP4aIw6uz5YNgz\nOlEo\r\n=RxO3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHOxluRcNz5C49ZZyavsfjd3iWfrkD0ThbNp03kILuQ5AiBdSdG++Yco7Jhy6a++TQEY7Yp7wNXVFHwGNoKDA0GeGQ=="}],"size":2597,"noattachment":false,"key":"/rewrite-imports/-/rewrite-imports-1.4.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rewrite-imports_1.4.0_1542916116714_0.3437563870118807"},"_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":1542916116870,"_cnpm_publish_time":1542916116870,"dist-tags":{"latest":"3.0.0"}}