-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
💻
- Would you like to work on a fix?
How are you using Babel?
@babel/cli
Input code
https://github.com/mozilla/web-ext , tag 7.5.0. Note that this bug can't be reproduced on x86-64 linux.
Configuration file name
.babelrc
Configuration
{
"presets": [
[
"@babel/env",
{
"targets": { "node": "14" },
// Leave import/export statements unchanged in the babel transpiling output.
"modules": false
}
],
"@babel/flow"
],
"plugins": [
[
"transform-inline-environment-variables",
{
"include": ["WEBEXT_BUILD_ENV"]
}
]
],
"env": {
"test": {
"plugins": ["istanbul"]
}
}
}
Current and expected behavior
Current Behavior
The the command npx babel src -d lib exited with code 1 and only one file got transformed. Additionally, the following content was logged to the console:
{ valid: true, value: null }
If we modify node_modules/@babel/cli/lib/babel/util.js to print the result of the call to transformFile:
function _compile() {
_compile = _asyncToGenerator(function* (filename, opts) {
opts = Object.assign({}, opts, {
caller: CALLER
});
const result = yield new Promise((resolve, reject) => {
babel().transformFile(filename, opts, (err, result) => {
+ console.log(`after transformFile, err:`, err, 'result:', result);
if (err) reject(err);else resolve(result);
});
});
...we can see the following output when babel starts transforming the second file:
after transformFile, err: { valid: true, value: null } result: undefined
Expected Behavior
All the files can be transformed successfully.
Environment
System: Arch Linux riscv64(in qemu-user)
System:
OS: Linux 6.2 undefined
Binaries:
Node: 19.8.0 - /usr/sbin/node
npm: 8.19.2 - /usr/sbin/npm
npmPackages:
@babel/cli: 7.20.7 => 7.20.7
@babel/core: 7.20.12 => 7.20.12
@babel/eslint-parser: 7.19.1 => 7.19.1
@babel/preset-env: 7.20.2 => 7.20.2
@babel/preset-flow: 7.18.6 => 7.18.6
@babel/register: 7.18.9 => 7.18.9
@babel/runtime: 7.20.13 => 7.20.13
babel-plugin-istanbul: 6.1.1 => 6.1.1
babel-plugin-transform-inline-environment-variables: 0.4.4 => 0.4.4
eslint: 8.32.0 => 8.32.0
Possible solution
After some debugging, I have found out that this bug comes from @babel/core/lib/config/caching.js.
This bug is a cache related bug and interestingly, if you put a console.log(); statement in the getCachedValue function:
function* getCachedValue(cache, arg, data){
const cachedValue = cache.get(arg);
+ console.log();
if (cachedValue) {
...Then everything works fine!
Additional context
I am packaging web-ext for Arch linux riscv64. Here is the complete build log: https://archriscv.felixc.at/.status/log.htm?url=logs/web-ext/web-ext-7.5.0-1.log