Skip to content

Commit

Permalink
fix(core): Preserve format extensions against Rollup v2 chicanery
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed May 22, 2020
1 parent 28db191 commit 14efe1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions packages/pectin-core/lib/getOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ const dotProp = require('dot-prop');
module.exports = function getOutput(pkg, cwd) {
const output = [];

// generated chunks as of rollup v0.68.0 need chunkFileNames, not entryFileNames
const chunkFileNames = dotProp.get(pkg, 'rollup.chunkFileNames', '[name]-[hash].[format].js');
const entryFileNames = dotProp.get(pkg, 'rollup.entryFileNames', '[name].[format].js');

output.push({
format: 'cjs',
dir: path.dirname(path.resolve(cwd, pkg.main)),
chunkFileNames,
// generated chunks as of rollup v0.68.0 need chunkFileNames, not entryFileNames
chunkFileNames: dotProp.get(pkg, 'rollup.chunkFileNames', '[name]-[hash].cjs.js'),
// only one entry point, thus no pattern is required
entryFileNames: path.basename(pkg.main),
});
Expand All @@ -24,8 +21,8 @@ module.exports = function getOutput(pkg, cwd) {
output.push({
format: 'esm',
dir: path.dirname(path.resolve(cwd, pkg.module)),
chunkFileNames,
entryFileNames,
chunkFileNames: dotProp.get(pkg, 'rollup.chunkFileNames', '[name]-[hash].esm.js'),
entryFileNames: dotProp.get(pkg, 'rollup.entryFileNames', '[name].esm.js'),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Object {
"input": "<REPO_ROOT>/packages/rollup-config-pectin/src/rollup-config-pectin.js",
"output": Array [
Object {
"chunkFileNames": "[name]-[hash].[format].js",
"chunkFileNames": "[name]-[hash].cjs.js",
"dir": "<REPO_ROOT>/packages/rollup-config-pectin/lib",
"entryFileNames": "rollup-config-pectin.js",
"exports": "auto",
Expand Down

0 comments on commit 14efe1e

Please sign in to comment.