[
  {
    "path": ".babelrc.js",
    "content": "module.exports = {\n\tpresets: [\n\t\t[\n\t\t\t'@babel/preset-env',\n\t\t\t{\n\t\t\t\ttargets: {\n\t\t\t\t\tnode: 6\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t]\n};\n"
  },
  {
    "path": ".eslintrc.json",
    "content": "{\n  \"root\": true,\n  \"rules\": {\n    \"indent\": [ 2, \"tab\", { \"SwitchCase\": 1 } ],\n    \"semi\": [ 2, \"always\" ],\n    \"keyword-spacing\": [ 2, { \"before\": true, \"after\": true } ],\n    \"space-before-blocks\": [ 2, \"always\" ],\n    \"no-mixed-spaces-and-tabs\": [ 2, \"smart-tabs\" ],\n    \"no-cond-assign\": 0,\n    \"no-unused-vars\": 2,\n    \"object-shorthand\":  [ 2, \"always\" ],\n    \"no-const-assign\": 2,\n    \"no-class-assign\": 2,\n    \"no-this-before-super\": 2,\n    \"no-var\": 2,\n    \"no-unreachable\": 2,\n    \"valid-typeof\": 2,\n    \"quote-props\": [ 2, \"as-needed\" ],\n    \"one-var\": [ 2, \"never\" ],\n    \"prefer-arrow-callback\": 2,\n    \"prefer-const\": [ 2, { \"destructuring\": \"all\" } ],\n    \"arrow-spacing\": 2\n  },\n  \"env\": {\n    \"es6\": true,\n    \"browser\": true,\n    \"node\": true\n  },\n  \"extends\": [\n    \"eslint:recommended\",\n    \"plugin:import/errors\",\n    \"plugin:import/warnings\"\n  ],\n  \"parserOptions\": {\n    \"ecmaVersion\": 8,\n    \"sourceType\": \"module\"\n  },\n  \"settings\": {\n    \"import/ignore\": [ 0, [\n      \"\\\\.path.js$\"\n    ] ]\n  }\n}\n"
  },
  {
    "path": ".gitignore",
    "content": ".DS_Store\nnode_modules\n.gobble*\ndist\n!test/**/node_modules\n"
  },
  {
    "path": ".huskyrc",
    "content": "{\n  \"hooks\": {\n    \"post-commit\": \"git reset\",\n    \"pre-commit\": \"lint-staged\"\n  }\n}\n"
  },
  {
    "path": ".lintstagedrc",
    "content": "{\n  \"{src/**/*,test/test,test/**/_config}.js\": [\n    \"prettier --write\",\n    \"eslint --fix\",\n    \"git add\"\n  ]\n}\n"
  },
  {
    "path": ".prettierrc",
    "content": "{\n\t\"singleQuote\": true,\n\t\"useTabs\": true,\n\t\"printWidth\": 100\n}\n"
  },
  {
    "path": ".travis.yml",
    "content": "sudo: false\nlanguage: node_js\nnode_js:\n  - \"8\"\n  - \"10\"\nenv:\n  global:\n    - BUILD_TIMEOUT=10000\ninstall: npm ci --ignore-scripts\nbefore_install:\n  - if [[ $TRAVIS_NODE_VERSION -lt 8 ]]; then npm install --global npm@5; fi\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# rollup-plugin-commonjs changelog\n\n## 10.1.0\n*2019-08-27*\n* Normalize ids before looking up in named export map ([#406](https://github.com/rollup/rollup-plugin-commonjs/issues/406))\n* Update README.md with note on symlinks ([#405](https://github.com/rollup/rollup-plugin-commonjs/issues/405))\n\n## 10.0.2\n*2019-08-03*\n* Support preserveSymlinks: false ([#401](https://github.com/rollup/rollup-plugin-commonjs/issues/401))\n\n## 10.0.1\n*2019-06-27*\n* Make tests run with Node 6 again and update dependencies ([#389](https://github.com/rollup/rollup-plugin-commonjs/issues/389))\n* Handle builtins appropriately for resolve 1.11.0 ([#395](https://github.com/rollup/rollup-plugin-commonjs/issues/395))\n\n## 10.0.0\n*2019-05-15*\n* Use new Rollup@1.12 context functions, fix issue when resolveId returns an object ([#387](https://github.com/rollup/rollup-plugin-commonjs/issues/387))\n\n## 9.3.4\n*2019-04-04*\n* Make \"extensions\" optional ([#384](https://github.com/rollup/rollup-plugin-commonjs/issues/384))\n* Use same typing for include and exclude properties ([#385](https://github.com/rollup/rollup-plugin-commonjs/issues/385))\n\n## 9.3.3\n*2019-04-04*\n* Remove colon from module prefixes ([#371](https://github.com/rollup/rollup-plugin-commonjs/issues/371))\n\n## 9.3.2\n*2019-04-04*\n* Use shared extractAssignedNames, fix destructuring issue ([#303](https://github.com/rollup/rollup-plugin-commonjs/issues/303))\n\n## 9.3.1\n*2019-04-04*\n* Include typings in release ([#382](https://github.com/rollup/rollup-plugin-commonjs/issues/382))\n\n## 9.3.0\n*2019-04-03*\n* Add TypeScript types ([#363](https://github.com/rollup/rollup-plugin-commonjs/issues/363))\n\n## 9.2.3\n*2019-04-02*\n* Improve support for ES3 browsers ([#364](https://github.com/rollup/rollup-plugin-commonjs/issues/364))\n* Add note about monorepo usage to readme ([#372](https://github.com/rollup/rollup-plugin-commonjs/issues/372))\n* Add .js extension to generated helper file ([#373](https://github.com/rollup/rollup-plugin-commonjs/issues/373))\n\n## 9.2.2\n*2019-03-25*\n* Handle array destructuring assignment ([#379](https://github.com/rollup/rollup-plugin-commonjs/issues/379))\n\n## 9.2.1\n*2019-02-23*\n* Use correct context when manually resolving ids ([#370](https://github.com/rollup/rollup-plugin-commonjs/issues/370))\n\n## 9.2.0\n*2018-10-10*\n* Fix missing default warning, produce better code when importing known ESM default exports ([#349](https://github.com/rollup/rollup-plugin-commonjs/issues/349))\n* Refactor code and add prettier ([#346](https://github.com/rollup/rollup-plugin-commonjs/issues/346))\n\n## 9.1.8\n*2018-09-18*\n* Ignore virtual modules created by other plugins ([#327](https://github.com/rollup/rollup-plugin-commonjs/issues/327))\n* Add \"location\" and \"process\" to reserved words ([#330](https://github.com/rollup/rollup-plugin-commonjs/issues/330))\n\n## 9.1.6\n*2018-08-24*\n* Keep commonJS detection between instantiations ([#338](https://github.com/rollup/rollup-plugin-commonjs/issues/338))\n\n## 9.1.5\n*2018-08-09*\n* Handle object form of input ([#329](https://github.com/rollup/rollup-plugin-commonjs/issues/329))\n\n## 9.1.4\n*2018-07-27*\n* Make \"from\" a reserved word ([#320](https://github.com/rollup/rollup-plugin-commonjs/issues/320))\n\n## 9.1.3\n*2018-04-30*\n* Fix a caching issue ([#316](https://github.com/rollup/rollup-plugin-commonjs/issues/316))\n\n## 9.1.2\n*2018-04-30*\n* Re-publication of 9.1.0\n\n## 9.1.1\n*2018-04-30*\n* Fix ordering of modules when using rollup 0.58 ([#302](https://github.com/rollup/rollup-plugin-commonjs/issues/302))\n\n## 9.1.0\n\n* Do not automatically wrap modules with return statements in top level arrow functions ([#302](https://github.com/rollup/rollup-plugin-commonjs/issues/302))\n\n## 9.0.0\n\n* Make rollup a peer dependency with a version range ([#300](https://github.com/rollup/rollup-plugin-commonjs/issues/300))\n\n## 8.4.1\n\n* Re-release of 8.3.0 as #287 was actually a breaking change\n\n## 8.4.0\n\n* Better handle non-CJS files that contain CJS keywords ([#285](https://github.com/rollup/rollup-plugin-commonjs/issues/285))\n* Use rollup's plugin context`parse` function ([#287](https://github.com/rollup/rollup-plugin-commonjs/issues/287))\n* Improve error handling ([#288](https://github.com/rollup/rollup-plugin-commonjs/issues/288))\n\n## 8.3.0\n\n* Handle multiple entry points ([#283](https://github.com/rollup/rollup-plugin-commonjs/issues/283))\n* Extract named exports from exported object literals ([#272](https://github.com/rollup/rollup-plugin-commonjs/issues/272))\n* Fix when `options.external` is modified by other plugins ([#264](https://github.com/rollup/rollup-plugin-commonjs/issues/264))\n* Recognize static template strings in require statements ([#271](https://github.com/rollup/rollup-plugin-commonjs/issues/271))\n\n## 8.2.4\n\n* Don't import default from ES modules that don't export default ([#206](https://github.com/rollup/rollup-plugin-commonjs/issues/206))\n\n## 8.2.3\n\n* Prevent duplicate default exports ([#230](https://github.com/rollup/rollup-plugin-commonjs/pull/230))\n* Only include default export when it exists ([#226](https://github.com/rollup/rollup-plugin-commonjs/pull/226))\n* Deconflict `require` aliases ([#232](https://github.com/rollup/rollup-plugin-commonjs/issues/232))\n\n## 8.2.1\n\n* Fix magic-string deprecation warning\n\n## 8.2.0\n\n* Avoid using `index` as a variable name ([#208](https://github.com/rollup/rollup-plugin-commonjs/pull/208))\n\n## 8.1.1\n\n* Compatibility with 0.48 ([#220](https://github.com/rollup/rollup-plugin-commonjs/issues/220))\n\n## 8.1.0\n\n* Handle `options.external` correctly ([#212](https://github.com/rollup/rollup-plugin-commonjs/pull/212))\n* Support top-level return ([#195](https://github.com/rollup/rollup-plugin-commonjs/pull/195))\n\n## 8.0.2\n\n* Fix another `var` rewrite bug ([#181](https://github.com/rollup/rollup-plugin-commonjs/issues/181))\n\n## 8.0.1\n\n* Remove declarators within a var declaration correctly ([#179](https://github.com/rollup/rollup-plugin-commonjs/issues/179))\n\n## 8.0.0\n\n* Prefer the names dependencies are imported by for the common `var foo = require('foo')` pattern ([#176](https://github.com/rollup/rollup-plugin-commonjs/issues/176))\n\n## 7.1.0\n\n* Allow certain `require` statements to pass through unmolested ([#174](https://github.com/rollup/rollup-plugin-commonjs/issues/174))\n\n## 7.0.2\n\n* Handle duplicate default exports ([#158](https://github.com/rollup/rollup-plugin-commonjs/issues/158))\n\n## 7.0.1\n\n* Fix exports with parentheses ([#168](https://github.com/rollup/rollup-plugin-commonjs/issues/168))\n\n## 7.0.0\n\n* Rewrite `typeof module`, `typeof module.exports` and `typeof exports` as `'object'` ([#151](https://github.com/rollup/rollup-plugin-commonjs/issues/151))\n\n## 6.0.1\n\n* Don't overwrite globals ([#127](https://github.com/rollup/rollup-plugin-commonjs/issues/127))\n\n## 6.0.0\n\n* Rewrite top-level `define` as `undefined`, so AMD-first UMD blocks do not cause breakage ([#144](https://github.com/rollup/rollup-plugin-commonjs/issues/144))\n* Support ES2017 syntax ([#132](https://github.com/rollup/rollup-plugin-commonjs/issues/132))\n* Deconflict exported reserved keywords ([#116](https://github.com/rollup/rollup-plugin-commonjs/issues/116))\n\n## 5.0.5\n* Fix parenthesis wrapped exports ([#120](https://github.com/rollup/rollup-plugin-commonjs/issues/120))\n\n## 5.0.4\n\n* Ensure named exports are added to default export in optimised modules ([#112](https://github.com/rollup/rollup-plugin-commonjs/issues/112))\n\n## 5.0.3\n\n* Respect custom `namedExports` in optimised modules ([#35](https://github.com/rollup/rollup-plugin-commonjs/issues/35))\n\n## 5.0.2\n\n* Replace `require` (outside call expressions) with `commonjsRequire` helper ([#77](https://github.com/rollup/rollup-plugin-commonjs/issues/77), [#83](https://github.com/rollup/rollup-plugin-commonjs/issues/83))\n\n## 5.0.1\n\n* Deconflict against globals ([#84](https://github.com/rollup/rollup-plugin-commonjs/issues/84))\n\n## 5.0.0\n\n* Optimise modules that don't need to be wrapped in a function ([#106](https://github.com/rollup/rollup-plugin-commonjs/pull/106))\n* Ignore modules containing `import` and `export` statements ([#96](https://github.com/rollup/rollup-plugin-commonjs/pull/96))\n\n## 4.1.0\n\n* Ignore dead branches ([#93](https://github.com/rollup/rollup-plugin-commonjs/issues/93))\n\n## 4.0.1\n\n* Fix `ignoreGlobal` option ([#86](https://github.com/rollup/rollup-plugin-commonjs/pull/86))\n\n## 4.0.0\n\n* Better interop and smaller output ([#92](https://github.com/rollup/rollup-plugin-commonjs/pull/92))\n\n## 3.3.1\n\n* Deconflict export and local module ([rollup/rollup#554](https://github.com/rollup/rollup/issues/554))\n\n## 3.3.0\n\n* Keep the order of execution for require calls ([#43](https://github.com/rollup/rollup-plugin-commonjs/pull/43))\n* Use interopDefault as helper ([#42](https://github.com/rollup/rollup-plugin-commonjs/issues/42))\n\n## 3.2.0\n\n* Use named exports as a function when no default export is defined ([#524](https://github.com/rollup/rollup/issues/524))\n\n## 3.1.0\n\n* Replace `typeof require` with `'function'` ([#38](https://github.com/rollup/rollup-plugin-commonjs/issues/38))\n* Don't attempt to resolve entry file relative to importer ([#63](https://github.com/rollup/rollup-plugin-commonjs/issues/63))\n\n## 3.0.2\n\n* Handle multiple references to `global`\n\n## 3.0.1\n\n* Return a `name`\n\n## 3.0.0\n\n* Make `transform` stateless ([#71](https://github.com/rollup/rollup-plugin-commonjs/pull/71))\n* Support web worker `global` ([#50](https://github.com/rollup/rollup-plugin-commonjs/issues/50))\n* Ignore global with `options.ignoreGlobal` ([#48](https://github.com/rollup/rollup-plugin-commonjs/issues/48))\n\n## 2.2.1\n\n* Prevent false positives with `namedExports` ([#36](https://github.com/rollup/rollup-plugin-commonjs/issues/36))\n\n## 2.2.0\n\n* Rewrite top-level `this` expressions to mean the same as `global`  ([#31](https://github.com/rollup/rollup-plugin-commonjs/issues/31))\n\n## 2.1.0\n\n* Optimised module wrappers ([#20](https://github.com/rollup/rollup-plugin-commonjs/pull/20))\n* Allow control over named exports via `options.namedExports` ([#18](https://github.com/rollup/rollup-plugin-commonjs/issues/18))\n* Handle bare imports correctly ([#23](https://github.com/rollup/rollup-plugin-commonjs/issues/23))\n* Blacklist all reserved words as export names ([#21](https://github.com/rollup/rollup-plugin-commonjs/issues/21))\n* Configure allowed file extensions via `options.extensions` ([#27](https://github.com/rollup/rollup-plugin-commonjs/pull/27))\n\n## 2.0.0\n\n* Support for transpiled modules – `exports.default` is used as the default export in place of `module.exports`, if applicable, and `__esModule` is not exported ([#16](https://github.com/rollup/rollup-plugin-commonjs/pull/16))\n\n## 1.4.0\n\n* Generate sourcemaps by default\n\n## 1.3.0\n\n* Handle references to `global` ([#6](https://github.com/rollup/rollup-plugin-commonjs/issues/6))\n\n## 1.2.0\n\n* Generate named exports where possible ([#5](https://github.com/rollup/rollup-plugin-commonjs/issues/5))\n* Handle shadowed `require`/`module`/`exports`\n\n## 1.1.0\n\n* Handle dots in filenames ([#3](https://github.com/rollup/rollup-plugin-commonjs/issues/3))\n* Wrap modules in IIFE for more readable output\n\n## 1.0.0\n\n* Stable release, now that Rollup supports plugins\n\n## 0.2.1\n\n* Allow mixed CommonJS/ES6 imports/exports\n* Use `var` instead of `let`\n\n## 0.2.0\n\n* Sourcemap support\n* Support `options.include` and `options.exclude`\n* Bail early if module is obviously not a CommonJS module\n\n## 0.1.1\n\nAdd dist files to package (whoops!)\n\n## 0.1.0\n\n* First release\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2017 [these people](https://github.com/rollup/rollup-plugin-commonjs/graphs/contributors)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Moved\n\nThis module has moved and is now available at [@rollup/plugin-commonjs](https://github.com/rollup/plugins). Please update your dependencies. This repository is no longer maintained.\n\n\n# rollup-plugin-commonjs [![Build Status][travis-img]][travis]\n\n[travis-img]: https://travis-ci.org/rollup/rollup-plugin-commonjs.svg\n[travis]: https://travis-ci.org/rollup/rollup-plugin-commonjs\n\nConvert CommonJS modules to ES6, so they can be included in a Rollup bundle\n\n\n## Installation\n\n```bash\nnpm install --save-dev rollup-plugin-commonjs\n```\n\n\n## Usage\n\nTypically, you would use this plugin alongside [rollup-plugin-node-resolve](https://github.com/rollup/rollup-plugin-node-resolve), so that you could bundle your CommonJS dependencies in `node_modules`.\n\n```js\n// rollup.config.js\nimport commonjs from 'rollup-plugin-commonjs';\nimport nodeResolve from 'rollup-plugin-node-resolve';\n\nexport default {\n  input: 'main.js',\n  output: {\n    file: 'bundle.js',\n    format: 'iife'\n  },\n  plugins: [\n    nodeResolve({\n      jsnext: true,\n      main: true\n    }),\n\n    commonjs({\n      // non-CommonJS modules will be ignored, but you can also\n      // specifically include/exclude files\n      include: 'node_modules/**',  // Default: undefined\n      exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],  // Default: undefined\n      // these values can also be regular expressions\n      // include: /node_modules/\n\n      // search for files other than .js files (must already\n      // be transpiled by a previous plugin!)\n      extensions: [ '.js', '.coffee' ],  // Default: [ '.js' ]\n\n      // if true then uses of `global` won't be dealt with by this plugin\n      ignoreGlobal: false,  // Default: false\n\n      // if false then skip sourceMap generation for CommonJS modules\n      sourceMap: false,  // Default: true\n\n      // explicitly specify unresolvable named exports\n      // (see below for more details)\n      namedExports: { 'react': ['createElement', 'Component' ] },  // Default: undefined\n\n      // sometimes you have to leave require statements\n      // unconverted. Pass an array containing the IDs\n      // or a `id => boolean` function. Only use this\n      // option if you know what you're doing!\n      ignore: [ 'conditional-runtime-dependency' ]\n    })\n  ]\n};\n```\n\n### Usage with symlinks\n\nSymlinks are common in monorepos and are also created by the `npm link` command. Rollup with `rollup-plugin-node-resolve` resolves modules to their real paths by default. So `include` and `exclude` paths should handle real paths rather than symlinked paths (e.g. `../common/node_modules/**` instead of `node_modules/**`). You may also use a regular expression for `include` that works regardless of base path. Try this:\n\n```js\ncommonjs({\n  include: /node_modules/\n})\n```\n\nWhether symlinked module paths are [realpathed](http://man7.org/linux/man-pages/man3/realpath.3.html) or preserved depends on Rollup's `preserveSymlinks` setting, which is false by default, matching Node.js' default behavior. Setting `preserveSymlinks` to true in your Rollup config will cause `import` and `export` to match based on symlinked paths instead.\n\n### Custom named exports\n\nThis plugin will attempt to create named exports, where appropriate, so you can do this...\n\n```js\n// importer.js\nimport { named } from './exporter.js';\n\n// exporter.js\nmodule.exports = { named: 42 }; // or `exports.named = 42;`\n```\n\n...but that's not always possible:\n\n```js\n// importer.js\nimport { named } from 'my-lib';\n\n// my-lib.js\nvar myLib = exports;\nmyLib.named = 'you can\\'t see me';\n```\n\nIn those cases, you can specify custom named exports:\n\n```js\ncommonjs({\n  namedExports: {\n    // left-hand side can be an absolute path, a path\n    // relative to the current directory, or the name\n    // of a module in node_modules\n    'my-lib': [ 'named' ]\n  }\n})\n```\n\n\n## Strict mode\n\nES modules are *always* parsed in strict mode. That means that certain non-strict constructs (like octal literals) will be treated as syntax errors when Rollup parses modules that use them. Some older CommonJS modules depend on those constructs, and if you depend on them your bundle will blow up. There's basically nothing we can do about that.\n\nLuckily, there is absolutely no good reason *not* to use strict mode for everything — so the solution to this problem is to lobby the authors of those modules to update them.\n\n\n## License\n\nMIT\n"
  },
  {
    "path": "appveyor.yml",
    "content": "# http://www.appveyor.com/docs/appveyor-yml\n\nversion: \"{build}\"\n\nclone_depth: 10\n\ninit:\n  - git config --global core.autocrlf false\n  - git config --global core.symlinks true\n\nenvironment:\n  matrix:\n    # node.js\n    - nodejs_version: 8\n\ninstall:\n  - ps: Install-Product node $env:nodejs_version\n  - IF %nodejs_version% LSS 7 npm -g install npm@4\n  - npm install\n\nbuild: off\n\ntest_script:\n  - node --version && npm --version\n  - npm test\n\nmatrix:\n  fast_finish: false\n\n# cache:\n#   - C:\\Users\\appveyor\\AppData\\Roaming\\npm-cache -> package.json     # npm cache\n#   - node_modules -> package.json                                    # local npm modules\n"
  },
  {
    "path": "index.d.ts",
    "content": "import { Plugin } from 'rollup';\n\ninterface RollupCommonJSOptions {\n\t/**\n\t * non-CommonJS modules will be ignored, but you can also\n\t * specifically include/exclude files\n\t * @default undefined\n\t */\n\tinclude?: string | RegExp | ReadonlyArray<string | RegExp>,\n\t/**\n\t * non-CommonJS modules will be ignored, but you can also\n\t * specifically include/exclude files\n\t * @default undefined\n\t */\n\texclude?: string | RegExp | ReadonlyArray<string | RegExp>,\n\t/**\n\t * search for files other than .js files (must already\n\t * be transpiled by a previous plugin!)\n\t * @default [ '.js' ]\n\t */\n\textensions?: ReadonlyArray<string | RegExp>,\n\t/**\n\t * if true then uses of `global` won't be dealt with by this plugin\n\t * @default false\n\t */\n\tignoreGlobal?: boolean,\n\t/**\n\t * if false then skip sourceMap generation for CommonJS modules\n\t * @default true\n\t */\n\tsourceMap?: boolean,\n\t/**\n\t * explicitly specify unresolvable named exports\n\t * ([see below for more details](https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports))\n\t * @default undefined\n\t */\n\tnamedExports?: { [package: string]: ReadonlyArray<string> },\n\t/**\n\t * sometimes you have to leave require statements\n\t * unconverted. Pass an array containing the IDs\n\t * or a `id => boolean` function. Only use this\n\t * option if you know what you're doing!\n\t */\n\tignore?: ReadonlyArray<string | ((id: string) => boolean)>,\n}\n\n/**\n * Convert CommonJS modules to ES6, so they can be included in a Rollup bundle\n */\nexport default function commonjs(options?: RollupCommonJSOptions): Plugin;\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"rollup-plugin-commonjs\",\n  \"version\": \"10.1.0\",\n  \"description\": \"Convert CommonJS modules to ES2015\",\n  \"main\": \"dist/rollup-plugin-commonjs.cjs.js\",\n  \"module\": \"dist/rollup-plugin-commonjs.es.js\",\n  \"jsnext:main\": \"dist/rollup-plugin-commonjs.es.js\",\n  \"scripts\": {\n    \"test\": \"npm run test:only\",\n    \"test:only\": \"mocha && tsc\",\n    \"pretest\": \"npm run build\",\n    \"build\": \"shx rm -rf dist/* && rollup -c\",\n    \"dev\": \"rollup -c -w\",\n    \"lint\": \"prettier --write src/**/*.js test/test.js test/**/_config.js && eslint --fix src/**/*.js test/test.js test/**/_config.js\",\n    \"prepublishOnly\": \"npm run lint && npm run test:only\",\n    \"prepare\": \"npm run build\"\n  },\n  \"files\": [\n    \"src\",\n    \"dist\",\n    \"index.d.ts\",\n    \"README.md\"\n  ],\n  \"peerDependencies\": {\n    \"rollup\": \">=1.12.0\"\n  },\n  \"dependencies\": {\n    \"estree-walker\": \"^0.6.1\",\n    \"is-reference\": \"^1.1.2\",\n    \"magic-string\": \"^0.25.2\",\n    \"resolve\": \"^1.11.0\",\n    \"rollup-pluginutils\": \"^2.8.1\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.4.5\",\n    \"@babel/preset-env\": \"^7.4.5\",\n    \"@babel/register\": \"^7.4.4\",\n    \"acorn\": \"^6.1.1\",\n    \"eslint\": \"^6.0.1\",\n    \"eslint-plugin-import\": \"^2.18.0\",\n    \"husky\": \"^2.4.1\",\n    \"lint-staged\": \"^8.2.1\",\n    \"locate-character\": \"^2.0.5\",\n    \"mocha\": \"^6.1.4\",\n    \"prettier\": \"^1.18.2\",\n    \"require-relative\": \"^0.8.7\",\n    \"rollup\": \"^1.16.2\",\n    \"rollup-plugin-babel\": \"^4.3.3\",\n    \"rollup-plugin-json\": \"^4.0.0\",\n    \"rollup-plugin-node-resolve\": \"^5.1.0\",\n    \"shx\": \"^0.3.2\",\n    \"source-map\": \"^0.6.1\",\n    \"source-map-support\": \"^0.5.12\",\n    \"typescript\": \"^3.5.2\"\n  },\n  \"repository\": \"rollup/rollup-plugin-commonjs\",\n  \"author\": \"Rich Harris\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/rollup/rollup-plugin-commonjs/issues\"\n  },\n  \"homepage\": \"https://github.com/rollup/rollup-plugin-commonjs\"\n}\n"
  },
  {
    "path": "rollup.config.js",
    "content": "import babel from 'rollup-plugin-babel';\nimport json from 'rollup-plugin-json';\nimport pkg from './package.json';\n\nexport default {\n\tinput: 'src/index.js',\n\tplugins: [\n\t\tjson(),\n\t\tbabel()\n\t],\n\texternal: Object.keys(pkg.dependencies).concat(['fs', 'path']),\n\toutput: [\n\t\t{\n\t\t\tformat: 'es',\n\t\t\tfile: pkg.module,\n\t\t\tsourcemap: true\n\t\t},\n\t\t{\n\t\t\tformat: 'cjs',\n\t\t\tfile: pkg.main,\n\t\t\tsourcemap: true\n\t\t}\n\t]\n};\n"
  },
  {
    "path": "src/ast-utils.js",
    "content": "export { default as isReference } from 'is-reference';\n\nexport function flatten(node) {\n\tconst parts = [];\n\n\twhile (node.type === 'MemberExpression') {\n\t\tif (node.computed) return null;\n\n\t\tparts.unshift(node.property.name);\n\t\tnode = node.object;\n\t}\n\n\tif (node.type !== 'Identifier') return null;\n\n\tconst name = node.name;\n\tparts.unshift(name);\n\n\treturn { name, keypath: parts.join('.') };\n}\n\nexport function extractNames(node) {\n\tconst names = [];\n\textractors[node.type](names, node);\n\treturn names;\n}\n\nfunction getExtractor (type) {\n\tconst extractor = extractors[type];\n\tif (!extractor)\n\t\tthrow new SyntaxError(`${type} pattern not supported.`);\n\treturn extractor;\n}\n\nconst extractors = {\n\tIdentifier(names, node) {\n\t\tnames.push(node.name);\n\t},\n\n\tObjectPattern(names, node) {\n\t\tnode.properties.forEach(prop => {\n\t\t\tgetExtractor(prop.value.type)(names, prop.value);\n\t\t});\n\t},\n\n\tArrayPattern(names, node) {\n\t\tnode.elements.forEach(element => {\n\t\t\tif (!element) return;\n\t\t\tgetExtractor(element.type)(names, element);\n\t\t});\n\t},\n\n\tRestElement(names, node) {\n\t\tgetExtractor(node.argument.type)(names, node.argument);\n\t},\n\n\tAssignmentPattern(names, node) {\n\t\tgetExtractor(node.left.type)(names, node.left);\n\t}\n};\n\nexport function isTruthy(node) {\n\tif (node.type === 'Literal') return !!node.value;\n\tif (node.type === 'ParenthesizedExpression') return isTruthy(node.expression);\n\tif (node.operator in operators) return operators[node.operator](node);\n}\n\nexport function isFalsy(node) {\n\treturn not(isTruthy(node));\n}\n\nfunction not(value) {\n\treturn value === undefined ? value : !value;\n}\n\nfunction equals(a, b, strict) {\n\tif (a.type !== b.type) return undefined;\n\tif (a.type === 'Literal') return strict ? a.value === b.value : a.value == b.value;\n}\n\nconst operators = {\n\t'==': x => {\n\t\treturn equals(x.left, x.right, false);\n\t},\n\n\t'!=': x => not(operators['=='](x)),\n\n\t'===': x => {\n\t\treturn equals(x.left, x.right, true);\n\t},\n\n\t'!==': x => not(operators['==='](x)),\n\n\t'!': x => isFalsy(x.argument),\n\n\t'&&': x => isTruthy(x.left) && isTruthy(x.right),\n\n\t'||': x => isTruthy(x.left) || isTruthy(x.right)\n};\n"
  },
  {
    "path": "src/helpers.js",
    "content": "export const PROXY_SUFFIX = '?commonjs-proxy';\nexport const getProxyId = id => `\\0${id}${PROXY_SUFFIX}`;\nexport const getIdFromProxyId = proxyId => proxyId.slice(1, -PROXY_SUFFIX.length);\n\nexport const EXTERNAL_SUFFIX = '?commonjs-external';\nexport const getExternalProxyId = id => `\\0${id}${EXTERNAL_SUFFIX}`;\nexport const getIdFromExternalProxyId = proxyId => proxyId.slice(1, -EXTERNAL_SUFFIX.length);\n\nexport const HELPERS_ID = '\\0commonjsHelpers.js';\n\n// `x['default']` is used instead of `x.default` for backward compatibility with ES3 browsers.\n// Minifiers like uglify will usually transpile it back if compatibility with ES3 is not enabled.\nexport const HELPERS = `\nexport var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};\n\nexport function commonjsRequire () {\n\tthrow new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');\n}\n\nexport function unwrapExports (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nexport function createCommonjsModule(fn, module) {\n\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n}\n\nexport function getCjsExportFromNamespace (n) {\n\treturn n && n['default'] || n;\n}`;\n"
  },
  {
    "path": "src/index.js",
    "content": "import { realpathSync, existsSync } from 'fs';\nimport { extname, resolve, normalize } from 'path';\nimport { sync as nodeResolveSync, isCore } from 'resolve';\nimport { createFilter } from 'rollup-pluginutils';\nimport { peerDependencies } from '../package.json';\nimport {\n\tEXTERNAL_SUFFIX,\n\tgetIdFromExternalProxyId,\n\tgetIdFromProxyId,\n\tHELPERS,\n\tHELPERS_ID,\n\tPROXY_SUFFIX\n} from './helpers';\nimport { getIsCjsPromise, setIsCjsPromise } from './is-cjs';\nimport { getResolveId } from './resolve-id';\nimport { checkEsModule, hasCjsKeywords, transformCommonjs } from './transform.js';\nimport { getName } from './utils.js';\n\nexport default function commonjs(options = {}) {\n\tconst extensions = options.extensions || ['.js'];\n\tconst filter = createFilter(options.include, options.exclude);\n\tconst ignoreGlobal = options.ignoreGlobal;\n\n\tconst customNamedExports = {};\n\tif (options.namedExports) {\n\t\tObject.keys(options.namedExports).forEach(id => {\n\t\t\tlet resolveId = id;\n\t\t\tlet resolvedId;\n\n\t\t\tif (isCore(id)) {\n\t\t\t\t// resolve will not find npm modules with the same name as\n\t\t\t\t// core modules without a trailing slash. Since core modules\n\t\t\t\t// must be external, we can assume any core modules defined\n\t\t\t\t// here are npm modules by that name.\n\t\t\t\tresolveId += '/';\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tresolvedId = nodeResolveSync(resolveId, { basedir: process.cwd() });\n\t\t\t} catch (err) {\n\t\t\t\tresolvedId = resolve(id);\n\t\t\t}\n\n\t\t\t// Note: customNamedExport's keys must be normalized file paths.\n\t\t\t// resolve and nodeResolveSync both return normalized file paths\n\t\t\t// so no additional normalization is necessary.\n\t\t\tcustomNamedExports[resolvedId] = options.namedExports[id];\n\n\t\t\tif (existsSync(resolvedId)) {\n\t\t\t\tconst realpath = realpathSync(resolvedId);\n\t\t\t\tif (realpath !== resolvedId) {\n\t\t\t\t\tcustomNamedExports[realpath] = options.namedExports[id];\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tconst esModulesWithoutDefaultExport = new Set();\n\tconst esModulesWithDefaultExport = new Set();\n\tconst allowDynamicRequire = !!options.ignore; // TODO maybe this should be configurable?\n\n\tconst ignoreRequire =\n\t\ttypeof options.ignore === 'function'\n\t\t\t? options.ignore\n\t\t\t: Array.isArray(options.ignore)\n\t\t\t\t? id => options.ignore.includes(id)\n\t\t\t\t: () => false;\n\n\tconst resolveId = getResolveId(extensions);\n\n\tconst sourceMap = options.sourceMap !== false;\n\n\tfunction transformAndCheckExports(code, id) {\n\t\t{\n\t\t\tconst { isEsModule, hasDefaultExport, ast } = checkEsModule(this.parse, code, id);\n\t\t\tif (isEsModule) {\n\t\t\t\t(hasDefaultExport ? esModulesWithDefaultExport : esModulesWithoutDefaultExport).add(id);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// it is not an ES module but it does not have CJS-specific elements.\n\t\t\tif (!hasCjsKeywords(code, ignoreGlobal)) {\n\t\t\t\tesModulesWithoutDefaultExport.add(id);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst normalizedId = normalize(id);\n\n\t\t\tconst transformed = transformCommonjs(\n\t\t\t\tthis.parse,\n\t\t\t\tcode,\n\t\t\t\tid,\n\t\t\t\tthis.getModuleInfo(id).isEntry,\n\t\t\t\tignoreGlobal,\n\t\t\t\tignoreRequire,\n\t\t\t\tcustomNamedExports[normalizedId],\n\t\t\t\tsourceMap,\n\t\t\t\tallowDynamicRequire,\n\t\t\t\tast\n\t\t\t);\n\t\t\tif (!transformed) {\n\t\t\t\tesModulesWithoutDefaultExport.add(id);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn transformed;\n\t\t}\n\t}\n\n\treturn {\n\t\tname: 'commonjs',\n\n\t\tbuildStart() {\n\t\t\tconst [major, minor] = this.meta.rollupVersion.split('.').map(Number);\n\t\t\tconst minVersion = peerDependencies.rollup.slice(2);\n\t\t\tconst [minMajor, minMinor] = minVersion.split('.').map(Number);\n\t\t\tif (major < minMajor || (major === minMajor && minor < minMinor)) {\n\t\t\t\tthis.error(\n\t\t\t\t\t`Insufficient Rollup version: \"rollup-plugin-commonjs\" requires at least rollup@${minVersion} but found rollup@${this.meta.rollupVersion}.`\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\tresolveId,\n\n\t\tload(id) {\n\t\t\tif (id === HELPERS_ID) return HELPERS;\n\n\t\t\t// generate proxy modules\n\t\t\tif (id.endsWith(EXTERNAL_SUFFIX)) {\n\t\t\t\tconst actualId = getIdFromExternalProxyId(id);\n\t\t\t\tconst name = getName(actualId);\n\n\t\t\t\treturn `import ${name} from ${JSON.stringify(actualId)}; export default ${name};`;\n\t\t\t}\n\n\t\t\tif (id.endsWith(PROXY_SUFFIX)) {\n\t\t\t\tconst actualId = getIdFromProxyId(id);\n\t\t\t\tconst name = getName(actualId);\n\n\t\t\t\treturn getIsCjsPromise(actualId).then(isCjs => {\n\t\t\t\t\tif (isCjs)\n\t\t\t\t\t\treturn `import { __moduleExports } from ${JSON.stringify(\n\t\t\t\t\t\t\tactualId\n\t\t\t\t\t\t)}; export default __moduleExports;`;\n\t\t\t\t\telse if (esModulesWithoutDefaultExport.has(actualId))\n\t\t\t\t\t\treturn `import * as ${name} from ${JSON.stringify(actualId)}; export default ${name};`;\n\t\t\t\t\telse if (esModulesWithDefaultExport.has(actualId)) {\n\t\t\t\t\t\treturn `export {default} from ${JSON.stringify(actualId)};`;\n\t\t\t\t\t} else\n\t\t\t\t\t\treturn `import * as ${name} from ${JSON.stringify(\n\t\t\t\t\t\t\tactualId\n\t\t\t\t\t\t)}; import {getCjsExportFromNamespace} from \"${HELPERS_ID}\"; export default getCjsExportFromNamespace(${name})`;\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\n\t\ttransform(code, id) {\n\t\t\tif (!filter(id) || extensions.indexOf(extname(id)) === -1) {\n\t\t\t\tsetIsCjsPromise(id, null);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tlet transformed;\n\t\t\ttry {\n\t\t\t\ttransformed = transformAndCheckExports.call(this, code, id);\n\t\t\t} catch (err) {\n\t\t\t\ttransformed = null;\n\t\t\t\tthis.error(err, err.loc);\n\t\t\t}\n\n\t\t\tsetIsCjsPromise(id, Boolean(transformed));\n\t\t\treturn transformed;\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "src/is-cjs.js",
    "content": "const isCjsPromises = new Map();\n\nexport function getIsCjsPromise(id) {\n\tlet isCjsPromise = isCjsPromises.get(id);\n\tif (isCjsPromise) return isCjsPromise.promise;\n\n\tconst promise = new Promise(resolve => {\n\t\tisCjsPromise = {\n\t\t\tresolve,\n\t\t\tpromise: undefined\n\t\t};\n\t\tisCjsPromises.set(id, isCjsPromise);\n\t});\n\tisCjsPromise.promise = promise;\n\n\treturn promise;\n}\n\nexport function setIsCjsPromise(id, resolution) {\n\tconst isCjsPromise = isCjsPromises.get(id);\n\tif (isCjsPromise) {\n\t\tif (isCjsPromise.resolve) {\n\t\t\tisCjsPromise.resolve(resolution);\n\t\t\tisCjsPromise.resolve = undefined;\n\t\t}\n\t} else {\n\t\tisCjsPromises.set(id, { promise: Promise.resolve(resolution), resolve: undefined });\n\t}\n}\n"
  },
  {
    "path": "src/resolve-id.js",
    "content": "import { statSync } from 'fs';\nimport { dirname, resolve, sep } from 'path';\nimport {\n\tgetExternalProxyId,\n\tgetIdFromProxyId,\n\tgetProxyId,\n\tHELPERS_ID,\n\tPROXY_SUFFIX\n} from './helpers';\n\nfunction getCandidatesForExtension(resolved, extension) {\n\treturn [resolved + extension, resolved + `${sep}index${extension}`];\n}\n\nfunction getCandidates(resolved, extensions) {\n\treturn extensions.reduce(\n\t\t(paths, extension) => paths.concat(getCandidatesForExtension(resolved, extension)),\n\t\t[resolved]\n\t);\n}\n\nexport function getResolveId(extensions) {\n\tfunction resolveExtensions(importee, importer) {\n\t\tif (importee[0] !== '.' || !importer) return; // not our problem\n\n\t\tconst resolved = resolve(dirname(importer), importee);\n\t\tconst candidates = getCandidates(resolved, extensions);\n\n\t\tfor (let i = 0; i < candidates.length; i += 1) {\n\t\t\ttry {\n\t\t\t\tconst stats = statSync(candidates[i]);\n\t\t\t\tif (stats.isFile()) return { id: candidates[i] };\n\t\t\t} catch (err) {\n\t\t\t\t/* noop */\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction resolveId(importee, importer) {\n\t\tconst isProxyModule = importee.endsWith(PROXY_SUFFIX);\n\t\tif (isProxyModule) {\n\t\t\timportee = getIdFromProxyId(importee);\n\t\t} else if (importee.startsWith('\\0')) {\n\t\t\tif (importee === HELPERS_ID) {\n\t\t\t\treturn importee;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\n\t\tif (importer && importer.endsWith(PROXY_SUFFIX)) {\n\t\t\timporter = getIdFromProxyId(importer);\n\t\t}\n\n\t\treturn this.resolve(importee, importer, { skipSelf: true }).then(resolved => {\n\t\t\tif (!resolved) {\n\t\t\t\tresolved = resolveExtensions(importee, importer);\n\t\t\t}\n\t\t\tif (isProxyModule) {\n\t\t\t\tif (!resolved) {\n\t\t\t\t\treturn { id: getExternalProxyId(importee), external: false };\n\t\t\t\t}\n\t\t\t\tresolved.id = (resolved.external ? getExternalProxyId : getProxyId)(resolved.id);\n\t\t\t\tresolved.external = false;\n\t\t\t\treturn resolved;\n\t\t\t}\n\t\t\treturn resolved;\n\t\t});\n\t}\n\n\treturn resolveId;\n}\n"
  },
  {
    "path": "src/transform.js",
    "content": "import { walk } from 'estree-walker';\nimport MagicString from 'magic-string';\nimport { attachScopes, extractAssignedNames, makeLegalIdentifier } from 'rollup-pluginutils';\nimport { flatten, isFalsy, isReference, isTruthy } from './ast-utils.js';\nimport { getProxyId, HELPERS_ID } from './helpers';\nimport { getName } from './utils.js';\n\nconst reserved = 'process location abstract arguments boolean break byte case catch char class const continue debugger default delete do double else enum eval export extends false final finally float for from function goto if implements import in instanceof int interface let long native new null package private protected public return short static super switch synchronized this throw throws transient true try typeof var void volatile while with yield'.split(\n\t' '\n);\nconst blacklist = { __esModule: true };\nreserved.forEach(word => (blacklist[word] = true));\n\nconst exportsPattern = /^(?:module\\.)?exports(?:\\.([a-zA-Z_$][a-zA-Z_$0-9]*))?$/;\n\nconst firstpassGlobal = /\\b(?:require|module|exports|global)\\b/;\nconst firstpassNoGlobal = /\\b(?:require|module|exports)\\b/;\nconst importExportDeclaration = /^(?:Import|Export(?:Named|Default))Declaration/;\nconst functionType = /^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/;\n\nfunction deconflict(scope, globals, identifier) {\n\tlet i = 1;\n\tlet deconflicted = identifier;\n\n\twhile (scope.contains(deconflicted) || globals.has(deconflicted) || deconflicted in blacklist)\n\t\tdeconflicted = `${identifier}_${i++}`;\n\tscope.declarations[deconflicted] = true;\n\n\treturn deconflicted;\n}\n\nfunction tryParse(parse, code, id) {\n\ttry {\n\t\treturn parse(code, { allowReturnOutsideFunction: true });\n\t} catch (err) {\n\t\terr.message += ` in ${id}`;\n\t\tthrow err;\n\t}\n}\n\nexport function hasCjsKeywords(code, ignoreGlobal) {\n\tconst firstpass = ignoreGlobal ? firstpassNoGlobal : firstpassGlobal;\n\treturn firstpass.test(code);\n}\n\nexport function checkEsModule(parse, code, id) {\n\tconst ast = tryParse(parse, code, id);\n\n\tlet isEsModule = false;\n\tfor (const node of ast.body) {\n\t\tif (node.type === 'ExportDefaultDeclaration')\n\t\t\treturn { isEsModule: true, hasDefaultExport: true, ast };\n\t\tif (node.type === 'ExportNamedDeclaration') {\n\t\t\tisEsModule = true;\n\t\t\tfor (const specifier of node.specifiers) {\n\t\t\t\tif (specifier.exported.name === 'default') {\n\t\t\t\t\treturn { isEsModule: true, hasDefaultExport: true, ast };\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (importExportDeclaration.test(node.type)) isEsModule = true;\n\t}\n\n\treturn { isEsModule, hasDefaultExport: false, ast };\n}\n\nexport function transformCommonjs(\n\tparse,\n\tcode,\n\tid,\n\tisEntry,\n\tignoreGlobal,\n\tignoreRequire,\n\tcustomNamedExports,\n\tsourceMap,\n\tallowDynamicRequire,\n\tastCache\n) {\n\tconst ast = astCache || tryParse(parse, code, id);\n\n\tconst magicString = new MagicString(code);\n\n\tconst required = {};\n\t// Because objects have no guaranteed ordering, yet we need it,\n\t// we need to keep track of the order in a array\n\tconst sources = [];\n\n\tlet uid = 0;\n\n\tlet scope = attachScopes(ast, 'scope');\n\tconst uses = { module: false, exports: false, global: false, require: false };\n\n\tlet lexicalDepth = 0;\n\tlet programDepth = 0;\n\n\tconst globals = new Set();\n\n\tconst HELPERS_NAME = deconflict(scope, globals, 'commonjsHelpers'); // TODO technically wrong since globals isn't populated yet, but ¯\\_(ツ)_/¯\n\n\tconst namedExports = {};\n\n\t// TODO handle transpiled modules\n\tlet shouldWrap = /__esModule/.test(code);\n\n\tfunction isRequireStatement(node) {\n\t\tif (!node) return;\n\t\tif (node.type !== 'CallExpression') return;\n\t\tif (node.callee.name !== 'require' || scope.contains('require')) return;\n\t\tif (node.arguments.length === 0) return; // Weird case of require() without arguments\n\t\treturn true;\n\t}\n\n\tfunction hasDynamicArguments(node) {\n\t\treturn (\n\t\t\tnode.arguments.length > 1 ||\n\t\t\t(node.arguments[0].type !== 'Literal' &&\n\t\t\t\t(node.arguments[0].type !== 'TemplateLiteral' || node.arguments[0].expressions.length > 0))\n\t\t);\n\t}\n\n\tfunction isStaticRequireStatement(node) {\n\t\tif (!isRequireStatement(node)) return;\n\t\tif (hasDynamicArguments(node)) return;\n\t\tif (ignoreRequire(node.arguments[0].value)) return;\n\t\treturn true;\n\t}\n\n\tfunction getRequireStringArg(node) {\n\t\treturn node.arguments[0].type === 'Literal'\n\t\t\t? node.arguments[0].value\n\t\t\t: node.arguments[0].quasis[0].value.cooked;\n\t}\n\n\tfunction getRequired(node, name) {\n\t\tconst sourceId = getRequireStringArg(node);\n\t\tconst existing = required[sourceId];\n\t\tif (existing === undefined) {\n\t\t\tif (!name) {\n\t\t\t\tdo name = `require$$${uid++}`;\n\t\t\t\twhile (scope.contains(name));\n\t\t\t}\n\n\t\t\tsources.push(sourceId);\n\t\t\trequired[sourceId] = { source: sourceId, name, importsDefault: false };\n\t\t}\n\n\t\treturn required[sourceId];\n\t}\n\n\t// do a first pass, see which names are assigned to. This is necessary to prevent\n\t// illegally replacing `var foo = require('foo')` with `import foo from 'foo'`,\n\t// where `foo` is later reassigned. (This happens in the wild. CommonJS, sigh)\n\tconst assignedTo = new Set();\n\twalk(ast, {\n\t\tenter(node) {\n\t\t\tif (node.type !== 'AssignmentExpression') return;\n\t\t\tif (node.left.type === 'MemberExpression') return;\n\n\t\t\textractAssignedNames(node.left).forEach(name => {\n\t\t\t\tassignedTo.add(name);\n\t\t\t});\n\t\t}\n\t});\n\n\twalk(ast, {\n\t\tenter(node, parent) {\n\t\t\tif (sourceMap) {\n\t\t\t\tmagicString.addSourcemapLocation(node.start);\n\t\t\t\tmagicString.addSourcemapLocation(node.end);\n\t\t\t}\n\n\t\t\t// skip dead branches\n\t\t\tif (parent && (parent.type === 'IfStatement' || parent.type === 'ConditionalExpression')) {\n\t\t\t\tif (node === parent.consequent && isFalsy(parent.test)) return this.skip();\n\t\t\t\tif (node === parent.alternate && isTruthy(parent.test)) return this.skip();\n\t\t\t}\n\n\t\t\tif (node._skip) return this.skip();\n\n\t\t\tprogramDepth += 1;\n\n\t\t\tif (node.scope) scope = node.scope;\n\t\t\tif (functionType.test(node.type)) lexicalDepth += 1;\n\n\t\t\t// if toplevel return, we need to wrap it\n\t\t\tif (node.type === 'ReturnStatement' && lexicalDepth === 0) {\n\t\t\t\tshouldWrap = true;\n\t\t\t}\n\n\t\t\t// rewrite `this` as `commonjsHelpers.commonjsGlobal`\n\t\t\tif (node.type === 'ThisExpression' && lexicalDepth === 0) {\n\t\t\t\tuses.global = true;\n\t\t\t\tif (!ignoreGlobal)\n\t\t\t\t\tmagicString.overwrite(node.start, node.end, `${HELPERS_NAME}.commonjsGlobal`, {\n\t\t\t\t\t\tstoreName: true\n\t\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// rewrite `typeof module`, `typeof module.exports` and `typeof exports` (https://github.com/rollup/rollup-plugin-commonjs/issues/151)\n\t\t\tif (node.type === 'UnaryExpression' && node.operator === 'typeof') {\n\t\t\t\tconst flattened = flatten(node.argument);\n\t\t\t\tif (!flattened) return;\n\n\t\t\t\tif (scope.contains(flattened.name)) return;\n\n\t\t\t\tif (\n\t\t\t\t\tflattened.keypath === 'module.exports' ||\n\t\t\t\t\tflattened.keypath === 'module' ||\n\t\t\t\t\tflattened.keypath === 'exports'\n\t\t\t\t) {\n\t\t\t\t\tmagicString.overwrite(node.start, node.end, `'object'`, { storeName: false });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// rewrite `require` (if not already handled) `global` and `define`, and handle free references to\n\t\t\t// `module` and `exports` as these mean we need to wrap the module in commonjsHelpers.createCommonjsModule\n\t\t\tif (node.type === 'Identifier') {\n\t\t\t\tif (isReference(node, parent) && !scope.contains(node.name)) {\n\t\t\t\t\tif (node.name in uses) {\n\t\t\t\t\t\tif (node.name === 'require') {\n\t\t\t\t\t\t\tif (allowDynamicRequire) return;\n\t\t\t\t\t\t\tmagicString.overwrite(node.start, node.end, `${HELPERS_NAME}.commonjsRequire`, {\n\t\t\t\t\t\t\t\tstoreName: true\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tuses[node.name] = true;\n\t\t\t\t\t\tif (node.name === 'global' && !ignoreGlobal) {\n\t\t\t\t\t\t\tmagicString.overwrite(node.start, node.end, `${HELPERS_NAME}.commonjsGlobal`, {\n\t\t\t\t\t\t\t\tstoreName: true\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// if module or exports are used outside the context of an assignment\n\t\t\t\t\t\t// expression, we need to wrap the module\n\t\t\t\t\t\tif (node.name === 'module' || node.name === 'exports') {\n\t\t\t\t\t\t\tshouldWrap = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (node.name === 'define') {\n\t\t\t\t\t\tmagicString.overwrite(node.start, node.end, 'undefined', { storeName: true });\n\t\t\t\t\t}\n\n\t\t\t\t\tglobals.add(node.name);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Is this an assignment to exports or module.exports?\n\t\t\tif (node.type === 'AssignmentExpression') {\n\t\t\t\tif (node.left.type !== 'MemberExpression') return;\n\n\t\t\t\tconst flattened = flatten(node.left);\n\t\t\t\tif (!flattened) return;\n\n\t\t\t\tif (scope.contains(flattened.name)) return;\n\n\t\t\t\tconst match = exportsPattern.exec(flattened.keypath);\n\t\t\t\tif (!match || flattened.keypath === 'exports') return;\n\n\t\t\t\tuses[flattened.name] = true;\n\n\t\t\t\t// we're dealing with `module.exports = ...` or `[module.]exports.foo = ...` –\n\t\t\t\t// if this isn't top-level, we'll need to wrap the module\n\t\t\t\tif (programDepth > 3) shouldWrap = true;\n\n\t\t\t\tnode.left._skip = true;\n\n\t\t\t\tif (flattened.keypath === 'module.exports' && node.right.type === 'ObjectExpression') {\n\t\t\t\t\treturn node.right.properties.forEach(prop => {\n\t\t\t\t\t\tif (prop.computed || prop.key.type !== 'Identifier') return;\n\t\t\t\t\t\tconst name = prop.key.name;\n\t\t\t\t\t\tif (name === makeLegalIdentifier(name)) namedExports[name] = true;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (match[1]) namedExports[match[1]] = true;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// if this is `var x = require('x')`, we can do `import x from 'x'`\n\t\t\tif (\n\t\t\t\tnode.type === 'VariableDeclarator' &&\n\t\t\t\tnode.id.type === 'Identifier' &&\n\t\t\t\tisStaticRequireStatement(node.init)\n\t\t\t) {\n\t\t\t\t// for now, only do this for top-level requires. maybe fix this in future\n\t\t\t\tif (scope.parent) return;\n\n\t\t\t\t// edge case — CJS allows you to assign to imports. ES doesn't\n\t\t\t\tif (assignedTo.has(node.id.name)) return;\n\n\t\t\t\tconst required = getRequired(node.init, node.id.name);\n\t\t\t\trequired.importsDefault = true;\n\n\t\t\t\tif (required.name === node.id.name) {\n\t\t\t\t\tnode._shouldRemove = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!isStaticRequireStatement(node)) return;\n\n\t\t\tconst required = getRequired(node);\n\n\t\t\tif (parent.type === 'ExpressionStatement') {\n\t\t\t\t// is a bare import, e.g. `require('foo');`\n\t\t\t\tmagicString.remove(parent.start, parent.end);\n\t\t\t} else {\n\t\t\t\trequired.importsDefault = true;\n\t\t\t\tmagicString.overwrite(node.start, node.end, required.name);\n\t\t\t}\n\n\t\t\tnode.callee._skip = true;\n\t\t},\n\n\t\tleave(node) {\n\t\t\tprogramDepth -= 1;\n\t\t\tif (node.scope) scope = scope.parent;\n\t\t\tif (functionType.test(node.type)) lexicalDepth -= 1;\n\n\t\t\tif (node.type === 'VariableDeclaration') {\n\t\t\t\tlet keepDeclaration = false;\n\t\t\t\tlet c = node.declarations[0].start;\n\n\t\t\t\tfor (let i = 0; i < node.declarations.length; i += 1) {\n\t\t\t\t\tconst declarator = node.declarations[i];\n\n\t\t\t\t\tif (declarator._shouldRemove) {\n\t\t\t\t\t\tmagicString.remove(c, declarator.end);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!keepDeclaration) {\n\t\t\t\t\t\t\tmagicString.remove(c, declarator.start);\n\t\t\t\t\t\t\tkeepDeclaration = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tc = declarator.end;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!keepDeclaration) {\n\t\t\t\t\tmagicString.remove(node.start, node.end);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tif (\n\t\t!sources.length &&\n\t\t!uses.module &&\n\t\t!uses.exports &&\n\t\t!uses.require &&\n\t\t(ignoreGlobal || !uses.global)\n\t) {\n\t\tif (Object.keys(namedExports).length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Custom named exports were specified for ${id} but it does not appear to be a CommonJS module`\n\t\t\t);\n\t\t}\n\t\treturn null; // not a CommonJS module\n\t}\n\n\tconst includeHelpers = shouldWrap || uses.global || uses.require;\n\tconst importBlock =\n\t\t(includeHelpers ? [`import * as ${HELPERS_NAME} from '${HELPERS_ID}';`] : [])\n\t\t\t.concat(\n\t\t\t\tsources.map(source => {\n\t\t\t\t\t// import the actual module before the proxy, so that we know\n\t\t\t\t\t// what kind of proxy to build\n\t\t\t\t\treturn `import '${source}';`;\n\t\t\t\t}),\n\t\t\t\tsources.map(source => {\n\t\t\t\t\tconst { name, importsDefault } = required[source];\n\t\t\t\t\treturn `import ${importsDefault ? `${name} from ` : ``}'${getProxyId(source)}';`;\n\t\t\t\t})\n\t\t\t)\n\t\t\t.join('\\n') + '\\n\\n';\n\n\tconst namedExportDeclarations = [];\n\tlet wrapperStart = '';\n\tlet wrapperEnd = '';\n\n\tconst moduleName = deconflict(scope, globals, getName(id));\n\tif (!isEntry) {\n\t\tconst exportModuleExports = {\n\t\t\tstr: `export { ${moduleName} as __moduleExports };`,\n\t\t\tname: '__moduleExports'\n\t\t};\n\n\t\tnamedExportDeclarations.push(exportModuleExports);\n\t}\n\n\tconst name = getName(id);\n\n\tfunction addExport(x) {\n\t\tconst deconflicted = deconflict(scope, globals, name);\n\n\t\tconst declaration =\n\t\t\tdeconflicted === name\n\t\t\t\t? `export var ${x} = ${moduleName}.${x};`\n\t\t\t\t: `var ${deconflicted} = ${moduleName}.${x};\\nexport { ${deconflicted} as ${x} };`;\n\n\t\tnamedExportDeclarations.push({\n\t\t\tstr: declaration,\n\t\t\tname: x\n\t\t});\n\t}\n\n\tif (customNamedExports) customNamedExports.forEach(addExport);\n\n\tconst defaultExportPropertyAssignments = [];\n\tlet hasDefaultExport = false;\n\n\tif (shouldWrap) {\n\t\tconst args = `module${uses.exports ? ', exports' : ''}`;\n\n\t\twrapperStart = `var ${moduleName} = ${HELPERS_NAME}.createCommonjsModule(function (${args}) {\\n`;\n\t\twrapperEnd = `\\n});`;\n\t} else {\n\t\tconst names = [];\n\n\t\tast.body.forEach(node => {\n\t\t\tif (node.type === 'ExpressionStatement' && node.expression.type === 'AssignmentExpression') {\n\t\t\t\tconst left = node.expression.left;\n\t\t\t\tconst flattened = flatten(left);\n\n\t\t\t\tif (!flattened) return;\n\n\t\t\t\tconst match = exportsPattern.exec(flattened.keypath);\n\t\t\t\tif (!match) return;\n\n\t\t\t\tif (flattened.keypath === 'module.exports') {\n\t\t\t\t\thasDefaultExport = true;\n\t\t\t\t\tmagicString.overwrite(left.start, left.end, `var ${moduleName}`);\n\t\t\t\t} else {\n\t\t\t\t\tconst name = match[1];\n\t\t\t\t\tconst deconflicted = deconflict(scope, globals, name);\n\n\t\t\t\t\tnames.push({ name, deconflicted });\n\n\t\t\t\t\tmagicString.overwrite(node.start, left.end, `var ${deconflicted}`);\n\n\t\t\t\t\tconst declaration =\n\t\t\t\t\t\tname === deconflicted\n\t\t\t\t\t\t\t? `export { ${name} };`\n\t\t\t\t\t\t\t: `export { ${deconflicted} as ${name} };`;\n\n\t\t\t\t\tif (name !== 'default') {\n\t\t\t\t\t\tnamedExportDeclarations.push({\n\t\t\t\t\t\t\tstr: declaration,\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t});\n\t\t\t\t\t\tdelete namedExports[name];\n\t\t\t\t\t}\n\n\t\t\t\t\tdefaultExportPropertyAssignments.push(`${moduleName}.${name} = ${deconflicted};`);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tif (!hasDefaultExport && (names.length || !isEntry)) {\n\t\t\twrapperEnd = `\\n\\nvar ${moduleName} = {\\n${names\n\t\t\t\t.map(({ name, deconflicted }) => `\\t${name}: ${deconflicted}`)\n\t\t\t\t.join(',\\n')}\\n};`;\n\t\t}\n\t}\n\tObject.keys(namedExports)\n\t\t.filter(key => !blacklist[key])\n\t\t.forEach(addExport);\n\n\tconst defaultExport = /__esModule/.test(code)\n\t\t? `export default ${HELPERS_NAME}.unwrapExports(${moduleName});`\n\t\t: `export default ${moduleName};`;\n\n\tconst named = namedExportDeclarations\n\t\t.filter(x => x.name !== 'default' || !hasDefaultExport)\n\t\t.map(x => x.str);\n\n\tconst exportBlock =\n\t\t'\\n\\n' +\n\t\t[defaultExport]\n\t\t\t.concat(named)\n\t\t\t.concat(hasDefaultExport ? defaultExportPropertyAssignments : [])\n\t\t\t.join('\\n');\n\n\tmagicString\n\t\t.trim()\n\t\t.prepend(importBlock + wrapperStart)\n\t\t.trim()\n\t\t.append(wrapperEnd);\n\n\tif (hasDefaultExport || named.length > 0 || shouldWrap || !isEntry) {\n\t\tmagicString.append(exportBlock);\n\t}\n\n\tcode = magicString.toString();\n\tconst map = sourceMap ? magicString.generateMap() : null;\n\n\treturn { code, map };\n}\n"
  },
  {
    "path": "src/utils.js",
    "content": "import { basename, dirname, extname, sep } from 'path';\nimport { makeLegalIdentifier } from 'rollup-pluginutils';\n\nexport function getName(id) {\n\tconst name = makeLegalIdentifier(basename(id, extname(id)));\n\tif (name !== 'index') {\n\t\treturn name;\n\t} else {\n\t\tconst segments = dirname(id).split(sep);\n\t\treturn makeLegalIdentifier(segments[segments.length - 1]);\n\t}\n}\n\n// Return the first non-falsy result from an array of\n// maybe-sync, maybe-promise-returning functions\nexport function first(candidates) {\n\treturn function(...args) {\n\t\treturn candidates.reduce((promise, candidate) => {\n\t\t\treturn promise.then(result =>\n\t\t\t\tresult != null ? result : Promise.resolve(candidate.call(this, ...args))\n\t\t\t);\n\t\t}, Promise.resolve());\n\t};\n}\n"
  },
  {
    "path": "test/form/async-function/input.js",
    "content": "module.exports = async function () {\n\t// TODO\n};\n"
  },
  {
    "path": "test/form/async-function/output.js",
    "content": "var input = async function () {\n\t// TODO\n};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/constant-template-literal/input.js",
    "content": "var foo = require(`tape`);\nconsole.log(foo);\n"
  },
  {
    "path": "test/form/constant-template-literal/output.js",
    "content": "import 'tape';\nimport foo from '_tape?commonjs-proxy';\n\nconsole.log(foo);\n\nvar input = {\n\n};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/dynamic-template-literal/input.js",
    "content": "var pe = 'pe';\nvar foo = require(`ta${pe}`);\nconsole.log(foo);\n"
  },
  {
    "path": "test/form/dynamic-template-literal/output.js",
    "content": "import * as commonjsHelpers from '_commonjsHelpers.js';\n\nvar pe = 'pe';\nvar foo = commonjsHelpers.commonjsRequire(`ta${pe}`);\nconsole.log(foo);\n\nvar input = {\n\n};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/ignore-ids/_config.js",
    "content": "module.exports = {\n\toptions: {\n\t\tignore: ['foo']\n\t}\n};\n"
  },
  {
    "path": "test/form/ignore-ids/input.js",
    "content": "var foo = require( 'foo' );\nvar bar = require( 'bar' );"
  },
  {
    "path": "test/form/ignore-ids/output.js",
    "content": "import 'bar';\nimport bar from '_bar?commonjs-proxy';\n\nvar foo = require( 'foo' );\n\nvar input = {\n\n};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/ignore-ids-function/_config.js",
    "content": "module.exports = {\n\toptions: {\n\t\tignore: id => id === 'foo'\n\t}\n};\n"
  },
  {
    "path": "test/form/ignore-ids-function/input.js",
    "content": "var foo = require( 'foo' );\nvar bar = require( 'bar' );"
  },
  {
    "path": "test/form/ignore-ids-function/output.js",
    "content": "import 'bar';\nimport bar from '_bar?commonjs-proxy';\n\nvar foo = require( 'foo' );\n\nvar input = {\n\n};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/multiple-var-declarations/input.js",
    "content": "var a = require('./a')()\n  , b = require('./b');\n\nconsole.log( a, b );"
  },
  {
    "path": "test/form/multiple-var-declarations/output.js",
    "content": "import './a';\nimport './b';\nimport require$$0 from '_./a?commonjs-proxy';\nimport b from '_./b?commonjs-proxy';\n\nvar a = require$$0();\n\nconsole.log( a, b );\n\nvar input = {\n\n};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/multiple-var-declarations-b/input.js",
    "content": "var a = require('./a')\n  , b = 42;\n\nconsole.log( a, b );"
  },
  {
    "path": "test/form/multiple-var-declarations-b/output.js",
    "content": "import './a';\nimport a from '_./a?commonjs-proxy';\n\nvar b = 42;\n\nconsole.log( a, b );\n\nvar input = {\n\n};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/multiple-var-declarations-c/input.js",
    "content": "var a = 'a'\n  , b = require( './b' )\n  , c = 'c';\n\nconsole.log( a, b, c );"
  },
  {
    "path": "test/form/multiple-var-declarations-c/output.js",
    "content": "import './b';\nimport b from '_./b?commonjs-proxy';\n\nvar a = 'a'\n  , c = 'c';\n\nconsole.log( a, b, c );\n\nvar input = {\n\n};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/no-exports-entry/_config.js",
    "content": "module.exports = {\n\toptions: {\n\t\tignore: [ 'foo' ]\n\t},\n\tentry: './input.js'\n};\n"
  },
  {
    "path": "test/form/no-exports-entry/input.js",
    "content": "var dummy = require('./dummy');\n\nvar foo = function () {\n\treturn;\n};\n\nvar input = 42;\n"
  },
  {
    "path": "test/form/no-exports-entry/output.js",
    "content": "import './dummy';\nimport dummy from '_./dummy?commonjs-proxy';\n\nvar foo = function () {\n\treturn;\n};\n\nvar input = 42;\n"
  },
  {
    "path": "test/form/no-toplevel-return/input.js",
    "content": "var foo = function () {\n\treturn;\n};\n\nvar bar = () => {\n\treturn;\n};\n\nfunction baz () {\n\treturn;\n}\n\nmodule.exports = 42;\n"
  },
  {
    "path": "test/form/no-toplevel-return/output.js",
    "content": "var foo = function () {\n\treturn;\n};\n\nvar bar = () => {\n\treturn;\n};\n\nfunction baz () {\n\treturn;\n}\n\nvar input = 42;\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/optimised-default-export/input.js",
    "content": "module.exports = 42;\n"
  },
  {
    "path": "test/form/optimised-default-export/output.js",
    "content": "var input = 42;\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/optimised-default-export-function/input.js",
    "content": "module.exports = function foo () {};\n"
  },
  {
    "path": "test/form/optimised-default-export-function/output.js",
    "content": "var input = function foo () {};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/optimised-default-export-function-double-assign/input.js",
    "content": "var bar;\nmodule.exports = bar = function foo () {};\n"
  },
  {
    "path": "test/form/optimised-default-export-function-double-assign/output.js",
    "content": "var bar;\nvar input = bar = function foo () {};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/optimised-default-export-iife/input.js",
    "content": "module.exports = (function foo () {\n  return function fooChild() {};\n}());\n"
  },
  {
    "path": "test/form/optimised-default-export-iife/output.js",
    "content": "var input = (function foo () {\n  return function fooChild() {};\n}());\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/optimised-named-export/input.js",
    "content": "exports.foo = 'a';\nmodule.exports.bar = 'b';\n"
  },
  {
    "path": "test/form/optimised-named-export/output.js",
    "content": "var foo = 'a';\nvar bar = 'b';\n\nvar input = {\n\tfoo: foo,\n\tbar: bar\n};\n\nexport default input;\nexport { input as __moduleExports };\nexport { foo };\nexport { bar };\n"
  },
  {
    "path": "test/form/optimised-named-export-conflicts/input.js",
    "content": "var foo = 1;\nvar bar = 2;\n\nexports.foo = 'a';\nmodule.exports.bar = 'b';\n"
  },
  {
    "path": "test/form/optimised-named-export-conflicts/output.js",
    "content": "var foo = 1;\nvar bar = 2;\n\nvar foo_1 = 'a';\nvar bar_1 = 'b';\n\nvar input = {\n\tfoo: foo_1,\n\tbar: bar_1\n};\n\nexport default input;\nexport { input as __moduleExports };\nexport { foo_1 as foo };\nexport { bar_1 as bar };\n"
  },
  {
    "path": "test/form/require-collision/input.js",
    "content": "(function() {\n  var foo = require(\"foo\");\n  var require$$0 = \"FAIL\";\n  console.log(foo);\n})();\n"
  },
  {
    "path": "test/form/require-collision/output.js",
    "content": "import 'foo';\nimport require$$1 from '_foo?commonjs-proxy';\n\n(function() {\n  var foo = require$$1;\n  var require$$0 = \"FAIL\";\n  console.log(foo);\n})();\n\nvar input = {\n\n};\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/typeof-module-exports/input.js",
    "content": "var foo = 42;\n\nif ( typeof exports === 'object' && typeof module === 'object' ) {\n\tmodule.exports = foo;\n} else if ( typeof define === 'function' && define.amd ) {\n\tdefine([], function () { return foo; });\n} else {\n\twindow.foo = foo;\n}\n"
  },
  {
    "path": "test/form/typeof-module-exports/output.js",
    "content": "import * as commonjsHelpers from '_commonjsHelpers.js';\n\nvar input = commonjsHelpers.createCommonjsModule(function (module, exports) {\nvar foo = 42;\n\nif ( 'object' === 'object' && 'object' === 'object' ) {\n\tmodule.exports = foo;\n} else if ( typeof undefined === 'function' && undefined.amd ) {\n\tundefined([], function () { return foo; });\n} else {\n\twindow.foo = foo;\n}\n});\n\nexport default input;\nexport { input as __moduleExports };\n"
  },
  {
    "path": "test/form/unambiguous-with-default-export/input.js",
    "content": "require( './foo.js' );\n\nexport default {};\n"
  },
  {
    "path": "test/form/unambiguous-with-default-export/output.js",
    "content": "require( './foo.js' );\n\nexport default {};\n"
  },
  {
    "path": "test/form/unambiguous-with-import/input.js",
    "content": "require( './foo.js' );\n\nimport './bar.js';\n"
  },
  {
    "path": "test/form/unambiguous-with-import/output.js",
    "content": "require( './foo.js' );\n\nimport './bar.js';\n"
  },
  {
    "path": "test/form/unambiguous-with-named-export/input.js",
    "content": "require( './foo.js' );\n\nexport {};\n"
  },
  {
    "path": "test/form/unambiguous-with-named-export/output.js",
    "content": "require( './foo.js' );\n\nexport {};\n"
  },
  {
    "path": "test/function/__esModule/answer.js",
    "content": "exports.__esModule = true;\nexports.answer = 42;\n"
  },
  {
    "path": "test/function/__esModule/main.js",
    "content": "import * as x from './answer';\n\nassert.ok( 'answer' in x );\nassert.ok( 'default' in x );\nassert.ok( !( '__esModule' in x ) );\n"
  },
  {
    "path": "test/function/assign-properties-to-default-export/foo.js",
    "content": "var foo = {};\n\nmodule.exports = foo;\nmodule.exports.bar = 1;\nexports.baz = 2;\n"
  },
  {
    "path": "test/function/assign-properties-to-default-export/main.js",
    "content": "import foo from './foo.js';\n\nassert.equal( foo.bar, 1 );\nassert.equal( foo.baz, 2 );\n"
  },
  {
    "path": "test/function/assumed-globals/_config.js",
    "content": "module.exports = {\n\tcontext: {\n\t\tdocument: { real: true }\n\t}\n};\n"
  },
  {
    "path": "test/function/assumed-globals/document.js",
    "content": "if ( typeof document !== 'undefined' ) {\n\tmodule.exports = document;\n} else {\n\tmodule.exports = { fake: true };\n}\n"
  },
  {
    "path": "test/function/assumed-globals/main.js",
    "content": "import document from './document.js';\n\nassert.deepEqual( document, { real: true });\n"
  },
  {
    "path": "test/function/bare-import/_config.js",
    "content": "module.exports = {};\n"
  },
  {
    "path": "test/function/bare-import/bar.js",
    "content": "Math.bar = 42;\n"
  },
  {
    "path": "test/function/bare-import/foo.js",
    "content": "require( './bar.js' );\n"
  },
  {
    "path": "test/function/bare-import/main.js",
    "content": "import './foo.js';\n\nassert.equal( Math.bar, 42 );\n"
  },
  {
    "path": "test/function/bare-import-comment/bar.js",
    "content": "// Great module\nMath.bar = 42;\n"
  },
  {
    "path": "test/function/bare-import-comment/foo.js",
    "content": "require( './bar.js' );\n"
  },
  {
    "path": "test/function/bare-import-comment/main.js",
    "content": "import './foo.js';\n\nassert.equal( Math.bar, 42 );\n"
  },
  {
    "path": "test/function/basic/_config.js",
    "content": "const assert = require('assert');\n\nmodule.exports = {\n\texports: exports => {\n\t\tassert.equal(exports, 42);\n\t}\n};\n"
  },
  {
    "path": "test/function/basic/foo.js",
    "content": "module.exports = 21;\n"
  },
  {
    "path": "test/function/basic/main.js",
    "content": "var foo = require( './foo' );\nmodule.exports = foo * 2;\n"
  },
  {
    "path": "test/function/deconflict-export-and-local/index.js",
    "content": "var someValueModule = require('./someValue');\n\nexports.someValue = someValueModule.someValue;\n"
  },
  {
    "path": "test/function/deconflict-export-and-local/main.js",
    "content": "import { someValue } from './index.js';\n\nassert.equal( someValue, 10 );\n"
  },
  {
    "path": "test/function/deconflict-export-and-local/someValue.js",
    "content": "exports.someValue = 10;\n"
  },
  {
    "path": "test/function/dot/foo.bar.js",
    "content": "module.exports = 'fubar';\n"
  },
  {
    "path": "test/function/dot/main.js",
    "content": "var status = require( './foo.bar' );\n\nassert.equal( status, 'fubar' );\n"
  },
  {
    "path": "test/function/duplicate-default-exports/main.js",
    "content": "import x from './x';\n\nassert.strictEqual( x.default, x );"
  },
  {
    "path": "test/function/duplicate-default-exports/x.js",
    "content": "var x = {};\n\nmodule.exports = x;\nmodule.exports.default = x;"
  },
  {
    "path": "test/function/duplicate-default-exports-b/main.js",
    "content": "import x from './x';\n\nassert.deepEqual( x, { default: 42 });"
  },
  {
    "path": "test/function/duplicate-default-exports-b/x.js",
    "content": "var x = {};\n\nmodule.exports = x;\nmodule.exports.default = 42;"
  },
  {
    "path": "test/function/duplicate-default-exports-c/exports.js",
    "content": "exports.Foo = 1;\nexports.var = 'VAR';\nexports.default = {\n\tFoo: 2,\n\tdefault: 3\n};\n"
  },
  {
    "path": "test/function/duplicate-default-exports-c/main.js",
    "content": "import E from './exports.js';\nimport { Foo } from './exports.js';\nimport { var as Var } from './exports.js';\n\nassert.strictEqual( E.Foo, 1 );\nassert.strictEqual( E.var, 'VAR' );\nassert.deepEqual( E.default, { Foo: 2, default:  3 });\nassert.strictEqual( E.default.Foo, 2 );\nassert.strictEqual( E.default.default, 3 );\nassert.strictEqual( Foo, 1 );\nassert.strictEqual( Var, 'VAR' );\n"
  },
  {
    "path": "test/function/export-default-from/_config.js",
    "content": "module.exports = {};\n"
  },
  {
    "path": "test/function/export-default-from/imported.js",
    "content": "export default 'default export';\n"
  },
  {
    "path": "test/function/export-default-from/main.js",
    "content": "assert.equal(require('./reexporter'), 'default export');\n"
  },
  {
    "path": "test/function/export-default-from/reexporter.js",
    "content": "export {default} from './imported';\n"
  },
  {
    "path": "test/function/exports/_config.js",
    "content": "const assert = require('assert');\n\nmodule.exports = {\n\texports: exports => {\n\t\tassert.equal(exports, 'BARBAZ');\n\t}\n};\n"
  },
  {
    "path": "test/function/exports/foo.js",
    "content": "exports.bar = 'BAR';\nexports.baz = 'BAZ';\n"
  },
  {
    "path": "test/function/exports/main.js",
    "content": "var bar = require( './foo' ).bar;\nvar baz = require( './foo' ).baz;\n\nmodule.exports = bar + baz;\n"
  },
  {
    "path": "test/function/external-imports/_config.js",
    "content": "const assert = require('assert');\n\nmodule.exports = {\n\toptions: {\n\t\texternal: ['foo']\n\t},\n\texports: exports => {\n\t\tassert.equal(exports, 'foo');\n\t}\n};\n"
  },
  {
    "path": "test/function/external-imports/main.js",
    "content": "var foo = require( 'foo' );\n\nmodule.exports = foo;\n"
  },
  {
    "path": "test/function/fallback-no-default/foo.js",
    "content": "export var one = 1;\n\nexport var two = 2;\n"
  },
  {
    "path": "test/function/fallback-no-default/main.js",
    "content": "var foo = require('./foo.js');\n\nassert.equal( foo.one, 1 );\nassert.equal( foo.two, 2 );\n"
  },
  {
    "path": "test/function/global-not-overwritten/_config.js",
    "content": "const assert = require('assert');\n\nmodule.exports = {\n\texports(exports) {\n\t\tassert.equal(exports.encoded, encodeURIComponent('test string'));\n\t}\n};\n"
  },
  {
    "path": "test/function/global-not-overwritten/encode.js",
    "content": "exports.encodeURIComponent = function () {\n\treturn encodeURIComponent( this.str );\n};\n\nglobal.foo = exports; // to ensure module is wrapped\n"
  },
  {
    "path": "test/function/global-not-overwritten/main.js",
    "content": "import { encodeURIComponent } from './encode.js';\n\nvar foo = {\n\tstr: 'test string',\n\tencodeURIComponent\n};\n\nexport var encoded = foo.encodeURIComponent();\n"
  },
  {
    "path": "test/function/global-var/main.js",
    "content": "function foo () {\n\tvar a = 1, global = {};\n\tglobal.modified = true;\n\treturn global;\n}\n\nvar notGlobal = foo();\nassert.ok( notGlobal.modified );\nassert.ok( !global.modified );\n\nmodule.exports = {};\n"
  },
  {
    "path": "test/function/index/foo/index.js",
    "content": "module.exports = 42;\n"
  },
  {
    "path": "test/function/index/main.js",
    "content": "var foo = require( './foo' );\n\nassert.equal( foo, 42 );\n"
  },
  {
    "path": "test/function/inline/_config.js",
    "content": "const assert = require('assert');\n\nmodule.exports = {\n\texports: exports => {\n\t\tassert.equal(exports(), 2);\n\t}\n};\n"
  },
  {
    "path": "test/function/inline/foo.js",
    "content": "module.exports = 1;\n"
  },
  {
    "path": "test/function/inline/main.js",
    "content": "module.exports = function () {\n\treturn require( './multiply' )( 2, require( './foo' ) );\n};\n"
  },
  {
    "path": "test/function/inline/multiply.js",
    "content": "module.exports = function ( a, b ) {\n\treturn a * b;\n};\n"
  },
  {
    "path": "test/function/named-exports/foo.js",
    "content": "exports.a = 1;\nmodule.exports.b = 2;\n"
  },
  {
    "path": "test/function/named-exports/main.js",
    "content": "import { a, b } from './foo.js';\n\nassert.equal( a, 1 );\nassert.equal( b, 2 );\n"
  },
  {
    "path": "test/function/ordering/bar.js",
    "content": "var shared = require('./shared');\n\nmodule.exports = shared.fooLoaded\n"
  },
  {
    "path": "test/function/ordering/foo.js",
    "content": "var shared = require('./shared');\n\n// Mutate the shared module\nshared.fooLoaded = true;\n"
  },
  {
    "path": "test/function/ordering/main.js",
    "content": "require('./foo');\n\nvar fooLoaded = require('./bar');\n\nassert.ok( fooLoaded );\n"
  },
  {
    "path": "test/function/ordering/shared.js",
    "content": "module.exports = {\n\tfooLoaded: false\n};\n"
  },
  {
    "path": "test/function/react-apollo/commonjs-bar.js",
    "content": "function Bar () {\n\tthis.x = 42;\n}\n\nexports.__esModule = true;\nexports.default = Bar;\n"
  },
  {
    "path": "test/function/react-apollo/commonjs-foo.js",
    "content": "var Bar = require( './commonjs-bar' );\n\nexports.__esModule = true;\nexports.Bar = Bar.default;\n"
  },
  {
    "path": "test/function/react-apollo/main.js",
    "content": "import { Bar } from './commonjs-foo.js';\n\nassert.equal( new Bar().x, 42 );\n"
  },
  {
    "path": "test/function/reassignment/foo.js",
    "content": "function foo () {}\nfoo.something = false;\n\nmodule.exports = foo;\n"
  },
  {
    "path": "test/function/reassignment/main.js",
    "content": "var foo = require( './foo.js' );\n\nif ( !foo.something ) {\n\tfoo = function somethingElse () {}\n\tfoo.something = true;\n}\n\nassert.ok( foo.something );\n"
  },
  {
    "path": "test/function/reexports/_config.js",
    "content": "const path = require('path');\n\nmodule.exports = {\n\tpluginOptions: {\n\t\tnamedExports: {\n\t\t\t[path.resolve(__dirname, 'foo.js')]: ['named']\n\t\t}\n\t}\n};\n"
  },
  {
    "path": "test/function/reexports/bar.js",
    "content": "exports.named = 42;\n"
  },
  {
    "path": "test/function/reexports/foo.js",
    "content": "module.exports = require( './bar.js' );\n"
  },
  {
    "path": "test/function/reexports/main.js",
    "content": "import { named } from './foo.js';\n\nassert.equal( named, 42 );\n"
  },
  {
    "path": "test/function/resolve-is-cjs-extension/_config.js",
    "content": "module.exports = {\n\tdescription: 'always resolve cjs detection even if an imported file has an unknown extension',\n\toptions: {\n\t\tplugins: [\n\t\t\t{\n\t\t\t\tresolveId(importee) {\n\t\t\t\t\tif (importee === 'second') {\n\t\t\t\t\t\treturn `${__dirname}/second.x`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t},\n\tpluginOptions: {}\n};\n"
  },
  {
    "path": "test/function/resolve-is-cjs-extension/main.js",
    "content": "assert.equal(require('second').result, 'second' );\n"
  },
  {
    "path": "test/function/resolve-is-cjs-extension/second.x",
    "content": "export const result = 'second';\n"
  },
  {
    "path": "test/function/resolve-is-cjs-filtered/_config.js",
    "content": "module.exports = {\n\tdescription: 'always resolve cjs detection even if an imported file is filtered',\n\toptions: {\n\t\tplugins: [\n\t\t\t{\n\t\t\t\tresolveId(importee) {\n\t\t\t\t\tif (importee === 'second') {\n\t\t\t\t\t\treturn `${__dirname}/second.js`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t},\n\tpluginOptions: {\n\t\tinclude: ['function/resolve-is-cjs-filtered/main.js']\n\t}\n};\n"
  },
  {
    "path": "test/function/resolve-is-cjs-filtered/main.js",
    "content": "assert.equal(require('second').result, 'second' );\n"
  },
  {
    "path": "test/function/resolve-is-cjs-filtered/second.js",
    "content": "export const result = 'second';\n"
  },
  {
    "path": "test/function/shadowing/main.js",
    "content": "function foo ( require ) {\n\trequire( 'not-an-actual-require-statement' );\n}\n\nvar result;\n\nfoo( function ( msg ) {\n\tresult = msg;\n});\n\nassert.equal( result, 'not-an-actual-require-statement' );\n"
  },
  {
    "path": "test/function/skips-dead-branches/_config.js",
    "content": "const assert = require('assert');\n\nmodule.exports = {\n\tglobal: global => {\n\t\tassert.equal(global.a, undefined);\n\t\tassert.equal(global.b, 2);\n\t\tassert.equal(global.c, undefined);\n\t}\n};\n"
  },
  {
    "path": "test/function/skips-dead-branches/a.js",
    "content": "global.a = 1;\n"
  },
  {
    "path": "test/function/skips-dead-branches/b.js",
    "content": "global.b = 2;\nmodule.exports = 'b';\n"
  },
  {
    "path": "test/function/skips-dead-branches/c.js",
    "content": "global.c = 3;\nmodule.exports = 'c';\n"
  },
  {
    "path": "test/function/skips-dead-branches/main.js",
    "content": "if ( 'development' === 'production' ) {\n\trequire( './a.js' );\n}\n\nmodule.exports = true ?\n\trequire( './b.js' ) :\n\trequire( './c.js' );\n"
  },
  {
    "path": "test/function/this/foo.js",
    "content": "module.exports = function augmentThis () {\n\tthis.x = 'x';\n};\n\nthis.y = 'y';\n"
  },
  {
    "path": "test/function/this/main.js",
    "content": "var foo = require( './foo' );\n\nvar obj = {};\nfoo.call( obj );\n\nassert.equal( obj.x, 'x' );\nassert.equal( this.y, 'y' );\n"
  },
  {
    "path": "test/function/toplevel-return/_config.js",
    "content": "const assert = require('assert');\n\nmodule.exports = {\n\texports: exports => {\n\t\tassert.equal(exports, 'foo');\n\t}\n};\n"
  },
  {
    "path": "test/function/toplevel-return/foo.js",
    "content": "module.exports = 'foo';\nreturn;\n"
  },
  {
    "path": "test/function/toplevel-return/main.js",
    "content": "var foo = require('./foo');\n\nmodule.exports = 'foo';\n"
  },
  {
    "path": "test/function/toplevel-return-complex/_config.js",
    "content": "const assert = require('assert');\n\nmodule.exports = {\n\texports: exports => {\n\t\tassert.equal(exports, 'bar');\n\t}\n};\n"
  },
  {
    "path": "test/function/toplevel-return-complex/bar.js",
    "content": "module.exports = function () {\n  return true;\n};\n"
  },
  {
    "path": "test/function/toplevel-return-complex/foo.js",
    "content": "var bar = require('./bar');\nmodule.exports = 'bar';\nif (bar()) {\n  return;\n}\nmodule.exports = 'foo';\n"
  },
  {
    "path": "test/function/toplevel-return-complex/main.js",
    "content": "var foo = require('./foo');\n\nmodule.exports = foo;\n"
  },
  {
    "path": "test/function/trailing-slash/foo/index.js",
    "content": "module.exports = 42;\n"
  },
  {
    "path": "test/function/trailing-slash/main.js",
    "content": "var foo = require( './foo/' );\n\nassert.equal( foo, 42 );\n"
  },
  {
    "path": "test/function/typeof-require/foo.js",
    "content": "if ( typeof require === 'function' && require ) {\n\tmodule.exports = 1;\n} else {\n\tmodule.exports = 2;\n}\n"
  },
  {
    "path": "test/function/typeof-require/main.js",
    "content": "import foo from './foo.js';\n\nassert.equal( foo, 1 );\n"
  },
  {
    "path": "test/mocha.opts",
    "content": "--require @babel/register\n"
  },
  {
    "path": "test/node_modules/.gitkeep",
    "content": ""
  },
  {
    "path": "test/node_modules/bar/index.js",
    "content": "const baz = require('baz');\nmodule.exports = function () {\n\treturn baz;\n};"
  },
  {
    "path": "test/node_modules/baz/index.js",
    "content": "module.exports = 'hello';"
  },
  {
    "path": "test/node_modules/events/index.js",
    "content": "exports.message = 'this is not builtin';\n\nconst myLib = exports;\nmyLib.foo = 'this is a hidden export';"
  },
  {
    "path": "test/node_modules/external/index.js",
    "content": "var externalLib = exports;\nexternalLib.message = 'it works';\n"
  },
  {
    "path": "test/node_modules/foo/index.js",
    "content": "module.exports = 'foo';"
  },
  {
    "path": "test/samples/array-destructuring-assignment/main.js",
    "content": "\nfunction shuffleArray(array) {\n  for (let i = array.length - 1; i > 0; i--) {\n    const j = Math.floor(Math.random() * (i + 1));\n    [array[i], array[j]] = [array[j], array[i]];\n  }\n}\n\nexports.shuffleArray = shuffleArray;\n"
  },
  {
    "path": "test/samples/corejs/literal-with-default.js",
    "content": "module.exports = { default: 'foobar', __esModule: true };\n"
  },
  {
    "path": "test/samples/custom-named-exports/main.js",
    "content": "import { named } from './secret-named-exporter.js';\nimport { message } from 'external';\n\nassert.equal( named, 42 );\nassert.equal( message, 'it works' );\n"
  },
  {
    "path": "test/samples/custom-named-exports/secret-named-exporter.js",
    "content": "var myLib = exports;\nmyLib.named = 42;\n"
  },
  {
    "path": "test/samples/custom-named-exports-browser-shims/main.js",
    "content": "import { message, foo } from 'events';\n\nassert.equal( message, 'this is not builtin' );\nassert.equal( foo, 'this is a hidden export' );\n"
  },
  {
    "path": "test/samples/custom-named-exports-false-positive/main.js",
    "content": "import { thing } from './other.js';\nassert.equal( thing, 'yes' );\n"
  },
  {
    "path": "test/samples/custom-named-exports-false-positive/other.js",
    "content": "/* require (https://github.com/rollup/rollup-plugin-commonjs/issues/36) */\nexport var thing = 'yes';\n"
  },
  {
    "path": "test/samples/custom-named-exports-warn-builtins/main.js",
    "content": "import { message } from 'events';\n\nassert.equal( message, 'this is not builtin' );\n"
  },
  {
    "path": "test/samples/deconflict-helpers/main.js",
    "content": "var commonjsHelpers = { commonjsGlobal: 'nope' };\nmodule.exports = global;\n"
  },
  {
    "path": "test/samples/define-is-undefined/foo.js",
    "content": "(function (global, factory) {\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\t(global.foo = factory());\n}(this, (function () { 'use strict';\n\n\treturn 42;\n\n})));\n"
  },
  {
    "path": "test/samples/define-is-undefined/main.js",
    "content": "import foo from './foo.js';\n\nexport default 42;\n"
  },
  {
    "path": "test/samples/es-modules-without-default-export/main.js",
    "content": "const { a } = require('./other.js');\n\nassert.equal( a, 1 );\n"
  },
  {
    "path": "test/samples/es-modules-without-default-export/other.js",
    "content": "export const a = 1;\n"
  },
  {
    "path": "test/samples/extension/foo.coffee",
    "content": "module.exports = 21;\n"
  },
  {
    "path": "test/samples/extension/main.coffee",
    "content": "var foo = require( './foo' );\nmodule.exports = foo * 2;\n"
  },
  {
    "path": "test/samples/external/main.js",
    "content": "import bar from 'bar';\n\nexport default bar().toUpperCase();"
  },
  {
    "path": "test/samples/global/main.js",
    "content": "global.foo = 'bar';\n"
  },
  {
    "path": "test/samples/global-in-if-block/main.js",
    "content": "if (!global.count) {\n\tglobal.count = 0;\n}\n\nglobal.count += 1;\n"
  },
  {
    "path": "test/samples/ignore-global/firstpass.js",
    "content": "export var immediate = typeof global.setImmediate === 'function' ?\n   global.setImmediate : global.setTimeout;\n"
  },
  {
    "path": "test/samples/ignore-global/identifier.js",
    "content": "// require (firstpass)\n\nexport var immediate = typeof global.setImmediate === 'function' ?\n   global.setImmediate : global.setTimeout;\n"
  },
  {
    "path": "test/samples/ignore-global/main.js",
    "content": "export { immediate as immediate1 } from './firstpass';\nexport { immediate as immediate2 } from './identifier';\nexport { immediate as immediate3 } from './this';\n"
  },
  {
    "path": "test/samples/ignore-global/this.js",
    "content": "// require (firstpass)\n\n// \"this\" will be rewritten with \"undefined\" by rollup\nexport var immediate = typeof this === 'undefined' ? \n   null : typeof this.setImmediate === 'function' ?\n   this.setImmediate : this.setTimeout;\n"
  },
  {
    "path": "test/samples/ignore-virtual-modules/main.js",
    "content": "module.exports = require('\\0virtual');\n"
  },
  {
    "path": "test/samples/invalid-syntax/main.js",
    "content": "export const foo = 2,"
  },
  {
    "path": "test/samples/multiple-entry-points/2.js",
    "content": "function second () {\n\tconsole.log('second');\n}\nexports.second = second;"
  },
  {
    "path": "test/samples/multiple-entry-points/3.js",
    "content": "function third () {\n\tconsole.log('third');\n}\n\nexports.third = third;\n"
  },
  {
    "path": "test/samples/multiple-entry-points/4.js",
    "content": "export function fourth () {\n\tconsole.log('fourth');\n}\n"
  },
  {
    "path": "test/samples/multiple-entry-points/b.js",
    "content": "import { second } from './2';\nimport { third } from './3';\n\nsecond();\nthird();\n"
  },
  {
    "path": "test/samples/multiple-entry-points/c.js",
    "content": "import { second } from './2';\nimport { third } from './3';\nimport { fourth } from './4';\n\nsecond();\nthird();\nfourth();\n"
  },
  {
    "path": "test/samples/named-exports-from-object-literal/a.js",
    "content": "module.exports = 1;\n"
  },
  {
    "path": "test/samples/named-exports-from-object-literal/main.js",
    "content": "import { a, b, c } from './other.js';\n\nassert.equal( a, 1 );\nassert.equal( b, 2 );\nassert.equal( c, 3 );\n"
  },
  {
    "path": "test/samples/named-exports-from-object-literal/other.js",
    "content": "var a = require( './a.js' );\nvar b = 2;\n\nmodule.exports = {\n  a: a,\n  b: b,\n  c: a + b,\n  2: 1 + 1\n};\n"
  },
  {
    "path": "test/samples/other-transforms/bar.js",
    "content": "module.exports = 40;\n"
  },
  {
    "path": "test/samples/other-transforms/foo.js",
    "content": "var bar = require( './bar.js' );\n\nmodule.exports = bar + 1;\n"
  },
  {
    "path": "test/samples/other-transforms/main.js",
    "content": "import foo from './foo.js';\n\nassert.equal( foo, 42 );\n"
  },
  {
    "path": "test/samples/paren-expression/index.js",
    "content": "module.exports = (42);\n"
  },
  {
    "path": "test/samples/reexport/export.js",
    "content": "exports.named = 2;\n"
  },
  {
    "path": "test/samples/reexport/main.js",
    "content": "import { named } from './reexport.js';\n\nassert.equal(named, 2);\n"
  },
  {
    "path": "test/samples/reexport/reexport.js",
    "content": "module.exports = require('./export.js');\n"
  },
  {
    "path": "test/samples/rename-index/invalid-var/index.js",
    "content": "module.exports = 'invalid';\n"
  },
  {
    "path": "test/samples/rename-index/main.js",
    "content": "import invalid from './invalid-var';\nimport valid from './validVar';\nimport other from './other/nonIndex';\n\nconsole.log(invalid, valid, other);\n"
  },
  {
    "path": "test/samples/rename-index/other/nonIndex.js",
    "content": "module.exports = 'not an index file';\n"
  },
  {
    "path": "test/samples/rename-index/validVar/index.js",
    "content": "module.exports = 'valid';\n"
  },
  {
    "path": "test/samples/reserved-as-property/main.js",
    "content": "module.exports.delete = 'foo';\n"
  },
  {
    "path": "test/samples/sourcemap/foo.js",
    "content": "export default 42;\n"
  },
  {
    "path": "test/samples/sourcemap/main.js",
    "content": "var foo = require( './foo' );\nconsole.log( foo );\n"
  },
  {
    "path": "test/samples/symlinked-node-modules/index.js",
    "content": "import { foo } from 'events';"
  },
  {
    "path": "test/samples/umd/correct-scoping.js",
    "content": "if ( typeof require === 'function' ) {\n\tmodule.exports = function ( require ) {\n\t\treturn typeof require;\n\t}( {} );\n}\n"
  },
  {
    "path": "test/samples/umd/protobuf.js",
    "content": "// From https://github.com/rollup/rollup-plugin-commonjs/issues/38\n(function(global, factory) {\n    /* AMD */ if (typeof define === 'function' && define[\"amd\"])\n        define([\"foo\"], factory);\n    /* CommonJS */ else if (typeof require === \"function\" && typeof module === \"object\" && module && module[\"exports\"])\n        module[\"exports\"] = factory(require(\"foo\"), true);\n    /* Global */ else\n        (global[\"dcodeIO\"] = global[\"dcodeIO\"] || {})[\"ProtoBuf\"] = factory(global[\"dcodeIO\"][\"ByteBuffer\"]);\n})(this, function(ByteBuffer, isCommonJS) {\n  return isCommonJS;\n})\n"
  },
  {
    "path": "test/samples/umd/sinon.js",
    "content": "// From https://github.com/rollup/rollup-plugin-commonjs/issues/38\nvar sinon = (function () { // eslint-disable-line no-unused-vars\n    \"use strict\";\n\n    var sinonModule;\n    var isNode = typeof module !== \"undefined\" && module.exports && typeof require === \"function\";\n    var isAMD = typeof define === \"function\" && typeof define.amd === \"object\" && define.amd;\n\n    function loadDependencies(require, exports, module) {\n        sinonModule = module.exports = require(\"./sinon/util/core\");\n        require(\"./sinon/extend\");\n        require(\"./sinon/walk\");\n        require(\"./sinon/typeOf\");\n        require(\"./sinon/times_in_words\");\n        require(\"./sinon/spy\");\n        require(\"./sinon/call\");\n        require(\"./sinon/behavior\");\n        require(\"./sinon/stub\");\n        require(\"./sinon/mock\");\n        require(\"./sinon/collection\");\n        require(\"./sinon/assert\");\n        require(\"./sinon/sandbox\");\n        require(\"./sinon/test\");\n        require(\"./sinon/test_case\");\n        require(\"./sinon/match\");\n        require(\"./sinon/format\");\n        require(\"./sinon/log_error\");\n    }\n\n    if (isAMD) {\n        define(loadDependencies);\n    } else if (isNode) {\n        loadDependencies(require, module.exports, module);\n        sinonModule = module.exports;\n    } else {\n        sinonModule = {};\n    }\n\n    return sinonModule;\n}());\n"
  },
  {
    "path": "test/samples/use-own-output/from-rollup.js",
    "content": "Object.defineProperty(exports, '__esModule', { value: true });\nexports.x = 10\n"
  },
  {
    "path": "test/samples/use-own-output/main.js",
    "content": "import * as b from \"./from-rollup\";\nwindow.b = b;\n"
  },
  {
    "path": "test/test.js",
    "content": "/* eslint-env mocha */\n/* eslint-disable no-console */\n\nconst acorn = require('acorn');\nconst path = require('path');\nconst fs = require('fs');\nconst assert = require('assert');\nconst relative = require('require-relative');\nconst { SourceMapConsumer } = require('source-map');\nconst { getLocator } = require('locate-character');\nconst { rollup } = require('rollup');\nconst resolve = require('rollup-plugin-node-resolve');\n\nfunction commonjs(options) {\n\tdelete require.cache[require.resolve('..')];\n\treturn require('..')(options);\n}\n\nrequire('source-map-support').install();\n\nprocess.chdir(__dirname);\n\nfunction execute(code, context = {}) {\n\tlet fn;\n\tconst contextKeys = Object.keys(context);\n\tconst argNames = contextKeys.concat(\n\t\t'module',\n\t\t'exports',\n\t\t'require',\n\t\t'global',\n\t\t'assert',\n\t\t'globalThis',\n\t\tcode\n\t);\n\n\ttry {\n\t\tfn = new Function(...argNames);\n\t} catch (err) {\n\t\t// syntax error\n\t\tconsole.log(code);\n\t\tthrow err;\n\t}\n\n\tconst module = { exports: {} };\n\tconst global = {};\n\n\tconst argValues = contextKeys\n\t\t.map(key => context[key])\n\t\t.concat(module, module.exports, name => relative(name, 'test/x.js'), global, assert, global);\n\n\tfn(...argValues);\n\n\treturn {\n\t\tcode,\n\t\texports: module.exports,\n\t\tglobal\n\t};\n}\n\nconst getOutputFromGenerated = generated => (generated.output ? generated.output[0] : generated);\n\nasync function getCodeFromBundle(bundle, customOptions = {}) {\n\tconst options = Object.assign({ format: 'cjs' }, customOptions);\n\treturn getOutputFromGenerated(await bundle.generate(options)).code;\n}\n\nasync function executeBundle(bundle, { context, exports } = {}) {\n\tconst code = await getCodeFromBundle(bundle, exports ? { exports } : {});\n\treturn execute(code, context);\n}\n\ndescribe('rollup-plugin-commonjs', () => {\n\tdescribe('form', () => {\n\t\tconst transformContext = {\n\t\t\tparse: (input, options) =>\n\t\t\t\tacorn.parse(\n\t\t\t\t\tinput,\n\t\t\t\t\tObject.assign(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tecmaVersion: 9,\n\t\t\t\t\t\t\tsourceType: 'module'\n\t\t\t\t\t\t},\n\t\t\t\t\t\toptions\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t};\n\n\t\tfs.readdirSync('form').forEach(dir => {\n\t\t\tlet config;\n\n\t\t\ttry {\n\t\t\t\tconfig = require(`./form/${dir}/_config.js`);\n\t\t\t} catch (err) {\n\t\t\t\tconfig = {};\n\t\t\t}\n\n\t\t\t(config.solo ? it.only : it)(dir, () => {\n\t\t\t\tconst { transform } = commonjs(config.options);\n\t\t\t\tconst id = `./form/${dir}/input.js`;\n\n\t\t\t\ttransformContext.getModuleInfo = moduleId => ({\n\t\t\t\t\tisEntry: config.entry && moduleId === id\n\t\t\t\t});\n\n\t\t\t\tconst input = fs.readFileSync(id, 'utf-8');\n\n\t\t\t\tlet outputFile = `form/${dir}/output`;\n\t\t\t\tif (fs.existsSync(`${outputFile}.${process.platform}.js`)) {\n\t\t\t\t\toutputFile += `.${process.platform}.js`;\n\t\t\t\t} else {\n\t\t\t\t\toutputFile += '.js';\n\t\t\t\t}\n\n\t\t\t\tconst expected = fs.readFileSync(outputFile, 'utf-8').trim();\n\n\t\t\t\tconst transformed = transform.call(transformContext, input, id);\n\t\t\t\tconst actual = (transformed ? transformed.code : input).trim().replace(/\\0/g, '_');\n\t\t\t\tassert.equal(actual, expected);\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe('function', () => {\n\t\tfs.readdirSync('function').forEach(dir => {\n\t\t\tlet config;\n\n\t\t\ttry {\n\t\t\t\tconfig = require(`./function/${dir}/_config.js`);\n\t\t\t} catch (err) {\n\t\t\t\tconfig = {};\n\t\t\t}\n\n\t\t\t(config.solo ? it.only : it)(dir, async () => {\n\t\t\t\tconst options = Object.assign(\n\t\t\t\t\t{\n\t\t\t\t\t\tinput: `function/${dir}/main.js`\n\t\t\t\t\t},\n\t\t\t\t\tconfig.options || {},\n\t\t\t\t\t{\n\t\t\t\t\t\tplugins: [\n\t\t\t\t\t\t\t...((config.options && config.options.plugins) || []),\n\t\t\t\t\t\t\tcommonjs(config.pluginOptions)\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst bundle = await rollup(options);\n\t\t\t\tconst code = await getCodeFromBundle(bundle);\n\t\t\t\tif (config.show || config.solo) {\n\t\t\t\t\tconsole.error(code);\n\t\t\t\t}\n\n\t\t\t\tconst { exports, global } = execute(code, config.context);\n\n\t\t\t\tif (config.exports) config.exports(exports);\n\t\t\t\tif (config.global) config.global(global);\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe('misc tests', () => {\n\t\t// most of these should be moved over to function...\n\t\tit('generates a sourcemap', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/sourcemap/main.js',\n\t\t\t\tplugins: [commonjs({ sourceMap: true })]\n\t\t\t});\n\n\t\t\tconst { code, map } = getOutputFromGenerated(\n\t\t\t\tawait bundle.generate({\n\t\t\t\t\tformat: 'cjs',\n\t\t\t\t\tsourcemap: true,\n\t\t\t\t\tsourcemapFile: path.resolve('bundle.js')\n\t\t\t\t})\n\t\t\t);\n\n\t\t\tconst smc = new SourceMapConsumer(map);\n\t\t\tconst locator = getLocator(code, { offsetLine: 1 });\n\n\t\t\tlet generatedLoc = locator('42');\n\t\t\tlet loc = smc.originalPositionFor(generatedLoc); // 42\n\t\t\tassert.equal(loc.source, 'samples/sourcemap/foo.js');\n\t\t\tassert.equal(loc.line, 1);\n\t\t\tassert.equal(loc.column, 15);\n\n\t\t\tgeneratedLoc = locator('log');\n\t\t\tloc = smc.originalPositionFor(generatedLoc); // log\n\t\t\tassert.equal(loc.source, 'samples/sourcemap/main.js');\n\t\t\tassert.equal(loc.line, 2);\n\t\t\tassert.equal(loc.column, 8);\n\t\t});\n\n\t\tit('supports an array of multiple entry points', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: ['samples/multiple-entry-points/b.js', 'samples/multiple-entry-points/c.js'],\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tconst { output } = await bundle.generate({\n\t\t\t\tformat: 'cjs',\n\t\t\t\tchunkFileNames: '[name].js'\n\t\t\t});\n\t\t\tif (Array.isArray(output)) {\n\t\t\t\tassert.equal(output.length, 3);\n\t\t\t\tassert.ok(output.find(({ fileName }) => fileName === 'b.js'));\n\t\t\t\tassert.ok(output.find(({ fileName }) => fileName === 'c.js'));\n\t\t\t} else {\n\t\t\t\tassert.equal(Object.keys(output).length, 3);\n\t\t\t\tassert.equal('b.js' in output, true);\n\t\t\t\tassert.equal('c.js' in output, true);\n\t\t\t}\n\t\t});\n\n\t\tit('supports an object of multiple entry points', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: {\n\t\t\t\t\tb: require.resolve('./samples/multiple-entry-points/b.js'),\n\t\t\t\t\tc: require.resolve('./samples/multiple-entry-points/c.js')\n\t\t\t\t},\n\t\t\t\tplugins: [resolve(), commonjs()]\n\t\t\t});\n\n\t\t\tconst { output } = await bundle.generate({\n\t\t\t\tformat: 'cjs',\n\t\t\t\tchunkFileNames: '[name].js'\n\t\t\t});\n\n\t\t\tif (Array.isArray(output)) {\n\t\t\t\tassert.equal(output.length, 3);\n\t\t\t\tassert.ok(output.find(({ fileName }) => fileName === 'b.js'));\n\t\t\t\tassert.ok(output.find(({ fileName }) => fileName === 'c.js'));\n\t\t\t} else {\n\t\t\t\tassert.equal(Object.keys(output).length, 3);\n\t\t\t\tassert.equal('b.js' in output, true);\n\t\t\t\tassert.equal('c.js' in output, true);\n\t\t\t}\n\t\t});\n\n\t\tit('handles references to `global`', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/global/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\n\t\t\tconst mockWindow = {};\n\t\t\tconst mockGlobal = {};\n\t\t\tconst mockSelf = {};\n\n\t\t\tconst fn = new Function('module', 'globalThis', 'window', 'global', 'self', code);\n\n\t\t\tfn({}, undefined, mockWindow, mockGlobal, mockSelf);\n\t\t\tassert.equal(mockWindow.foo, 'bar', code);\n\t\t\tassert.equal(mockGlobal.foo, undefined, code);\n\t\t\tassert.equal(mockSelf.foo, undefined, code);\n\n\t\t\tfn({}, undefined, undefined, mockGlobal, mockSelf);\n\t\t\tassert.equal(mockGlobal.foo, 'bar', code);\n\t\t\tassert.equal(mockSelf.foo, undefined, code);\n\n\t\t\tfn({}, undefined, undefined, undefined, mockSelf);\n\t\t\tassert.equal(mockSelf.foo, 'bar', code);\n\t\t});\n\n\t\tit('handles multiple references to `global`', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/global-in-if-block/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\t\t\tconst fn = new Function('module', 'exports', 'globalThis', code);\n\t\t\tconst module = { exports: {} };\n\t\t\tconst globalThis = {};\n\n\t\t\tfn(module, module.exports, globalThis);\n\t\t\tassert.equal(globalThis.count, 1);\n\n\t\t\tfn(module, module.exports, globalThis);\n\t\t\tassert.equal(globalThis.count, 2);\n\t\t});\n\n\t\tit('handles transpiled CommonJS modules', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/corejs/literal-with-default.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\t\t\tconst module = { exports: {} };\n\n\t\t\tconst fn = new Function('module', 'exports', code);\n\t\t\tfn(module, module.exports);\n\n\t\t\tassert.equal(module.exports, 'foobar', code);\n\t\t});\n\n\t\tit('handles successive builds', async () => {\n\t\t\tconst plugin = commonjs();\n\t\t\tlet bundle = await rollup({\n\t\t\t\tinput: 'samples/corejs/literal-with-default.js',\n\t\t\t\tplugins: [plugin]\n\t\t\t});\n\t\t\tawait bundle.generate({\n\t\t\t\tformat: 'cjs'\n\t\t\t});\n\n\t\t\tbundle = await rollup({\n\t\t\t\tinput: 'samples/corejs/literal-with-default.js',\n\t\t\t\tplugins: [plugin]\n\t\t\t});\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\n\t\t\tconst module = { exports: {} };\n\n\t\t\tconst fn = new Function('module', 'exports', code);\n\t\t\tfn(module, module.exports);\n\n\t\t\tassert.equal(module.exports, 'foobar', code);\n\t\t});\n\n\t\tit('allows named exports to be added explicitly via config', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/custom-named-exports/main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\tresolve(),\n\t\t\t\t\tcommonjs({\n\t\t\t\t\t\tnamedExports: {\n\t\t\t\t\t\t\t'samples/custom-named-exports/secret-named-exporter.js': ['named'],\n\t\t\t\t\t\t\texternal: ['message']\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t]\n\t\t\t});\n\n\t\t\tawait executeBundle(bundle);\n\t\t});\n\n\t\tit('handles warnings without error when resolving named exports', () => {\n\t\t\treturn rollup({\n\t\t\t\tinput: 'samples/custom-named-exports-warn-builtins/main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\tresolve(),\n\t\t\t\t\tcommonjs({\n\t\t\t\t\t\tnamedExports: {\n\t\t\t\t\t\t\tevents: ['message']\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t]\n\t\t\t});\n\t\t});\n\n\t\tit('handles symlinked node_modules with preserveSymlinks: false', () => {\n\t\t\tconst cwd = process.cwd();\n\n\t\t\t// ensure we resolve starting from a directory with\n\t\t\t// symlinks in node_modules.\n\n\t\t\tprocess.chdir('samples/symlinked-node-modules');\n\n\t\t\treturn rollup({\n\t\t\t\tinput: './index.js',\n\t\t\t\tonwarn(warning) {\n\t\t\t\t\t// should not get a warning about unknown export 'foo'\n\t\t\t\t\tthrow new Error(`Unexpected warning: ${warning.message}`);\n\t\t\t\t},\n\t\t\t\tplugins: [\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tpreserveSymlinks: false,\n\t\t\t\t\t\tpreferBuiltins: false\n\t\t\t\t\t}),\n\t\t\t\t\tcommonjs({\n\t\t\t\t\t\tnamedExports: {\n\t\t\t\t\t\t\tevents: ['foo']\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t]\n\t\t\t})\n\t\t\t\t.then(v => {\n\t\t\t\t\tprocess.chdir(cwd);\n\t\t\t\t\treturn v;\n\t\t\t\t})\n\t\t\t\t.catch(err => {\n\t\t\t\t\tprocess.chdir(cwd);\n\t\t\t\t\tthrow err;\n\t\t\t\t});\n\t\t});\n\n\t\tit('handles named exports for built-in shims', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/custom-named-exports-browser-shims/main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tpreferBuiltins: false\n\t\t\t\t\t}),\n\t\t\t\t\tcommonjs({\n\t\t\t\t\t\tnamedExports: {\n\t\t\t\t\t\t\tevents: ['foo']\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t]\n\t\t\t});\n\n\t\t\tawait executeBundle(bundle);\n\t\t});\n\n\t\tit('ignores false positives with namedExports (#36)', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/custom-named-exports-false-positive/main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\tresolve(),\n\t\t\t\t\tcommonjs({\n\t\t\t\t\t\tnamedExports: {\n\t\t\t\t\t\t\tirrelevant: ['lol']\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t]\n\t\t\t});\n\n\t\t\tawait executeBundle(bundle);\n\t\t});\n\n\t\tit('converts a CommonJS module with custom file extension', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/extension/main.coffee',\n\t\t\t\tplugins: [commonjs({ extensions: ['.coffee'] })]\n\t\t\t});\n\n\t\t\tassert.equal((await executeBundle(bundle)).exports, 42);\n\t\t});\n\n\t\tit('identifies named exports from object literals', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/named-exports-from-object-literal/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tconst { code } = await bundle.generate({\n\t\t\t\tformat: 'cjs'\n\t\t\t});\n\n\t\t\tconst fn = new Function('module', 'assert', code);\n\t\t\tfn({}, assert);\n\t\t});\n\n\t\tit('can ignore references to `global`', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/ignore-global/main.js',\n\t\t\t\tplugins: [commonjs({ ignoreGlobal: true })],\n\t\t\t\tonwarn: warning => {\n\t\t\t\t\tif (warning.code === 'THIS_IS_UNDEFINED') return;\n\t\t\t\t\tconsole.warn(warning.message);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\t\t\tconst { exports, global } = await executeBundle(bundle);\n\n\t\t\tassert.equal(exports.immediate1, global.setImmediate, code);\n\t\t\tassert.equal(exports.immediate2, global.setImmediate, code);\n\t\t\tassert.equal(exports.immediate3, null, code);\n\t\t});\n\n\t\tit('can handle parens around right have node while producing default export', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/paren-expression/index.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tassert.equal((await executeBundle(bundle)).exports, 42);\n\t\t});\n\n\t\tdescribe('typeof transforms', () => {\n\t\t\tit('correct-scoping', async () => {\n\t\t\t\tconst bundle = await rollup({\n\t\t\t\t\tinput: 'samples/umd/correct-scoping.js',\n\t\t\t\t\tplugins: [commonjs()]\n\t\t\t\t});\n\n\t\t\t\tassert.equal((await executeBundle(bundle)).exports, 'object');\n\t\t\t});\n\n\t\t\tit('protobuf', async () => {\n\t\t\t\tconst bundle = await rollup({\n\t\t\t\t\tinput: 'samples/umd/protobuf.js',\n\t\t\t\t\texternal: ['bytebuffer'],\n\t\t\t\t\tplugins: [commonjs()]\n\t\t\t\t});\n\n\t\t\t\tassert.equal((await executeBundle(bundle)).exports, true);\n\t\t\t});\n\n\t\t\tit('sinon', async () => {\n\t\t\t\tconst bundle = await rollup({\n\t\t\t\t\tinput: 'samples/umd/sinon.js',\n\t\t\t\t\tplugins: [commonjs()]\n\t\t\t\t});\n\n\t\t\t\tconst { code } = getOutputFromGenerated(await bundle.generate({ format: 'es' }));\n\n\t\t\t\tassert.equal(code.indexOf('typeof require'), -1, code);\n\t\t\t\t// assert.notEqual( code.indexOf( 'typeof module' ), -1, code ); // #151 breaks this test\n\t\t\t\t// assert.notEqual( code.indexOf( 'typeof define' ), -1, code ); // #144 breaks this test\n\t\t\t});\n\t\t});\n\n\t\tit('deconflicts helper name', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/deconflict-helpers/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tconst { exports } = await executeBundle(bundle);\n\t\t\tassert.notEqual(exports, 'nope');\n\t\t});\n\n\t\tit('deconflicts reserved keywords', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/reserved-as-property/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tconst reservedProp = (await executeBundle(bundle, { exports: 'named' })).exports.delete;\n\t\t\tassert.equal(reservedProp, 'foo');\n\t\t});\n\n\t\tit('does not process the entry file when it has a leading \".\" (issue #63)', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: './function/basic/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tawait executeBundle(bundle);\n\t\t});\n\n\t\tit('does not reexport named contents', async () => {\n\t\t\ttry {\n\t\t\t\tawait rollup({\n\t\t\t\t\tinput: 'samples/reexport/main.js',\n\t\t\t\t\tplugins: [commonjs()]\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tassert.equal(\n\t\t\t\t\terror.message,\n\t\t\t\t\t`'named' is not exported by samples${path.sep}reexport${path.sep}reexport.js`\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tit('respects other plugins', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/other-transforms/main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttransform(code, id) {\n\t\t\t\t\t\t\tif (id[0] === '\\0') return null;\n\t\t\t\t\t\t\treturn code.replace('40', '41');\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tcommonjs()\n\t\t\t\t]\n\t\t\t});\n\n\t\t\tawait executeBundle(bundle);\n\t\t});\n\n\t\tit('rewrites top-level defines', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/define-is-undefined/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tfunction define() {\n\t\t\t\tthrow new Error('nope');\n\t\t\t}\n\n\t\t\tdefine.amd = true;\n\n\t\t\tconst { exports } = await executeBundle(bundle, { context: { define } });\n\t\t\tassert.equal(exports, 42);\n\t\t});\n\n\t\tit('respects options.external', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/external/main.js',\n\t\t\t\tplugins: [resolve(), commonjs()],\n\t\t\t\texternal: ['baz']\n\t\t\t});\n\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\t\t\tassert.equal(code.indexOf('hello'), -1);\n\n\t\t\tconst { exports } = await executeBundle(bundle);\n\t\t\tassert.equal(exports, 'HELLO');\n\t\t});\n\n\t\tit('prefers to set name using directory for index files', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/rename-index/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\t\t\tassert.equal(code.indexOf('var index'), -1);\n\t\t\tassert.notEqual(code.indexOf('var invalidVar'), -1);\n\t\t\tassert.notEqual(code.indexOf('var validVar'), -1);\n\t\t\tassert.notEqual(code.indexOf('var nonIndex'), -1);\n\t\t});\n\n\t\tit('does not misassign default when consuming rollup output', async () => {\n\t\t\t// Issue #224\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/use-own-output/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tconst window = {};\n\t\t\tawait executeBundle(bundle, { context: { window } });\n\t\t\tassert.notEqual(window.b.default, undefined);\n\t\t});\n\n\t\tit('does not warn even if the ES module not export \"default\"', async () => {\n\t\t\tconst warns = [];\n\t\t\tawait rollup({\n\t\t\t\tinput: 'samples/es-modules-without-default-export/main.js',\n\t\t\t\tplugins: [commonjs()],\n\t\t\t\tonwarn: warn => warns.push(warn)\n\t\t\t});\n\t\t\tassert.equal(warns.length, 0);\n\n\t\t\tawait rollup({\n\t\t\t\tinput: 'function/bare-import/bar.js',\n\t\t\t\tplugins: [commonjs()],\n\t\t\t\tonwarn: warn => warns.push(warn)\n\t\t\t});\n\t\t\tassert.equal(warns.length, 0);\n\n\t\t\tawait rollup({\n\t\t\t\tinput: 'function/bare-import-comment/main.js',\n\t\t\t\tplugins: [commonjs()],\n\t\t\t\tonwarn: warn => warns.push(warn)\n\t\t\t});\n\t\t\tassert.equal(warns.length, 0);\n\t\t});\n\n\t\tit('compiles with cache', async () => {\n\t\t\t// specific commonjs require() to ensure same instance is used\n\t\t\tconst commonjs = require('..');\n\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'function/index/main.js',\n\t\t\t\tplugins: [commonjs()]\n\t\t\t});\n\n\t\t\tawait rollup({\n\t\t\t\tinput: 'function/index/main.js',\n\t\t\t\tplugins: [commonjs()],\n\t\t\t\tcache: bundle\n\t\t\t});\n\t\t});\n\n\t\tit('creates an error with a code frame when parsing fails', async () => {\n\t\t\ttry {\n\t\t\t\tawait rollup({\n\t\t\t\t\tinput: 'samples/invalid-syntax/main.js',\n\t\t\t\t\tplugins: [commonjs()]\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tassert.equal(error.frame, '1: export const foo = 2,\\n                        ^');\n\t\t\t}\n\t\t});\n\n\t\tit('ignores virtual modules', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/ignore-virtual-modules/main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\tcommonjs(),\n\t\t\t\t\t{\n\t\t\t\t\t\tresolveId(id) {\n\t\t\t\t\t\t\tif (id === '\\0virtual' || id === '\\0resolved-virtual') {\n\t\t\t\t\t\t\t\treturn '\\0resolved-virtual';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tload(id) {\n\t\t\t\t\t\t\tif (id === '\\0resolved-virtual') {\n\t\t\t\t\t\t\t\treturn 'export default \"Virtual export\"';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t});\n\t\t\tassert.equal((await executeBundle(bundle)).exports, 'Virtual export');\n\t\t});\n\n\t\tit('does not produce warnings when importing .mjs without default export', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'main.mjs',\n\t\t\t\tonwarn(warning) {\n\t\t\t\t\t// The interop should not trigger a \"default is not exported\" warning\n\t\t\t\t\tthrow new Error(`Unexpected warning: ${warning.message}`);\n\t\t\t\t},\n\t\t\t\tplugins: [\n\t\t\t\t\tcommonjs(),\n\t\t\t\t\t{\n\t\t\t\t\t\tload(id) {\n\t\t\t\t\t\t\tif (id === 'main.mjs') {\n\t\t\t\t\t\t\t\treturn 'import cjs from \"cjs.js\"; export default cjs;';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (id === 'cjs.js') {\n\t\t\t\t\t\t\t\t// CJS libraries expect to receive a CJS file here\n\t\t\t\t\t\t\t\treturn 'module.exports = require(\"fromNodeModules\");';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (id === 'fromNodeModules.mjs') {\n\t\t\t\t\t\t\t\treturn 'export const result = \"from esm\";';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolveId(id) {\n\t\t\t\t\t\t\t// rollup-plugin-node-resolve usually prefers ESM versions\n\t\t\t\t\t\t\tif (id === 'fromNodeModules') {\n\t\t\t\t\t\t\t\treturn 'fromNodeModules.mjs';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn id;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t});\n\t\t\tassert.deepEqual((await executeBundle(bundle)).exports, { result: 'from esm' });\n\t\t});\n\n\t\tit('produces optimized code when importing esm with a known default export', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\tcommonjs(),\n\t\t\t\t\t{\n\t\t\t\t\t\tload(id) {\n\t\t\t\t\t\t\tif (id === 'main.js') {\n\t\t\t\t\t\t\t\treturn 'module.exports = require(\"esm.js\")';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (id === 'esm.js') {\n\t\t\t\t\t\t\t\treturn 'export const ignored = \"ignored\"; export default \"default\"';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolveId(id) {\n\t\t\t\t\t\t\treturn id;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t});\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\t\t\tassert.equal(\n\t\t\t\tcode,\n\t\t\t\t`'use strict';\n\nvar require$$0 = \"default\";\n\nvar main = require$$0;\n\nmodule.exports = main;\n`\n\t\t\t);\n\t\t});\n\n\t\tit('produces optimized code when importing esm without a default export', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\tcommonjs(),\n\t\t\t\t\t{\n\t\t\t\t\t\tload(id) {\n\t\t\t\t\t\t\tif (id === 'main.js') {\n\t\t\t\t\t\t\t\treturn 'module.exports = require(\"esm.js\")';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (id === 'esm.js') {\n\t\t\t\t\t\t\t\treturn 'export const value = \"value\";';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolveId(id) {\n\t\t\t\t\t\t\treturn id;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t});\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\t\t\tassert.equal(\n\t\t\t\tcode,\n\t\t\t\t`'use strict';\n\nconst value = \"value\";\n\nvar esm = /*#__PURE__*/Object.freeze({\n\tvalue: value\n});\n\nvar main = esm;\n\nmodule.exports = main;\n`\n\t\t\t);\n\t\t});\n\n\t\tit('handles array destructuring assignment', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/array-destructuring-assignment/main.js',\n\t\t\t\tplugins: [commonjs({ sourceMap: true })]\n\t\t\t});\n\n\t\t\tconst code = await getCodeFromBundle(bundle);\n\t\t\tassert.equal(\n\t\t\t\tcode,\n\t\t\t\t`'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction shuffleArray(array) {\n  for (let i = array.length - 1; i > 0; i--) {\n    const j = Math.floor(Math.random() * (i + 1));\n    [array[i], array[j]] = [array[j], array[i]];\n  }\n}\n\nvar shuffleArray_1 = shuffleArray;\n\nvar main = {\n\tshuffleArray: shuffleArray_1\n};\n\nexports.default = main;\nexports.shuffleArray = shuffleArray_1;\n`\n\t\t\t);\n\t\t});\n\n\t\tit('normalizes paths used in the named export map', async () => {\n\t\t\t// Deliberately denormalizes file paths and ensures named exports\n\t\t\t// continue to work.\n\t\t\tfunction hookedResolve() {\n\t\t\t\tconst resolvePlugin = resolve();\n\t\t\t\tconst oldResolve = resolvePlugin.resolveId;\n\t\t\t\tresolvePlugin.resolveId = async function() {\n\t\t\t\t\tconst result = await oldResolve.apply(resolvePlugin, arguments);\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\tresult.id = result.id.replace(/\\/|\\\\/, path.sep);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn result;\n\t\t\t\t};\n\n\t\t\t\treturn resolvePlugin;\n\t\t\t}\n\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'samples/custom-named-exports/main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\thookedResolve(),\n\t\t\t\t\tcommonjs({\n\t\t\t\t\t\tnamedExports: {\n\t\t\t\t\t\t\t'samples/custom-named-exports/secret-named-exporter.js': ['named'],\n\t\t\t\t\t\t\texternal: ['message']\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t]\n\t\t\t});\n\n\t\t\tawait executeBundle(bundle);\n\t\t});\n\t});\n});\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n    \"compilerOptions\": {\n        \"lib\": [\n            \"es6\"\n        ],\n        \"noImplicitAny\": true,\n        \"noImplicitThis\": true,\n        \"strict\": true,\n        \"noEmit\": true,\n        \"allowJs\": true\n    },\n    \"files\": [\n        \"index.d.ts\",\n        \"typings-test.js\"\n    ]\n}\n"
  },
  {
    "path": "typings-test.js",
    "content": "// @ts-check\nimport commonjs from '.';\n\n/** @type {import(\"rollup\").RollupOptions} */\nconst config = {\n\tinput: 'main.js',\n\toutput: {\n\t\tfile: 'bundle.js',\n\t\tformat: 'iife'\n\t},\n\tplugins: [\n\t\tcommonjs({\n\t\t\tinclude: 'node_modules/**',\n\t\t\texclude: [ 'node_modules/foo/**', 'node_modules/bar/**', /node_modules/ ],\n\t\t\textensions: [ '.js', '.coffee' ],\n\t\t\tignoreGlobal: false,\n\t\t\tsourceMap: false,\n\t\t\tnamedExports: { './module.js': ['foo', 'bar' ] },\n\t\t\tignore: [ 'conditional-runtime-dependency' ]\n\t\t})\n\t]\n};\n\nexport default config;\n"
  }
]