{"version":"3.0.0","name":"rewrite-imports","repository":{"type":"git","url":"git+https://github.com/lukeed/rewrite-imports.git"},"description":"A tiny (349B) utility to rewrite `import` statements as `require()`s; via RegExp","module":"dist/index.mjs","unpkg":"dist/index.min.js","main":"dist/index.js","types":"index.d.ts","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"engines":{"node":">=6"},"exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js"},"./package.json":"./package.json"},"scripts":{"build":"bundt","test":"uvu -r esm test"},"keywords":["regex","rewrite","modules","imports","requires","aliases"],"devDependencies":{"bundt":"^0.3.0","esm":"3.2.25","uvu":"0.5.1"},"gitHead":"db407cf2953ad637a835c503648be26fbdffd873","bugs":{"url":"https://github.com/lukeed/rewrite-imports/issues"},"homepage":"https://github.com/lukeed/rewrite-imports#readme","_id":"rewrite-imports@3.0.0","_nodeVersion":"14.15.3","_npmVersion":"6.14.9","dist":{"integrity":"sha512-RClzg1cUfYLYkQadcrjgih8+CqJDKOP3OIWGkFE+e5n71085QnOwghzLPonEe1gG6iblCVJ8lHGFtd+n8wj3Hg==","shasum":"4a5b921bbfa8030fd50c86d609b53432585a16bf","tarball":"http://registry-npm.ywwl.com/rewrite-imports/download/rewrite-imports-3.0.0.tgz","fileCount":7,"unpackedSize":7281,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJguWppCRA9TVsSAnZWagAAD00QAJRcftblQMKgpfJpv+jM\nHwqMlkwkVBKwMv9iSzquYTjIRk8aE7I38Li2ekN5Vc8pv6WIpVvgeCQMwxhe\nQRC7wrn9WlvHPo5mqIOD7Gvtqj5K80qMLnhL+xhazMYIC+H6pzY/dvZ1XlkK\nbJFb/qOHYDgv+PCeQUQZHMPguiqDggqahba0yFEPlMwTjo6Md3eIM1uNy9of\nJCmB5ZpSJsYo97n7nVZJxzAPif4TidAids9Xqqbaiml9uHEDb5eg4GsDCvwy\nJFWAhRt6aAYAsIqkUfbNPlsOZE4aimlhR0wJi8h0Ic0k8wJZRErzWFC0F3EI\n+sJB16LKLR59Z4gQEE3ALmngzJeY24RTJWX9Yc8OJlOdTptcgMWATqU1e19D\nA0Qf44snVEppSAhD6gElWX1B7GMpjDiEcLLrqYyMJsbD7KIlQZpPOdVF0T9H\nkRVbR9yB2jPXfdfXOnZE6DoVBiiNe6DayoUXmj/AES64rpfoVncYP0xSV+VB\npLBSh1maQYXxxesnyf+ET9aUGg3Nh1Z15jsJrNRLjXdVjtcqOXLHeUmLGkW6\n+bz7LGk4NYcXj7d64bYOXWilpdtRIk7X3JdbNTubvniyywZgp+bKMNMEoS2t\nWu5oaIoDUrYtzAPG1ylG6zM+b7+8g01ThwPqMD6kNSnuswGC/hWPS0nv9ANr\n9/J9\r\n=+TIs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5AyNFLm9MLsNksPtjFjgJ2MFNKu4Uo8IMnGEFni6sswIhAN0AzUmd53NNAVK7gtHCryEjyemCODHrf6f+ZHCrvcb9"}],"size":3256,"noattachment":false,"key":"/rewrite-imports/-/rewrite-imports-3.0.0.tgz"},"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rewrite-imports_3.0.0_1622764137326_0.949643012045988"},"_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":1622764137462,"_cnpm_publish_time":1622764137462,"dist-tags":{"latest":"3.0.0"}}