This issue applies both to electron-compile and electron-compilers, sorry
Reading through a bunch of code right now to find out if a different $TEMP/compileCache_${hash} will get generated if NODE_ENV changes, and.. it doesn't like it does?
Here's the default cache directory code:
export function calculateDefaultCompileCacheDirectory() {
let tmpDir = process.env.TEMP || process.env.TMPDIR || '/tmp';
let hash = require('crypto').createHash('md5').update(process.execPath).digest('hex');
let cacheDir = path.join(tmpDir, `compileCache_${hash}`);
mkdirp.sync(cacheDir);
d(`Using default cache directory: ${cacheDir}`);
return cacheDir;
}
The problem is:
- One might want to enable code coverage (or other babel plugins) only in testing
- But since all files are cached by their content
- And the files wouldn't change, only the compiler settings would
- Then electron-compile would just happily serve the old cached versions (which may have coverage instrumentation when they shouldn't, and the other way around).
You can probably reproduce the problem easily if you use electron-compile with a .babelrc like:
{
"env": {
"production": {
"presets": ["es2016-node5", "react"],
"sourceMaps": false
},
"development": {
"presets": ["es2016-node5", "react"],
"sourceMaps": "inline"
}
}
}
run it once with NODE_ENV=production, then again with NODE_ENV=development, I'm 80% confident you'd end up not seeing sourceMaps still.
Here's my proposal for electron-compile:
Tangentially, here's what I've got planned for electron-compilers:
Let me know if any of that sounds bad @paulcbetts & others so I can adjust plans accordingly!
This issue applies both to electron-compile and electron-compilers, sorry
Reading through a bunch of code right now to find out if a different
$TEMP/compileCache_${hash}will get generated ifNODE_ENVchanges, and.. it doesn't like it does?Here's the default cache directory code:
The problem is:
You can probably reproduce the problem easily if you use electron-compile with a
.babelrclike:{ "env": { "production": { "presets": ["es2016-node5", "react"], "sourceMaps": false }, "development": { "presets": ["es2016-node5", "react"], "sourceMaps": "inline" } } }run it once with
NODE_ENV=production, then again withNODE_ENV=development, I'm 80% confident you'd end up not seeing sourceMaps still.Here's my proposal for electron-compile:
calculateDefaultCompileCacheDirectoryto feed off ofdigest-for-object)Tangentially, here's what I've got planned for electron-compilers:
coverageoptions (typescript & babel) only apply whenNODE_ENV=testcoverageis a string, andcoverage: truewould always instrument, so that the old behavior is retained?coverageoption use babel-plugin-istanbul (a relatively thin wrapper over new-istanbul's instrumenting lib).__coverage__variable)__coverage__variable, with proper sourceMap support (it's like 8 lines).Let me know if any of that sounds bad @paulcbetts & others so I can adjust plans accordingly!