Skip to content

Instantly share code, notes, and snippets.

@darsain
Last active March 6, 2020 18:16
Show Gist options
  • Save darsain/1609f59ded10c75bab70dc08340db5d4 to your computer and use it in GitHub Desktop.
Save darsain/1609f59ded10c75bab70dc08340db5d4 to your computer and use it in GitHub Desktop.
@rollup/plugin-typescript producing the same output on subsequent runs bug reproduction
  • Rollup Plugin Name: @rollup/plugin-typescript
  • Rollup Plugin Version: 3.0.0
  • Rollup Version: 1.31.1
  • Operating System (or Browser): Win 10
  • Node Version: 13.7.0

Issue

When running rollup with typescirpt plugin multiple times without restarting the whole node process, the build will produce the same output even if the input files have changed. The new file is written, but it looks the same. It's as if creating a new bundle with rollup.rollup() remembers the old file and never reads the new one.

Steps to reproduce

  1. npm install
  2. npm start - creates an interactive build process
  3. press B key to build output.js out of input.ts
  4. modify input.ts and press B again
  5. see the build finish and produce the old version of the output
async function buildScripts() {
const rollup = require('rollup');
const typescript = require('@rollup/plugin-typescript');
const bundle = await rollup.rollup({
input: 'input.ts',
plugins: [typescript()]
});
await bundle.write({
file: 'output.js',
format: 'cjs'
});
}
// Build every time B is pressed
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', async function (key) {
if (key === '\u0003') process.exit(); // ctrl-c
if (key !== 'b') return;
process.stdout.write('Building "./output.js" ... ');
try {
await buildScripts();
process.stdout.write('done!\n');
} catch (error) {
process.stdout.write('error!\n');
console.error(error);
}
});
process.stdout.write('Press B key to build.\n');
console.log('foo');
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node builder.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@rollup/plugin-typescript": "^3.0.0",
"rollup": "^1.31.1",
"tslib": "^1.11.0",
"typescript": "^3.8.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment