Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options not work, neither targets ie11 in babel.config.js #925

Open
scil opened this issue Jan 5, 2022 · 5 comments
Open

options not work, neither targets ie11 in babel.config.js #925

scil opened this issue Jan 5, 2022 · 5 comments

Comments

@scil
Copy link

scil commented Jan 5, 2022

Webpack Version:
"webpack": "^5.65.0",

Babel Core Version:
"@babel/core": "^7.16.7",

Babel Loader Version:
"babel-loader": "^8.2.3",

Please tell us about your environment:
Windows 10

Current behavior:
not support ie 11, arrow function not converted.

babel config file

const presets = [
  [
    "@babel/preset-env",
    {
        debug: true,
        // "exclude": ["@babel/plugin-transform-regenerator"],
      targets: "ie 11",
      //     {
      //   // edge: "79",
      //   // chrome: "67",
      //   ie: "11",
      // },
      //useBuiltIns: "usage",
      useBuiltIns: "entry",
      corejs: "3.6.4",
    },
  ],
];

module.exports = { 
    presets,
    minified: isProduction,
    sourceMaps: isProduction? false: "inline",
    plugins:[ ],
};

Expected/desired behavior:

support ie 11, convert arrow function like this

export function getObjectDiff(obj1, obj2) {
    const diff = Object.keys(obj1).reduce((result, key) => {
        if (!obj2.hasOwnProperty(key)) {
            result.push(key);
        } else if (_.isEqual(obj1[key], obj2[key])) {
            const resultKeyIndex = result.indexOf(key);
            result.splice(resultKeyIndex, 1);
        }
        return result;
    }, Object.keys(obj2));

    return diff;
}

@scil
Copy link
Author

scil commented Jan 5, 2022

I have found the sollution is to skip automaticly merging babel.config.js .

I merge it mannuly, like this

const configFromBabel = require('./babel.config')
const babelLoaderOptions= {
...configFromBabel,
    only: null, // overwrite configFromBabel from babel.config.js
    babelrc:false,
    configFile:false,
}



            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: babelLoaderOptions, 
                    // options: {
                    //     babelrc:false,
                    //     configFile:false,
                    //     presets: [
                    //         ['@babel/preset-env', { targets: "ie 11" }]
                    //     ]
                    // }
                }
            },



what do u think?

@wang1212
Copy link

wang1212 commented Jan 7, 2022

I have found the sollution is to skip automaticly merging babel.config.js .

I merge it mannuly, like this

const configFromBabel = require('./babel.config')
const babelLoaderOptions= {
...configFromBabel,
    only: null, // overwrite configFromBabel from babel.config.js
    babelrc:false,
    configFile:false,
}



            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: babelLoaderOptions, 
                    // options: {
                    //     babelrc:false,
                    //     configFile:false,
                    //     presets: [
                    //         ['@babel/preset-env', { targets: "ie 11" }]
                    //     ]
                    // }
                }
            },

what do u think?

@scil I have the same problem.

My project root directory has a .babelrc.js configuration file. I adopted your solution. However, I only need to configure babelrc: false additionally, and do not need the configFile and only options.

In addition, I think this is a long-standing problem, you can take a look: #823 .

@scil
Copy link
Author

scil commented Jan 9, 2022

I have found the sollution is to skip automaticly merging babel.config.js .
I merge it mannuly, like this

const configFromBabel = require('./babel.config')
const babelLoaderOptions= {
...configFromBabel,
    only: null, // overwrite configFromBabel from babel.config.js
    babelrc:false,
    configFile:false,
}



            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: babelLoaderOptions, 
                    // options: {
                    //     babelrc:false,
                    //     configFile:false,
                    //     presets: [
                    //         ['@babel/preset-env', { targets: "ie 11" }]
                    //     ]
                    // }
                }
            },

what do u think?

@scil I have the same problem.

My project root directory has a .babelrc.js configuration file. I adopted your solution. However, I only need to configure babelrc: false additionally, and do not need the configFile and only options.

In addition, I think this is a long-standing problem, you can take a look: #823 .

Thank you. I use both of babelrc:false and configFile just for precausion.

I use only because my webpack and babel compile dif files.

@JLHwung
Copy link
Contributor

JLHwung commented Jan 13, 2022

convert arrow function like this

Can you print the effective Babel config applied to this file?

https://babeljs.io/docs/en/configuration#print-effective-configs

@scil
Copy link
Author

scil commented Jan 13, 2022

convert arrow function like this

Can you print the effective Babel config applied to this file?

https://babeljs.io/docs/en/configuration#print-effective-configs

I'd like to , but my env not support command npm start :(

PS>$env:BABEL_SHOW_CONFIG_FOR = ".\src\myComponent.jsx"; npm start
npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\A\node\node-cache\_logs\2022-01-13T16_51_05_329Z-debug-0.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants