猿问

webpack对es6的支持问题

webpack配置函数中没有配置babel-loader来进行es6代码的转换,也没有配置.babelrc,那么在index.js中直接使用import不会报错这是为什么??

webpack.config.js

var path = require('path');module.exports = {    //入口
    entry: {
        main: './src/index.js',
    },
    output: {        //所有产出资源路径
        path: path.join(__dirname, 'dist'),
        filename: 'main.js',
    },
}

index.js

import './a.js';console.log("我是index");


偶然的你
浏览 636回答 1
1回答

浮云间

我想你没有明白babel是干什么的What is Babel?Babel is a JavaScript compilerBabel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments. Here are the main things Babel can do for you:Transform syntaxPolyfill features that are missing in your target environment (through * @babel/polyfill)Source code transformations (codemods)And more! (check out these videos for inspiration)速查各大浏览器最新版本对ES6的支持
随时随地看视频慕课网APP

相关分类

Node.js
我要回答