Skip to content

Commit

Permalink
refactor: clean up file entry generation
Browse files Browse the repository at this point in the history
  • Loading branch information
tivac committed Jul 19, 2018
1 parent 40af724 commit a769269
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/rollup/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ const emptyMappings = {
mappings : "",
};

const parts = (file) => {
const name = path.basename(file, path.extname(file));
const makeFile = (details) => {
const { entry } = details;
const name = path.basename(entry, path.extname(entry));

return {
base : path.join(path.dirname(file), name),
return Object.assign(details, {
base : path.join(path.dirname(entry), name),
name,
};
});
};

module.exports = function(opts) {
Expand Down Expand Up @@ -166,7 +167,7 @@ module.exports = function(opts) {

// First pass is used to calculate JS usage of CSS dependencies
Object.keys(bundles).forEach((entry) => {
const file = Object.assign(parts(entry), {
const file = makeFile({
entry,
css : [],
});
Expand Down Expand Up @@ -224,7 +225,7 @@ module.exports = function(opts) {

// Common chunk only emitted if necessary
if(common.size) {
files.push(Object.assign(parts(options.common), {
files.push(makeFile({
entry : options.common,
css : [ ...common.keys() ],
}));
Expand Down

0 comments on commit a769269

Please sign in to comment.