{"name":"rewrite-imports","version":"2.0.3","repository":{"type":"git","url":"git+https://github.com/lukeed/rewrite-imports.git"},"description":"Rewrite `import` statements as `require()`s; via RegExp","module":"dist/rewrite.mjs","unpkg":"dist/rewrite.min.js","main":"dist/rewrite.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=6"},"scripts":{"build":"bundt","pretest":"npm run build","test":"tape test/*.js | tap-spec"},"keywords":["regex","rewrite","modules","imports","requires","aliases"],"devDependencies":{"bundt":"^0.3.0","tap-spec":"^4.1.1","tape":"^4.7.0"},"gitHead":"38cc9d5b9312afbb542dc6380ad43efc87d8dbc5","bugs":{"url":"https://github.com/lukeed/rewrite-imports/issues"},"homepage":"https://github.com/lukeed/rewrite-imports#readme","_id":"rewrite-imports@2.0.3","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-R7ICJEeP3y+d/q4C8YEJj9nRP0JyiSqG07uc0oQh8JvAe706dDFVL95GBZYCjADqmhArZWWjfM/5EcmVu4/B+g==","shasum":"210fc05ebda6a6c6a2e396608b0146003d510dda","tarball":"http://registry-npm.ywwl.com/rewrite-imports/download/rewrite-imports-2.0.3.tgz","fileCount":6,"unpackedSize":7128,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcpnRiCRA9TVsSAnZWagAAJvgQAJGcFavS5MzdPcOeoS0X\nj5GoTZvQ89C8d+DWjaKgYA91ZRdeHsUgkTB3zzE+21IYB4wbkkyPyEvpBH6i\nt9R6UyKAOfsDgIYY2uY18VDtkhV+yawz10DYlwY2KAT0OtZTPGS6OxkZF0dh\nQ/kP5PkoDOXrJpMnrYwfaQvu6xbiH5/MTR8+GoRFfa2R6gLsS+/s5wUYfZAi\ntYp2xHPUrrz8lixNc4rOYbTt9TCkiqLXYmiqlk4A+e9U8bMu2Mo0mqCd+tqF\nDEvl1MyMCaTKCfX8gZoytO8rgHXnQHXCzcZosQHH/x5Bg0MoRi+S3S+Jcx1D\nAAYBTQOU9qH2ITpeCpM9TMGorzMDqM9l/MKHhvt6EjTb8XA3cfBnznfEqEbX\nraCKpo8uQAeNA7jvTUzd3N6c1wKT+2V4t+skGfLJ2AfPSvrUHbJpXiUR+wHT\nITMW7BUKm0VPi0Wj0X3HPms2bNvoufB6wWrj1xP2PsSPjZ8AuFXGQcFgLJEc\n1er4KuQy9IdDzPe51irpTXnGy+1mDqESrqAOBcunP8LVh/A3o1z8mK7Own4d\nqCOeYLiaY89bgoEu4czVyBMxxSXaVm3KmLaidZaoESG7Mii3DkF//4/SKxI1\nz+nyzUuc1v8dkMPKZ3jN6d4YXJvjbHH/OvNhhc9SEBVM7Mff8tLaehR64ozl\n6Val\r\n=gIDE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCfjm6IkJcq1gIC0KCS9rSzj51tYO/pKCgNibV+ZOYZjQIgHHoN6MmDDtKsOjGuviiT8EZ9+FCZhz9pJDBP11ftCQE="}],"size":3146,"noattachment":false,"key":"/rewrite-imports/-/rewrite-imports-2.0.3.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rewrite-imports_2.0.3_1554412641670_0.7959729622269061"},"_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":1554412641836,"_cnpm_publish_time":1554412641836,"dist-tags":{"latest":"3.0.0"}}