[
  {
    "path": ".eslintrc",
    "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\ndist\n.gobble*\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\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# rollup-plugin-replace changelog\n\n## 2.2.0\n*2019-04-10*\n* Add index.d.ts typings file ([#31](https://github.com/rollup/rollup-plugin-replace/pull/31))\n\n## 2.1.1\n*2019-03-18*\n* Update rollup-pluginutils ([#29](https://github.com/rollup/rollup-plugin-replace/pull/29))\n* Update dependencies ([#30](https://github.com/rollup/rollup-plugin-replace/pull/30))\n\n## 2.1.0\n*2018-10-07*\n* Do not mutate values passed as option ([#22](https://github.com/rollup/rollup-plugin-replace/pull/22))\n* Update dependencies and improve tests ([#26](https://github.com/rollup/rollup-plugin-replace/pull/26))\n\n## 2.0.0\n\n* Only match on word boundaries, unless delimiters are empty strings ([#10](https://github.com/rollup/rollup-plugin-replace/pull/10))\n\n## 1.2.1\n\n* Match longest keys first ([#8](https://github.com/rollup/rollup-plugin-replace/pull/8))\n* Escape keys ([#9](https://github.com/rollup/rollup-plugin-replace/pull/9))\n\n## 1.2.0\n\n* Allow replacement to be a function that takes a module ID ([#1](https://github.com/rollup/rollup-plugin-replace/issues/1))\n\n## 1.1.1\n\n* Return a `name`\n\n## 1.1.0\n\n* Generate sourcemaps by default\n\n## 1.0.1\n\n* Include correct files in package\n\n## 1.0.0\n\n* First release\n"
  },
  {
    "path": "README.md",
    "content": "# Moved\n\nThis module has moved and is now available at [@rollup/plugin-replace](https://github.com/rollup/plugins). Please update your dependencies. This repository is no longer maintained.\n\n# rollup-plugin-replace\n\n[![](https://img.shields.io/npm/v/rollup-plugin-replace.svg?style=flat)](https://www.npmjs.com/package/rollup-plugin-replace)\n\nReplace strings in files while bundling them.\n\n## Installation\n\n```bash\nnpm install --save-dev rollup-plugin-replace\n```\n\n## Usage\n\nGenerally, you need to ensure that rollup-plugin-replace goes _before_ other things (like rollup-plugin-commonjs) in your `plugins` array, so that those plugins can apply any optimisations such as dead code removal.\n\n```js\n// rollup.config.js\nimport replace from 'rollup-plugin-replace';\n\nexport default {\n\t// ...\n\tplugins: [\n\t\treplace({\n\t\t\tENVIRONMENT: JSON.stringify('production')\n\t\t})\n\t]\n};\n```\n\n## Options\n\n```js\n{\n  // a minimatch pattern, or array of patterns, of files that\n  // should be processed by this plugin (if omitted, all files\n  // are included by default)...\n  include: 'config.js',\n\n  // ...and those that shouldn't, if `include` is otherwise\n  // too permissive\n  exclude: 'node_modules/**',\n\n  // To replace every occurrence of `<@foo@>` instead of every\n  // occurrence of `foo`, supply delimiters\n  delimiters: ['<@', '@>'],\n\n  // All other options are treated as `string: replacement`\n  // replacers...\n  VERSION: '1.0.0',\n  ENVIRONMENT: JSON.stringify('development'),\n\n  // or `string: (id) => replacement` functions...\n  __dirname: (id) => `'${path.dirname(id)}'`,\n\n  // ...unless you want to be careful about separating\n  // values from other options, in which case you can:\n  values: {\n    VERSION: '1.0.0',\n    ENVIRONMENT: JSON.stringify('development')\n  }\n}\n```\n\n## Word boundaries\n\nBy default, values will only match if they are surrounded by _word boundaries_ — i.e. with options like this...\n\n```js\n{\n\tchanged: 'replaced';\n}\n```\n\n...and code like this...\n\n```js\nconsole.log('changed');\nconsole.log('unchanged');\n```\n\n...the result will be this:\n\n```js\nconsole.log('replaced');\nconsole.log('unchanged');\n```\n\nIf that's not what you want, specify empty strings as delimiters:\n\n```js\n{\n  changed: 'replaced',\n  delimiters: ['', '']\n}\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\nenvironment:\n  matrix:\n    # node.js\n    - nodejs_version: stable\n\ninstall:\n  - ps: Install-Product node $env:nodejs_version\n  - npm ci\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\ntype Replacement = string | ((id: string) => string);\n\ninterface RollupReplaceOptions {\n\t/**\n\t * A minimatch pattern, or array of patterns, of files that should be\n\t * processed by this plugin (if omitted, all files are included by default)\n\t */\n\tinclude?: string | RegExp | ReadonlyArray<string | RegExp> | null;\n\t/**\n\t * Files that should be excluded, if `include` is otherwise too permissive.\n\t */\n\texclude?: string | RegExp | ReadonlyArray<string | RegExp> | null;\n\t/**\n\t * To replace every occurrence of `<@foo@>` instead of every occurrence\n\t * of `foo`, supply delimiters\n\t */\n\tdelimiters?: [string, string];\n\t/**\n\t * You can separate values to replace from other options.\n\t */\n\tvalues?: { [str: string]: Replacement };\n\n\t/**\n\t * All other options are treated as `string: replacement` replacers,\n\t * or `string: (id) => replacement` functions.\n\t */\n\t[str: string]: Replacement | RollupReplaceOptions['include'] | RollupReplaceOptions['values'];\n}\n\n/**\n * Replace strings in files while bundling them.\n */\nexport default function replace(options?: RollupReplaceOptions): Plugin;\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"rollup-plugin-replace\",\n  \"version\": \"2.2.0\",\n  \"devDependencies\": {\n    \"eslint\": \"^6.3.0\",\n    \"eslint-plugin-import\": \"^2.18.2\",\n    \"husky\": \"^3.0.5\",\n    \"lint-staged\": \"^9.2.5\",\n    \"locate-character\": \"^2.0.5\",\n    \"mocha\": \"^6.2.0\",\n    \"prettier\": \"^1.16.4\",\n    \"rollup\": \"^1.9.1\",\n    \"rollup-plugin-buble\": \"^0.19.6\",\n    \"shx\": \"^0.3.2\",\n    \"source-map\": \"^0.7.3\",\n    \"typescript\": \"^3.4.3\"\n  },\n  \"main\": \"dist/rollup-plugin-replace.cjs.js\",\n  \"module\": \"dist/rollup-plugin-replace.es.js\",\n  \"dependencies\": {\n    \"magic-string\": \"^0.25.2\",\n    \"rollup-pluginutils\": \"^2.6.0\"\n  },\n  \"scripts\": {\n    \"test\": \"npm run test:only\",\n    \"test:only\": \"mocha && tsc\",\n    \"pretest\": \"npm run build\",\n    \"build\": \"rollup -c\",\n    \"prebuild\": \"shx rm -rf dist/*\",\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  \"repository\": \"rollup/rollup-plugin-replace\",\n  \"keywords\": [\n    \"rollup\",\n    \"rollup-plugin\",\n    \"es2015\",\n    \"npm\",\n    \"modules\"\n  ],\n  \"author\": \"Rich Harris <richard.a.harris@gmail.com>\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/rollup/rollup-plugin-replace/issues\"\n  },\n  \"homepage\": \"https://github.com/rollup/rollup-plugin-replace#readme\"\n}\n"
  },
  {
    "path": "rollup.config.js",
    "content": "import buble from 'rollup-plugin-buble';\nimport pkg from './package.json';\n\nvar external = Object.keys(pkg.dependencies).concat('path');\n\nexport default {\n\tinput: 'src/index.js',\n\tplugins: [ buble() ],\n\texternal,\n\toutput: [\n\t\t{ file: pkg.main, format: 'cjs' },\n\t\t{ file: pkg.module, format: 'es' }\n\t]\n};\n"
  },
  {
    "path": "src/index.js",
    "content": "import MagicString from 'magic-string';\nimport { createFilter } from 'rollup-pluginutils';\n\nfunction escape(str) {\n\treturn str.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n}\n\nfunction ensureFunction(functionOrValue) {\n\tif (typeof functionOrValue === 'function') return functionOrValue;\n\treturn () => functionOrValue;\n}\n\nfunction longest(a, b) {\n\treturn b.length - a.length;\n}\n\nfunction getReplacements(options) {\n\tif (options.values) {\n\t\treturn Object.assign({}, options.values);\n\t} else {\n\t\tconst values = Object.assign({}, options);\n\t\tdelete values.delimiters;\n\t\tdelete values.include;\n\t\tdelete values.exclude;\n\t\tdelete values.sourcemap;\n\t\tdelete values.sourceMap;\n\t\treturn values;\n\t}\n}\n\nfunction mapToFunctions(object) {\n\treturn Object.keys(object).reduce((functions, key) => {\n\t\tfunctions[key] = ensureFunction(object[key]);\n\t\treturn functions;\n\t}, {});\n}\n\nexport default function replace(options = {}) {\n\tconst filter = createFilter(options.include, options.exclude);\n\tconst { delimiters } = options;\n\tconst functionValues = mapToFunctions(getReplacements(options));\n\tconst keys = Object.keys(functionValues)\n\t\t.sort(longest)\n\t\t.map(escape);\n\n\tconst pattern = delimiters\n\t\t? new RegExp(`${escape(delimiters[0])}(${keys.join('|')})${escape(delimiters[1])}`, 'g')\n\t\t: new RegExp(`\\\\b(${keys.join('|')})\\\\b`, 'g');\n\n\treturn {\n\t\tname: 'replace',\n\n\t\ttransform(code, id) {\n\t\t\tif (!filter(id)) return null;\n\n\t\t\tconst magicString = new MagicString(code);\n\n\t\t\tlet hasReplacements = false;\n\t\t\tlet match;\n\t\t\tlet start;\n\t\t\tlet end;\n\t\t\tlet replacement;\n\n\t\t\twhile ((match = pattern.exec(code))) {\n\t\t\t\thasReplacements = true;\n\n\t\t\t\tstart = match.index;\n\t\t\t\tend = start + match[0].length;\n\t\t\t\treplacement = String(functionValues[match[1]](id));\n\n\t\t\t\tmagicString.overwrite(start, end, replacement);\n\t\t\t}\n\n\t\t\tif (!hasReplacements) return null;\n\n\t\t\tconst result = { code: magicString.toString() };\n\t\t\tif (options.sourceMap !== false && options.sourcemap !== false)\n\t\t\t\tresult.map = magicString.generateMap({ hires: true });\n\n\t\t\treturn result;\n\t\t}\n\t};\n}\n"
  },
  {
    "path": "test/form/delimiters/_config.js",
    "content": "module.exports = {\n\tdescription: 'observes delimiters',\n\toptions: {\n\t\toriginal: 'replaced',\n\t\tdelimiters: ['<%', '%>']\n\t}\n};\n"
  },
  {
    "path": "test/form/delimiters/input.js",
    "content": "console.log(`\n  <%original%>\n  <% original%>\n  <%original %>\n`);\n"
  },
  {
    "path": "test/form/delimiters/output.js",
    "content": "console.log(`\n  replaced\n  <% original%>\n  <%original %>\n`);\n"
  },
  {
    "path": "test/form/match-variables/_config.js",
    "content": "module.exports = {\n\tdescription: 'matches most specific variables',\n\toptions: {\n\t\tBUILD: 'beta',\n\t\tBUILD_VERSION: '1.0.0'\n\t}\n};\n"
  },
  {
    "path": "test/form/match-variables/input.js",
    "content": "console.log('BUILD version BUILD_VERSION');\n"
  },
  {
    "path": "test/form/match-variables/output.js",
    "content": "console.log('beta version 1.0.0');\n"
  },
  {
    "path": "test/form/observe-plugin-options/_config.js",
    "content": "module.exports = {\n\tdescription: 'does not replace plugin options',\n\toptions: {\n\t\toriginal: 'replaced',\n\t\tdelimiters: ['', ''],\n\t\tsourcemap: true,\n\t\tsourceMap: true,\n\t\tinclude: '**/input.js',\n\t\texclude: 'node_modules/**'\n\t}\n};\n"
  },
  {
    "path": "test/form/observe-plugin-options/input.js",
    "content": "console.log(`\n  original\n  delimiters\n  sourcemap\n  sourceMap\n  include\n  exclude\n`);\n"
  },
  {
    "path": "test/form/observe-plugin-options/output.js",
    "content": "console.log(`\n  replaced\n  delimiters\n  sourcemap\n  sourceMap\n  include\n  exclude\n`);\n"
  },
  {
    "path": "test/form/replace-strings/_config.js",
    "content": "module.exports = {\n\tdescription: 'replaces strings',\n\toptions: {\n\t\tANSWER: '42'\n\t}\n};\n"
  },
  {
    "path": "test/form/replace-strings/input.js",
    "content": "console.log(ANSWER);\n"
  },
  {
    "path": "test/form/replace-strings/output.js",
    "content": "console.log(42);\n"
  },
  {
    "path": "test/form/replacement-function/_config.js",
    "content": "module.exports = {\n\tdescription: 'allows replacement to be a function',\n\toptions: {\n\t\t__filename(id) {\n\t\t\treturn JSON.stringify(id.slice(__dirname.length + 1));\n\t\t}\n\t}\n};\n"
  },
  {
    "path": "test/form/replacement-function/input.js",
    "content": "export default __filename;\n"
  },
  {
    "path": "test/form/replacement-function/output.js",
    "content": "export default \"input.js\";\n"
  },
  {
    "path": "test/form/special-characters/_config.js",
    "content": "module.exports = {\n\tdescription: 'supports special characters',\n\toptions: {\n\t\t\"require('one')\": '1',\n\t\tdelimiters: ['', '']\n\t}\n};\n"
  },
  {
    "path": "test/form/special-characters/input.js",
    "content": "const one = require('one');\nconsole.log(one);\n"
  },
  {
    "path": "test/form/special-characters/output.js",
    "content": "const one = 1;\nconsole.log(one);\n"
  },
  {
    "path": "test/function/replacement-function/_config.js",
    "content": "module.exports = {\n\tdescription: 'allows replacement to be a function',\n\tpluginOptions: {\n\t\t__filename(id) {\n\t\t\treturn JSON.stringify(id.slice(__dirname.length + 1));\n\t\t}\n\t}\n};\n"
  },
  {
    "path": "test/function/replacement-function/dir/foo.js",
    "content": "export default __filename;\n"
  },
  {
    "path": "test/function/replacement-function/main.js",
    "content": "import foo from './dir/foo.js';\n\nvar bar = __filename;\n\n// To work around windows issues\nassert.equal(foo.slice(0, 3), 'dir');\nassert.equal(foo.slice(-6), 'foo.js');\nassert.equal(foo.length, 10);\nassert.equal(bar, 'main.js');\n"
  },
  {
    "path": "test/function/word-boundaries/_config.js",
    "content": "const assert = require('assert');\n\nmodule.exports = {\n\tdescription: 'uses word boundaries if delimiters are unspecified',\n\tpluginOptions: { changed: 'replaced' },\n\texports(exports) {\n\t\tassert.deepEqual(exports, {\n\t\t\tfoo: 'unchanged',\n\t\t\tbar: 'replaced'\n\t\t});\n\t}\n};\n"
  },
  {
    "path": "test/function/word-boundaries/main.js",
    "content": "export const foo = 'unchanged';\nexport const bar = 'changed';\n"
  },
  {
    "path": "test/test.js",
    "content": "/* eslint-env mocha */\n/* eslint-disable no-console */\n\nconst assert = require('assert');\nconst { rollup } = require('rollup');\nconst replace = require('../dist/rollup-plugin-replace.cjs.js');\nconst fs = require('fs');\nconst { SourceMapConsumer } = require('source-map');\nconst { getLocator } = require('locate-character');\n\nprocess.chdir(__dirname);\n\nfunction execute(code, context = {}) {\n\tlet fn;\n\tconst contextKeys = Object.keys(context);\n\tconst argNames = contextKeys.concat('module', 'exports', 'assert', code);\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\tconst module = { exports: {} };\n\tconst argValues = contextKeys.map(key => context[key]).concat(module, module.exports, assert);\n\n\tfn(...argValues);\n\n\treturn module.exports;\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\ndescribe('rollup-plugin-replace', () => {\n\tdescribe('form', () => {\n\t\tconst transformContext = {};\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}: ${config.description}`, () => {\n\t\t\t\tconst { transform } = replace(config.options);\n\t\t\t\tconst input = fs.readFileSync(`form/${dir}/input.js`, 'utf-8');\n\t\t\t\tconst expected = fs.readFileSync(`form/${dir}/output.js`, 'utf-8').trim();\n\n\t\t\t\treturn Promise.resolve(\n\t\t\t\t\ttransform.call(transformContext, input, `${__dirname}/form/${dir}/input.js`)\n\t\t\t\t).then(transformed => {\n\t\t\t\t\tconst actual = (transformed ? transformed.code : input).trim();\n\t\t\t\t\tassert.equal(actual, expected);\n\t\t\t\t});\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}: ${config.description}`, 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\treplace(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\t\t\t\tconst exports = execute(code, config.context);\n\n\t\t\t\tif (config.exports) config.exports(exports);\n\t\t\t});\n\t\t});\n\t});\n\n\tdescribe('misc', () => {\n\t\tit('does not mutate the values map properties', async () => {\n\t\t\tconst valuesMap = { ANSWER: '42' };\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'main.js',\n\t\t\t\tplugins: [\n\t\t\t\t\treplace({ values: valuesMap }),\n\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\tload(importee) {\n\t\t\t\t\t\t\tif (importee === 'main.js') {\n\t\t\t\t\t\t\t\treturn 'console.log(ANSWER);';\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\n\t\t\tconst { code } = getOutputFromGenerated(await bundle.generate({ format: 'es' }));\n\t\t\tassert.equal(code.trim(), 'console.log(42);');\n\t\t\tassert.deepEqual(valuesMap, { ANSWER: '42' });\n\t\t});\n\n\t\tit('generates sourcemaps', async () => {\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'main.js',\n\t\t\t\tonwarn(warning) {\n\t\t\t\t\tthrow new Error(warning.message);\n\t\t\t\t},\n\t\t\t\tplugins: [\n\t\t\t\t\treplace({ values: { ANSWER: '42' } }),\n\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\tload(importee) {\n\t\t\t\t\t\t\tif (importee === 'main.js') {\n\t\t\t\t\t\t\t\treturn 'import value from \"other.js\";\\nconsole.log(value);';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (importee === 'other.js') {\n\t\t\t\t\t\t\t\treturn 'export default ANSWER;';\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\n\t\t\tconst { code, map } = getOutputFromGenerated(\n\t\t\t\tawait bundle.generate({ format: 'es', sourcemap: true })\n\t\t\t);\n\n\t\t\tawait SourceMapConsumer.with(map, null, async smc => {\n\t\t\t\tconst locator = getLocator(code, { offsetLine: 1 });\n\n\t\t\t\tlet generatedLoc = locator('42');\n\t\t\t\tlet loc = smc.originalPositionFor(generatedLoc); // 42\n\t\t\t\tassert.equal(loc.source, 'other.js');\n\t\t\t\tassert.equal(loc.line, 1);\n\t\t\t\tassert.equal(loc.column, 15);\n\n\t\t\t\tgeneratedLoc = locator('log');\n\t\t\t\tloc = smc.originalPositionFor(generatedLoc); // log\n\t\t\t\tassert.equal(loc.source, 'main.js');\n\t\t\t\tassert.equal(loc.line, 2);\n\t\t\t\tassert.equal(loc.column, 8);\n\t\t\t});\n\t\t});\n\n\t\tit('does not generate sourcemaps if disabled', async () => {\n\t\t\tlet warned = false;\n\n\t\t\tconst bundle = await rollup({\n\t\t\t\tinput: 'main.js',\n\t\t\t\tonwarn(warning) {\n\t\t\t\t\tassert.equal(\n\t\t\t\t\t\twarning.message,\n\t\t\t\t\t\t\"Sourcemap is likely to be incorrect: a plugin ('replace') was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help\"\n\t\t\t\t\t);\n\t\t\t\t\twarned = true;\n\t\t\t\t},\n\t\t\t\tplugins: [\n\t\t\t\t\treplace({ values: { ANSWER: '42' }, sourcemap: false }),\n\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\tload(importee) {\n\t\t\t\t\t\t\tif (importee === 'main.js') {\n\t\t\t\t\t\t\t\treturn 'import value from \"other.js\";\\nconsole.log(value);';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (importee === 'other.js') {\n\t\t\t\t\t\t\t\treturn 'export default ANSWER;';\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\n\t\t\tassert.ok(!warned);\n\t\t\tawait bundle.generate({ format: 'es', sourcemap: true });\n\t\t\tassert.ok(warned);\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 { dirname } from 'path';\nimport replace 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\treplace({\n\t\t\tinclude: 'config.js',\n\t\t\texclude: 'node_modules/**',\n\t\t\tdelimiters: ['<@', '@>'],\n\t\t\tVERSION: '1.0.0',\n\t\t\tENVIRONMENT: JSON.stringify('development'),\n\t\t\t__dirname: id => `'${dirname(id)}'`,\n\t\t\tvalues: {\n\t\t\t\tVERSION: '1.0.0',\n\t\t\t\tENVIRONMENT: JSON.stringify('development')\n\t\t\t}\n\t\t})\n\t]\n};\n\nexport default config;\n"
  }
]