Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch files onbuild, even if build fails #3081

Merged
merged 20 commits into from Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Module.ts
Expand Up @@ -244,6 +244,7 @@ export default class Module {
error(props: RollupError, pos: number) {
if (pos !== undefined) {
props.pos = pos;
props.graph = this.graph;
lukastaegert marked this conversation as resolved.
Show resolved Hide resolved

let location = locate(this.code, pos, { offsetLine: 1 });
try {
Expand Down
2 changes: 2 additions & 0 deletions src/rollup/types.d.ts
@@ -1,9 +1,11 @@
import * as ESTree from 'estree';
import { EventEmitter } from 'events';
import Graph from '../Graph';

export const VERSION: string;

export interface RollupError extends RollupLogProps {
graph: Graph;
stack?: string;
}

Expand Down
9 changes: 7 additions & 2 deletions src/watch/index.ts
Expand Up @@ -9,6 +9,7 @@ import {
OutputOptions,
RollupBuild,
RollupCache,
RollupError,
RollupWatcher,
WatcherOptions
} from '../rollup/types';
Expand Down Expand Up @@ -100,7 +101,7 @@ export class Watcher {
.catch(error => {
this.running = false;
this.emit('event', {
code: this.succeeded ? 'ERROR' : 'FATAL',
code: 'ERROR',
error
});
})
Expand Down Expand Up @@ -243,9 +244,13 @@ export class Task {
result
});
})
.catch((error: Error) => {
.catch((error: RollupError) => {
if (this.closed) return;

Array.from(error.graph.moduleById.keys()).forEach(id => {
this.watchFile(id);
});

if (this.cache) {
// this is necessary to ensure that any 'renamed' files
// continue to be watched following an error
Expand Down