Skip to content

Commit

Permalink
Fix dotenv package error (#1953)
Browse files Browse the repository at this point in the history
This fixes #1440. Package "dotenv" does something like "process.env.hasOwnProperty( ... )".
Parcel expects a value property lookup on process.env, not a function call. So valueToNode fails if it was called with a function like "hasOwnProperty".
  • Loading branch information
subhero24 authored and DeMoorJasper committed Aug 28, 2018
1 parent 4208bc8 commit 48c0fa3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/core/parcel-bundler/src/visitors/env.js
Expand Up @@ -7,10 +7,13 @@ module.exports = {
if (matchesPattern(node.object, 'process.env')) {
let key = types.toComputedKey(node);
if (types.isStringLiteral(key)) {
let val = types.valueToNode(process.env[key.value]);
morph(node, val);
asset.isAstDirty = true;
asset.cacheData.env[key.value] = process.env[key.value];
let prop = process.env[key.value];
if (typeof prop !== 'function') {
let value = types.valueToNode(prop);
morph(node, value);
asset.isAstDirty = true;
asset.cacheData.env[key.value] = process.env[key.value];
}
}
}
}
Expand Down

0 comments on commit 48c0fa3

Please sign in to comment.