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

fix: adding new files w/ rollup shouldn't error #422

Merged
merged 3 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ cache:
directories:
- "$HOME/.npm"

# Set up latest npm & cipm for installs
# Set up npm 5 for installs (npm 6 seems busted atm)
before_install:
- npm config set loglevel warn
- npm install --global npm@latest cipm
- npm install --global npm@5

install:
- cipm
- lerna exec -- cipm
- npm ci
- lerna exec -- npm ci

script:
- npm test -- --coverage --verbose --ci
Expand Down
3 changes: 2 additions & 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 packages/aliases/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 packages/browserify/package-lock.json

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

16 changes: 8 additions & 8 deletions packages/cli/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 packages/core/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 packages/core/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Processor.prototype = {
.filter((file) => this._graph.hasNode(file));

if(!files.length) {
return;
return [];
}

// Remove everything that depends on files to be removed as well
Expand Down
2 changes: 1 addition & 1 deletion packages/glob/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 packages/namer/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 packages/paths/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 packages/postcss/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 packages/rollup/package-lock.json

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

4 changes: 1 addition & 3 deletions packages/rollup/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function(opts) {
},

transform : function(code, id) {
let removed;
let removed = [];

if(!filter(id) || id.slice(slice) !== options.ext) {
return null;
Expand All @@ -54,8 +54,6 @@ module.exports = function(opts) {
// avoid cache staleness issues
if(runs) {
removed = processor.remove(id);
} else {
removed = [];
}

return Promise.all(
Expand Down
9 changes: 9 additions & 0 deletions packages/rollup/test/__snapshots__/rollup.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ console.log(css);
}
`;

exports[`/rollup.js watch should correctly add new css files in watch mode when files change 1`] = `""`;

exports[`/rollup.js watch should correctly add new css files in watch mode when files change 2`] = `
"/* packages/rollup/test/output/one.css */
.mc19ef5610_one {
color: red;
}"
`;

exports[`/rollup.js watch should correctly update files within the dependency graph in watch mode when files change 1`] = `
"/* packages/rollup/test/output/one.css */
.mc19ef5610_one {
Expand Down
57 changes: 57 additions & 0 deletions packages/rollup/test/rollup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,5 +422,62 @@ describe("/rollup.js", () => {
return done();
}));
});

it("should correctly add new css files in watch mode when files change", (done) => {
// Create v1 of the files
fs.writeFileSync(
"./packages/rollup/test/output/one.css",
dedent(`
.one {
color: red;
}
`)
);

fs.writeFileSync(
"./packages/rollup/test/output/watch.js",
dedent(`
console.log("hello");
`)
);

// Start watching (re-requiring rollup because it needs root obj reference)
watcher = watch({
input : require.resolve("./output/watch.js"),
output : {
file : "./packages/rollup/test/output/watch-output.js",
format : "es"
},
plugins : [
plugin({
css : "./packages/rollup/test/output/watch-output.css",
map : false
})
]
});

// Create v2 of the file after a bit
setTimeout(() => fs.writeFileSync(
"./packages/rollup/test/output/watch.js",
dedent(`
import css from "./one.css";

console.log(css);
`)
), 200);

watcher.on("event", watching((builds) => {
if(builds === 1) {
expect(read("watch-output.css")).toMatchSnapshot();

// continue watching
return;
}

expect(read("watch-output.css")).toMatchSnapshot();

return done();
}));
});
});
});
2 changes: 1 addition & 1 deletion packages/svelte/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 packages/test-utils/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 packages/webpack/package-lock.json

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

14 changes: 7 additions & 7 deletions packages/www/package-lock.json

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