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'
});
}
^ this function, when run subsequently, will produce the same output.js even when input.ts file has changed. It's like it remembers the file from 1st run and never reloads it.
Isolated reproduction: https://gist.github.com/darsain/1609f59ded10c75bab70dc08340db5d4
Steps to reproduce:
npm installnpm start - creates an interactive build processB key to build output.js out of input.tsinput.ts and press B againSubsequent runs of rollup with typescript plugin on modified files should produce new correct output.
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.
Doesn't happen if I remove the typescript plugin.
Also doesn't happen with rollup.watch, which I don't understand. Isn't it using the same APIs under the hood?
Also doesn't happen with rollup.watch
That jumps out at me as an issue with Gulp watch. I'd also recommend trying a script using chokidar directly (which is what Rollup uses). It looks like Gulp is simply forwarding on glob-watcher (https://github.com/gulpjs/gulp/blob/5667666ffae15c169f99c7096ca59c05f9440272/index.js#L6) which may be the culprit here. I think we're going to need your help in further distilling why this happens with Gulp and not with other setups, before this will become fixable.
Gulp has nothing to do with this. It doesn't touch anything. As I've written above:
Gulp is here only to facilitate the watching and subsequent runs without restarting the process.
The scripts builder didn't accept any files from gulp. It was just running rollup.rollup() with typescript plugin whenever input.ts changed so that this was easy and comfy for you guys to test and replicate.
But alright, I've re-implemented the reproduction by stripping the gulp out completely, and now the builder instead listens on keypresses from stdin to build (the buildScripts() function didn't change at all).
Updated gist https://gist.github.com/darsain/1609f59ded10c75bab70dc08340db5d4
The steps to reproduce now changed slightly to:
npm installnpm start - creates an interactive build processB key to build output.js out of input.tsinput.ts and press B againThe whole point of this reproduction is to show that subsequent rollup.rollup() calls with typesecript plugin remember the first input file and never reload it when called again. You have to restart the process to get it to build new files.
Or use rollup's built in watch that for some reason doesn't have this problem.
Another attempt to describe the problem as concisely as I can:
buildScripts() function in builder.js file.output.js even when input.ts file has changed unless you restart the whole node process.Gulp has nothing to do with this. It doesn't touch anything.
Perhaps you reacted before you digested all of that statement. Gulp === glob-watcher for all intents and purposes.
Or use rollup's built in watch that for some reason doesn't have this problem.
This is the outlier. We'll have to identify why this case doesn't have the problem. My guess is that there's a cache being invalidated.
I'm also encountering this issue when using rollup's watch feature.
My command line is:
rollup -i input.ts -o output.js -p typescript -w
One first run, output.js is generated.
When input.ts is modified and saved once, output.ts remains the same.
Touching/saving input.ts once again (without any code change), and now output.ts gets updated.
Btw, the rollup-plugin-typescript2 works correct 😐
@artemjackson please do not post subsequent replies - use the "edit" feature. please do not post "me too" replies - use the reaction buttons.
I've updated to the latest [email protected] + [email protected] + @rollup/[email protected] today, and now even rollup.watch doesn't work, and outputs same files every time it runs, regardless of changes.
So this plugin is pretty much unusable now.
Tried switching to rollup-plugin-typescript2 as suggested in the comment above, and all works fine there. That comment is therefore a useful advice to everyone affected by this bug, and a nice pointer to whoever will decide to fix it, since if you know it's working there, you might want to investigate what they're doing differently. Without that comment I would still have to suffer running every build manually, so marking it as off-topic and hiding it seems petty guys...
marking it as off-topic and hiding it seems petty guys
It's not petty at all. Directing users to a different plugin doesn't solve the issue with the plugin. If this were a support forum, that'd be perfectly fine, if not expected. But this isn't a support forum (as mentioned in the issue templates) - this is for issues to resolve problems and enhancements for specific plugins. If a comment doesn't address a potential fix or provide information for triage, it's off topic.
We'll close this one as it doesn't look like it'll receive further triage from the OP.