Skip to content
Permalink
Browse files

fix: use this.emitFile() API from rollup (#666)

  • Loading branch information...
tivac committed Sep 15, 2019
1 parent 0a7996e commit 108a4a18cad323324eff056b7deb51339f746c6a
Showing with 51 additions and 21 deletions.
  1. +27 −9 package-lock.json
  2. +1 −1 package.json
  3. +22 −10 packages/rollup/rollup.js
  4. +1 −1 packages/rollup/test/__snapshots__/splitting.test.js.snap

Some generated files are not rendered by default. Learn more.

@@ -44,7 +44,7 @@
"lerna": "^3.16.4",
"pegjs": "0.10.0",
"read-dir-deep": "^6.0.0",
"rollup": "^1.11.3",
"rollup": "^1.21.3",
"rollup-plugin-hypothetical": "^2.1.0",
"rollup-plugin-svelte": "^5.0.3",
"shelljs": "^0.8.3",
@@ -257,7 +257,11 @@ module.exports = (opts) => {
continue;
}

const id = this.emitAsset(`${name}${ext}`, result.css);
const id = this.emitFile({
type : "asset",
name : `${name}${ext}`,
source : result.css,
});

// Save off the final name of this asset for later use
const dest = this.getAssetFileName(id);
@@ -266,21 +270,21 @@ module.exports = (opts) => {

log("css output", dest);

// Maps can't be written out via the asset APIs becuase they shouldn't ever be hashed.
// They shouldn't be hashed because they simply follow the name of their parent .css asset.
// So add them to the bundle directly.
if(result.map) {
// Make sure to use the rollup name as the base, otherwise it won't
// automatically handle duplicate names correctly
const fileName = dest.replace(ext, `${ext}.map`);

log("map output", fileName);

bundle[fileName] = {
isAsset : true,
source : result.map.toString(),
this.emitFile({
type : "asset",
source : result.map.toString(),

// Use fileName instead of name because this has to follow the parent
// file naming and can't be double-hashed
fileName,
};
});

// Had to re-add the map annotation to the end of the source files
// if the filename had a hash, since we stripped it out up above
@@ -297,7 +301,11 @@ module.exports = (opts) => {

const compositions = await processor.compositions;

this.emitAsset(dest, JSON.stringify(compositions, null, 4));
this.emitFile({
type : "asset",
name : dest,
source : JSON.stringify(compositions, null, 4),
});
}

const meta = {};
@@ -328,7 +336,11 @@ module.exports = (opts) => {

log("metadata output", dest);

this.emitAsset(dest, JSON.stringify(meta, null, 4));
this.emitFile({
type : "asset",
source : JSON.stringify(meta, null, 4),
name : dest,
});
}
},
};
@@ -408,7 +408,7 @@ Object {
color: red;
}
",
"simple.96e4896f.js": "
"simple.336b919d.js": "
var css = {
\\"str\\": \\"\\\\\\"string\\\\\\"\\",
\\"fooga\\": \\"fooga\\"

0 comments on commit 108a4a1

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