Skip to content

Commit

Permalink
Merge branch 'master' into feat/yargs-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Feb 21, 2020
2 parents 9713f8e + db576f3 commit 5d690cc
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# rollup changelog

## 1.31.1
## 1.31.2
*unreleased*

### Pull Requests
* [#3390](https://github.com/rollup/rollup/pull/3390): fix typo: this.addWatchfile (@mistlog)

## 1.31.1
*2020-02-14*

### Bug Fixes
* Make sure errored files are always re-evaluated in watch mode to avoid an issue in the typescript plugin (#3388)

### Pull Requests
* [#3366](https://github.com/rollup/rollup/pull/3366): Correct spelling minifaction to minification (@VictorHom)
* [#3371](https://github.com/rollup/rollup/pull/3371): Adjust bug template to mention REPL.it (@lukastaegert)
* [#3388](https://github.com/rollup/rollup/pull/3388): Run transform hooks again in watch mode on files that errored (@lukastaegert)

## 1.31.0
*2020-01-31*
Expand Down
2 changes: 1 addition & 1 deletion docs/05-plugin-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ Adds additional files to be monitored in watch mode so that changes to these fil

**Note:** Usually in watch mode to improve rebuild speed, the `transform` hook will only be triggered for a given module if its contents actually changed. Using `this.addWatchFile` from within the `transform` hook will make sure the `transform` hook is also reevaluated for this module if the watched file changes.

In general, it is recommended to use `this.addWatchfile` from within the hook that depends on the watched file.
In general, it is recommended to use `this.addWatchFile` from within the hook that depends on the watched file.

#### `this.emitFile(emittedFile: EmittedChunk | EmittedAsset) => string`

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rollup",
"version": "1.31.0",
"version": "1.31.1",
"description": "Next-generation ES module bundler",
"main": "dist/rollup.js",
"module": "dist/rollup.es.js",
Expand Down
3 changes: 3 additions & 0 deletions src/watch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ export class Task {
this.watchFile(id);
}
}
if (error.id) {
this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
}
throw error;
});
}
Expand Down
52 changes: 52 additions & 0 deletions test/watch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,58 @@ describe('rollup.watch', () => {
});
});

it('runs transforms again on previously erroring files that were changed back', () => {
const brokenFiles = new Set();
const INITIAL_CONTENT = 'export default 42;';
sander.writeFileSync('test/_tmp/input/main.js', INITIAL_CONTENT);
const watcher = rollup.watch({
input: 'test/_tmp/input/main.js',
plugins: {
transform(code, id) {
if (code.includes('broken')) {
brokenFiles.add(id);
throw new Error('Broken in transform');
} else {
brokenFiles.delete(id);
}
},
generateBundle() {
if (brokenFiles.size > 0) {
throw new Error('Broken in generate');
}
}
},
output: {
file: 'test/_tmp/output/bundle.js',
format: 'cjs'
},
watch: { chokidar }
});
return sequence(watcher, [
'START',
'BUNDLE_START',
'BUNDLE_END',
'END',
() => {
assert.strictEqual(run('../_tmp/output/bundle.js'), 42);
sander.writeFileSync('test/_tmp/input/main.js', 'export default "broken";');
},
'START',
'BUNDLE_START',
'ERROR',
() => {
sander.writeFileSync('test/_tmp/input/main.js', INITIAL_CONTENT);
},
'START',
'BUNDLE_START',
'BUNDLE_END',
'END',
() => {
assert.strictEqual(run('../_tmp/output/bundle.js'), 42);
}
]);
});

describe('addWatchFile', () => {
it('supports adding additional watch files in plugin hooks', () => {
const watchChangeIds = [];
Expand Down

0 comments on commit 5d690cc

Please sign in to comment.