Skip to content

Commit

Permalink
Fix mangle.json name caching (seemed to break in a recent rollup update)
Browse files Browse the repository at this point in the history
  • Loading branch information
developit committed Jul 5, 2018
1 parent 42050bb commit 41e0dc3
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/index.js
Expand Up @@ -288,6 +288,15 @@ function createConfig(options, entry, format, writeMeta) {
const externalTest =
external.length === 0 ? () => false : id => externalPredicate.test(id);

function loadNameCache() {
try {
nameCache = JSON.parse(
fs.readFileSync(resolve(options.cwd, 'mangle.json'), 'utf8'),
);
} catch (e) {}
}
loadNameCache();

let config = {
inputOptions: {
input: exportType ? resolve(__dirname, '../src/lib/__entry__.js') : entry,
Expand Down Expand Up @@ -392,16 +401,7 @@ function createConfig(options, entry, format, writeMeta) {
}),
mangleOptions && {
// before hook
options() {
try {
nameCache = JSON.parse(
fs.readFileSync(
resolve(options.cwd, 'mangle.json'),
'utf8',
),
);
} catch (e) {}
},
options: loadNameCache,
// after hook
onwrite() {
if (writeMeta && nameCache) {
Expand Down

0 comments on commit 41e0dc3

Please sign in to comment.