{"name":"rewrite-imports","version":"1.2.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"},"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":"ebca15c159883755491e4c50b46eabfa186b6837","bugs":{"url":"https://github.com/lukeed/rewrite-imports/issues"},"homepage":"https://github.com/lukeed/rewrite-imports#readme","_id":"rewrite-imports@1.2.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-oVoZ3QImciK+S7I89vPyxDgohkwhJyWLP5EKcMvF2NOhaFkmdKFiJMJzTM35VeNV1gQfGvv9Cve6sMq5E7unHg==","shasum":"091b05aa0a358e54b6582205b6feeb73977bd8fb","tarball":"http://registry-npm.ywwl.com/rewrite-imports/download/rewrite-imports-1.2.0.tgz","fileCount":5,"unpackedSize":5092,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbcdi+CRA9TVsSAnZWagAAWIIP/35RstHXU4T0dPUcYzGe\nRD0wUV3pEn5KNS37k/rH+qZDH7Yab0rqGBIEtA4KaTqEPF7mwrxvHdq4U3oo\nisHz2OVLIDt83nRavSfJ/EtSI/oxMxY4KjEwyKhweFzUgfT6oBcnrbW9UjQz\nnR9VE8oo/jXy8z5hR3U34dNZ/SqEUFrjmUNEolpXSA7oGTODZfrnfdSSMMo+\nk8IEItUXGbN+39saZvzjKx2laG3OxRzbYvOBzz3IO47ZVLFjUSX1VzteKB5F\nC2STvnKSML0qDXXu93LWwgOLb5G3mbKVXaOFVVKIw7Bw+DTZQInTGvuOZGRP\niArJUwu7L4dKlLqSXQvHIOw5mwDQkOgIxyMQ+JfjSCKZrvyJMx8sR1GjyW8t\nOAySQ9SUj156vrruS9TstT6czi2lsgsY0wrmmzhlpmOKmukQ3a7Ybkje2Omr\nkC+x2/Qk7BPIBf00jtBcbPW686tdJIEwI6wA6am84PIoTnnfVLK0n98DnnOW\ng/8xLYIp7quhZdRfipyY9L0zag1/s+3e+wWjzG2Q4gkjmMWSETd0u60c9D+0\nohpBRlXxqHj10jTEjtLMBgwRH4PPaxDYlRcOGo4HwRmzPjXGb9MeYXAsgIpA\n4bUXOG6Ojlx1S1gM2DNwi+TqIRi9x3+tagtYot+ylRLVVzySWxl1WbOO6wNc\nKHs4\r\n=ohI2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDsQzZPAlepUgq8WtYGNB4YHEUER1TP2CZ5fQqZ4V736QIgP02YQ6bqjl5bqJvoFauk083Wz2PoPI5n37INC2t3l3Q="}],"size":2357,"noattachment":false,"key":"/rewrite-imports/-/rewrite-imports-1.2.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rewrite-imports_1.2.0_1534187710149_0.44699869277010285"},"_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":1534187710261,"_cnpm_publish_time":1534187710261,"dist-tags":{"latest":"3.0.0"}}