@mhy/config
Version:
> This documentation is not complete. It's in progress and it's a BETA version. Use the tool at your own risk.
25 lines (16 loc) • 669 B
JavaScript
;
const path = require('path');
const fs = require('fs');
const babelrc = JSON.parse(fs.readFileSync(path.resolve(__dirname, '.babelrc'), 'utf8'));
babelrc.presets.find(([name]) => name.includes('preset-env'))[1].modules = 'commonjs';
babelrc.plugins.push(require.resolve('babel-plugin-dynamic-import-node'));
const transformer = require('babel-jest').createTransformer(babelrc);
const proc = transformer.process.bind(transformer);
transformer.process = function (...args) {
const [code, path] = args;
if (!path.includes('node_modules') || code.includes('import')) {
return proc(...args);
}
return code;
};
module.exports = transformer;