Skip to content

Commit

Permalink
babel.config - print some env and build info for more insights
Browse files Browse the repository at this point in the history
  • Loading branch information
kidroca committed Nov 3, 2023
1 parent 7f6ef19 commit 9579930
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,19 @@ if (process.env.CAPTURE_METRICS === 'true') {
]);
}

module.exports = ({caller}) => {
module.exports = (api) => {
console.debug('babel.config.js');
console.debug(' - api.version:', api.version);
console.debug(' - api.env:', api.env());
console.debug(' - process.env.NODE_ENV:', process.env.NODE_ENV);
console.debug(' - process.env.BABEL_ENV:', process.env.BABEL_ENV);

// For `react-native` (iOS/Android) caller will be "metro"
// For `webpack` (Web) caller will be "@babel-loader"
// For jest, it will be babel-jest
// For `storybook` there won't be any config at all so we must give default argument of an empty object
const runningIn = caller((args = {}) => args.name);
const runningIn = api.caller((args = {}) => args.name);
console.debug(' - running in: ', runningIn);

return ['metro', 'babel-jest'].includes(runningIn) ? metro : webpack;
};

0 comments on commit 9579930

Please sign in to comment.