admin管理员组文章数量:1290935
I've noticed that there are virtually no info from babel on incorrect configuration. For example I've created new app with react-native-cli
, installed decorators plugin and filled my babel.config.js
as follows:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: ['@babel/plugin-proposal-decorators', { legacy: true }],
};
And there were the same plain as if no plugin is installed. Correct config would be:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]],
};
Now I'm trying to install jsx-control-statements and have the same silent fail causing
ReferenceError: Can't find variable: Choose
as if no such plugin is installed at all. My babel.config.js
is:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'jsx-control-statements',
['@babel/plugin-proposal-decorators', { legacy: true }],
],
};
So the question is: How do I debug this configuration? How can I get some diagnostic from babel about incorrect configuration/not found packages etc.?
I've noticed that there are virtually no info from babel on incorrect configuration. For example I've created new app with react-native-cli
, installed decorators plugin and filled my babel.config.js
as follows:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: ['@babel/plugin-proposal-decorators', { legacy: true }],
};
And there were the same plain as if no plugin is installed. Correct config would be:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]],
};
Now I'm trying to install jsx-control-statements and have the same silent fail causing
ReferenceError: Can't find variable: Choose
as if no such plugin is installed at all. My babel.config.js
is:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'jsx-control-statements',
['@babel/plugin-proposal-decorators', { legacy: true }],
],
};
So the question is: How do I debug this configuration? How can I get some diagnostic from babel about incorrect configuration/not found packages etc.?
Share Improve this question edited Oct 5, 2023 at 2:18 Dmitry Shvedov 3,2964 gold badges40 silver badges56 bronze badges asked Oct 3, 2019 at 22:41 Ilya DenisovIlya Denisov 8789 silver badges26 bronze badges2 Answers
Reset to default 5For instance if the presets/plugins are missing or missconfigured, you'll get an error when webpack takes over and try to load all the config. But I think your best shot is to use progressPlugin where you could display each step and see for yourself what is happening.
new webpack.ProgressPlugin((percentage, message, ...args) => {
console.log(percentage, message, ...args);
}),
Another approach, would be using debug module, as nearly all other plugins, modules use it.
DEBUG=* webpack [-c webpack.something.js]
Hope it helps
If you use babel.config.js
you could do the following:
module.exports = function(api) {
if (api) {
api.cache(true);
api.debug = process.env.NODE_ENV === 'development' || false;
}
const presets = ['@babel/preset-env'];
const plugins = [
'@babel/plugin-proposal-class-properties',
...
];
return {
presets,
plugins,
};
};
本文标签: javascriptHow to debug babelconfigjsStack Overflow
版权声明:本文标题:javascript - How to debug babel.config.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741502962a2382153.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论