1

How to remove 'modules: false' from config, I tried but, looking for a better way to do this. I mean how to better find this module property. thanks

const config = {
        'presets': [
            ['@babel/preset-env', {
                'targets': {
                    'browsers': ['last 1 versions', 'ie >= 11']
                },
                'modules': false,
            }],
            '@babel/react',
            '@babel/stage-1'
        ],
        'plugins': ['react-hot-loader/babel']
    }

    delete config.presets[0][1].modules
3
  • delete ... is actually the way to go. Commented Dec 14, 2017 at 10:49
  • 1
    Why would you expect anything easier? There is no way to automatically guess what you want to delete Commented Dec 14, 2017 at 10:53
  • OK. I just wanted to know if some way exist Commented Dec 14, 2017 at 10:55

2 Answers 2

1

Try packages like omit-deep:

var omitDeep = require('omit-deep');

var obj = {a: 'a', b: 'b', c: {b: 'b', d: {b: 'b', f: 'f'}}};
console.log(omitDeep(obj, ['b']));
//=> {a: 'a', c: {d: {f: 'f'}}} 

var obj = {a: 'a', b: 'b', c: {b: 'b', d: {b: 'b', f: 'f'}}};
console.log(omitDeep(obj, ['b', 'f']));
//=> {a: 'a', c: {d: {}}} 

If you want to code it by yourself remember you need a recursive function.

Sign up to request clarification or add additional context in comments.

Comments

0

Optimization

const nodeEnv = process.env.NODE_ENV || 'development'
let presetEnvConfig, plugins

if (nodeEnv === 'test'){
    presetEnvConfig = {targets: {node: 'current'}}
    plugins = ['istanbul']
} else {
    presetEnvConfig = {
        targets: {
            browsers: ['last 1 versions', 'ie >= 11']
        },
        modules: false
    }
    plugins = ['react-hot-loader/babel']
}

const config = {
    presets: [
        ['@babel/preset-env', presetEnvConfig],
        '@babel/react',
        '@babel/stage-1'
    ],
    plugins,
}

module.exports = config

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.