Skip to content
Permalink
Browse files

fix(rollup): properly include dependencies (#602)

Instead of injecting `import` statements use `this.addWatchFile(<file>)` like rollup intended. Solves some weird chunking issues I was seeing and is generally **way** more correct across the board.
  • Loading branch information...
tivac committed May 29, 2019
1 parent 692da74 commit c581e3de82ed198bd46f856062a7efa673c8e612
Showing with 12 additions and 11 deletions.
  1. +3 −4 packages/rollup/rollup.js
  2. +9 −7 packages/rollup/test/__snapshots__/watch.test.js.snap
@@ -107,10 +107,9 @@ module.exports = (opts) => {

const exported = output.join(exports);
const relative = path.relative(processor.options.cwd, id);
const dependencies = processor.dependencies(id);

const out = [
// Need to include this, watch mode doesn't catch all changes otherwise ಠ_ಠ
...processor.dependencies(id).map((dep) => `import ${JSON.stringify(dep)};`),
dev ?
dedent(`
const data = ${JSON.stringify(exported)};
@@ -146,7 +145,7 @@ module.exports = (opts) => {
out.push(`export var styles = ${JSON.stringify(details.result.css)};`);
}

processor.dependencies(id).forEach((dep) => this.addWatchFile(dep));
dependencies.forEach((dep) => this.addWatchFile(dep));

return {
code : out.join("\n"),
@@ -190,7 +189,7 @@ module.exports = (opts) => {
if(isAsset) {
return;
}

// Get CSS files being used by this chunk
const css = Object.keys(modules).filter((file) => processor.has(file));

@@ -146,15 +146,17 @@ Snapshot Diff:
- First value
+ Second value

@@ -1,9 +1,9 @@
Object {
"assets/one.css": "/* packages/rollup/test/output/watch/code-splitting/shared.css */
@@ -3,11 +3,11 @@
.mc204ad279_one {
color: red;
}",
"assets/shared.css": "/* packages/rollup/test/output/watch/code-splitting/shared.css */
.mc4002e81f_shared {
- color: blue;
+ color: seafoam;
}
/* packages/rollup/test/output/watch/code-splitting/one.css */
.mc204ad279_one {
color: red;
}",
"assets/two.css": "/* packages/rollup/test/output/watch/code-splitting/two.css */
.mc3861d3af_two {
color: green;
}",
`;

0 comments on commit c581e3d

Please sign in to comment.
You can’t perform that action at this time.