Skip to content

Commit

Permalink
Merge pull request #1536 from rollup/gh-1533
Browse files Browse the repository at this point in the history
pass through all necessary options to bundle.write in rollup.watch
  • Loading branch information
Rich-Harris committed Aug 11, 2017
2 parents 834acb3 + a30f5a5 commit d0392e9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/watch/index.js
Expand Up @@ -159,11 +159,8 @@ class Task {

return Promise.all(
this.targets.map(target => {
return bundle.write({
format: target.format,
dest: target.dest,
moduleName: this.options.moduleName
});
const options = Object.assign({}, this.options, target);
return bundle.write(options);
})
);
})
Expand Down
30 changes: 30 additions & 0 deletions test/watch/index.js
Expand Up @@ -341,5 +341,35 @@ describe('rollup.watch', () => {
]);
});
});

it('respects options.globals', () => {
return sander
.copydir('test/watch/samples/globals')
.to('test/_tmp/input')
.then(() => {
const watcher = rollup.watch({
entry: 'test/_tmp/input/main.js',
dest: 'test/_tmp/output/bundle.js',
format: 'iife',
watch: { chokidar },
external: ['jquery'],
globals: {
jquery: 'jQuery'
}
});

return sequence(watcher, [
'START',
'BUNDLE_START',
'BUNDLE_END',
'END',
() => {
const generated = sander.readFileSync('test/_tmp/output/bundle.js', { encoding: 'utf-8' });
assert.ok(/jQuery/.test(generated));
watcher.close();
}
]);
});
});
}
});
3 changes: 3 additions & 0 deletions test/watch/samples/globals/main.js
@@ -0,0 +1,3 @@
import $ from 'jquery';

$('body').html('<h1>Hello world!</h1>');

0 comments on commit d0392e9

Please sign in to comment.