Skip to content

Commit

Permalink
added fix for typescript asset invalidation (#2485)
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtariq1171 authored and wbinnssmith committed Apr 11, 2019
1 parent 592630d commit fb4422a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
8 changes: 1 addition & 7 deletions packages/core/parcel-bundler/src/assets/JSAsset.js
Expand Up @@ -37,13 +37,7 @@ class JSAsset extends Asset {
}

shouldInvalidate(cacheData) {
for (let key in cacheData.env) {
if (cacheData.env[key] !== process.env[key]) {
return true;
}
}

return false;
return isAccessedVarChanged(cacheData);
}

mightHaveDependencies() {
Expand Down
6 changes: 6 additions & 0 deletions packages/core/parcel-bundler/src/assets/TypeScriptAsset.js
@@ -1,10 +1,16 @@
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
const isAccessedVarChanged = require('../utils/isAccessedVarChanged');

class TypeScriptAsset extends Asset {
constructor(name, options) {
super(name, options);
this.type = 'js';
this.cacheData.env = {};
}

shouldInvalidate(cacheData) {
return isAccessedVarChanged(cacheData);
}

async generate() {
Expand Down
14 changes: 14 additions & 0 deletions packages/core/parcel-bundler/src/utils/isAccessedVarChanged.js
@@ -0,0 +1,14 @@
/*
Checks if any of the used variable from process.env is changed
*/
function isAccessedVarChanged(cacheData) {
for (let key in cacheData.env) {
if (cacheData.env[key] !== process.env[key]) {
return true;
}
}

return false;
}

module.exports = isAccessedVarChanged;

0 comments on commit fb4422a

Please sign in to comment.