Skip to content

Commit

Permalink
feat(rollup): rollup@2 compat (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
tivac committed Mar 9, 2020
1 parent 91b6912 commit 361bd4e
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 30 deletions.
35 changes: 28 additions & 7 deletions 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
Expand Up @@ -45,7 +45,7 @@
"p-defer": "^3.0.0",
"pegjs": "0.10.0",
"read-dir-deep": "^7.0.1",
"rollup": "^1.21.3",
"rollup": "^2.0.2",
"rollup-plugin-hypothetical": "^2.1.0",
"rollup-plugin-svelte": "^5.0.3",
"shelljs": "^0.8.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/rollup-rewriter/rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ module.exports = (opts = {}) => {
const graph = new DepGraph({ circular : true });

Object.entries(chunks).forEach(([ entry, chunk ]) => {
const { isAsset, dynamicImports } = chunk;
const { type, dynamicImports } = chunk;

if(isAsset) {
if(type === "asset") {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/rollup/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ module.exports = (opts = {}) => {

// Walk all bundle entries and add them to the dependency graph
Object.entries(bundle).forEach(([ entry, chunk ]) => {
const { isAsset, modules } = chunk;
const { type, modules } = chunk;

/* istanbul ignore if */
if(isAsset) {
if(type === "asset") {
return;
}

Expand Down Expand Up @@ -270,7 +270,7 @@ module.exports = (opts = {}) => {
});

// Save off the final name of this asset for later use
const dest = this.getAssetFileName(id);
const dest = this.getFileName(id);

names.set(node, dest);

Expand Down
2 changes: 1 addition & 1 deletion packages/rollup/test/__snapshots__/rollup.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ exports[`/rollup.js should write out empty CSS files by default 1`] = `""`;
exports[`/rollup.js shouldn't disable sourcemap generation 1`] = `
SourceMap {
"file": "simple.js",
"mappings": ";;;;;AAEA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC",
"mappings": ";;;;;AAEA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC",
"names": Array [],
"sources": Array [
"packages/rollup/test/specimens/simple.js",
Expand Down
14 changes: 6 additions & 8 deletions packages/rollup/test/__snapshots__/watch.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,14 @@ Snapshot Diff:
+ Second value
@@ --- --- @@
.mc204ad279_one {
color: red;
}",
"assets/shared.css": "/* packages/rollup/test/output/watch/code-splitting/shared.css */
Object {
"assets/one.css": "/* packages/rollup/test/output/watch/code-splitting/shared.css */
.mc4002e81f_shared {
- color: blue;
+ color: seafoam;
}",
"assets/two.css": "/* packages/rollup/test/output/watch/code-splitting/two.css */
.mc3861d3af_two {
color: green;
}
/* packages/rollup/test/output/watch/code-splitting/one.css */
.mc204ad279_one {
color: red;
}",
`;
2 changes: 0 additions & 2 deletions packages/rollup/test/watch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ describe("/rollup.js", () => {

// Start watching
watcher = watch({
experimentalCodeSplitting : true,

input : [
require.resolve(prefix("./output/watch/code-splitting/one.js")),
require.resolve(prefix("./output/watch/code-splitting/two.js")),
Expand Down
4 changes: 2 additions & 2 deletions packages/test-utils/expect/toMatchRollupAssetSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ expect.extend({
toMatchRollupAssetSnapshot({ output }) {
const assets = new Map();

output.forEach(({ isAsset, fileName, source }) => {
if(!isAsset) {
output.forEach(({ type, fileName, source }) => {
if(type !== "asset") {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/test-utils/expect/toMatchRollupCodeSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ expect.extend({
toMatchRollupCodeSnapshot({ output }) {
const chunks = new Map();

output.forEach(({ isAsset, name, code }) => {
if(isAsset) {
output.forEach(({ type, name, code }) => {
if(type === "asset") {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/test-utils/expect/toMatchRollupSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ expect.extend({
toMatchRollupSnapshot({ output }, name = "") {
const things = new Map();

output.forEach(({ code, isAsset, fileName, source }) => {
output.forEach(({ code, type, fileName, source }) => {
// Leading newline to make diffs easier to read
things.set(fileName, `\n${isAsset ? source : code}`);
things.set(fileName, `\n${type === "asset" ? source : code}`);
});

const out = Object.create(null);
Expand Down

0 comments on commit 361bd4e

Please sign in to comment.