{"name":"rewrite-imports","version":"2.0.2","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":"db8afca9a00e680f05276900fd1034a7d5afb6a2","bugs":{"url":"https://github.com/lukeed/rewrite-imports/issues"},"homepage":"https://github.com/lukeed/rewrite-imports#readme","_id":"rewrite-imports@2.0.2","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-h6xjqfgs00qdhtgDuICUcVj1w9INdxup8ve0DaFarQqNqc8V+f9bLEuUUbbWImqfgwCU2uS6o3sryWzVRZbpkw==","shasum":"1a862c8c6785219e7c0d3ccdb540ea0af74fef0a","tarball":"http://registry-npm.ywwl.com/rewrite-imports/download/rewrite-imports-2.0.2.tgz","fileCount":6,"unpackedSize":7114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcpbsPCRA9TVsSAnZWagAAUB4P/jfSjn/IusmKCC4yf6ee\nGoLl+b5ErBaRY23Awqp4B4oLibmlo4zwA/HPrjtbJweWGfWTvYo57x7rUTIy\nqdbXhjChFT07/JQ1xiS7iIVeLewsqqBb5jonVsgFJqb1/dfXweaVHyw5Pke7\nuelWHQgKCw35TUGS7b00I5oP3tPHTpK/t/DrG6VM1r4lE9nlr10EEIY0UaTu\n6ceoe6yzi46ZG5CtjWMhKlfJ3qVeuZE+c9gENbsCOhlExddKXmXmq/Zb2CEf\nXEEqe9s2M9+dyHj8wmvh7OXi6ZDGpPcAANfPDv10V+vwjqFbvUh0EaCWK1Gs\n8HFwgY+sZJ0TUi1wz49VUSSHi/Ct9KJkc5M2ivS7Uwn1ieSP9MHl1IePmmat\nYu17Cd37nblmALaJDpNA9MxwPWtHh2PY9cd9h9u0tsTDOd+xR/rIZ7diFXJG\n8eJ4haYoZnKpVqXJGWP4pfaDefojaAca4/Cpp8dt4cfr25sTRqlVsa+IlF51\nUBcLIWTnl3nVscUtsydWC7tktQbi7XE2hKevn/8QU4JHNTkr7bXBNOoSriJt\nnFM44f9e0qJA79zrxzPk+bQqucEIMR8QUoCGWwdhYm3KXw58l/dSE//UiUKD\ntD+TuSL1RGH6U8TPKjr6lhXYgngEwEJ0LuYXJDscCpT6VjZm4RNyZpfHVGK2\ngQoL\r\n=gqva\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIELNPLgGLpJ8GWWFQUhDkpzD0pKKUo1UsDVEzM1yZV7mAiBee9omrdOCxIoPdhJABJMfF7zZ8MU0POwUny49s1/TRg=="}],"size":3111,"noattachment":false,"key":"/rewrite-imports/-/rewrite-imports-2.0.2.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rewrite-imports_2.0.2_1554365198316_0.41283769995740505"},"_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":1554365198523,"_cnpm_publish_time":1554365198523,"dist-tags":{"latest":"3.0.0"}}