Code Monkey home page Code Monkey logo

webpack-babel's People

Contributors

jruit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

webpack-babel's Issues

[question]关于useBuiltIns的entry

babel10-9的例子中,我尝试去掉了babel/polyfill,把browserslist换成了一个较低的版本,发现entry的配置下,转出来的b.js和用usage转出来好像是一样的。甚至我改成了false,也还是一样的输出,想问下我是有哪边配置错了吗

//package
{
  "name": "babel10-8",
  "version": "1.0.0",
  "description": "https://www.jiangruitao.com",
  "main": "index.js",
  "scripts": {
    "dev": "babel a.js -o b.js"
  },
  "keywords": [
    "webpack",
    "babel",
    "tutorial"
  ],
  "author": "jruit",
  "license": "ISC",
  "devDependencies": {
    "@babel/cli": "7.13.10",
    "@babel/core": "7.13.10",
    "@babel/preset-env": "7.13.10"
  },
  "browserslist": [
    "chrome 5"
  ],
  "dependencies": {
    "@babel/polyfill": "7.12.1"
  }
}
`

`
// babel.config
module.exports = {
  presets: [["@babel/env", {
    useBuiltIns: false
  }]],
  plugins: []
}
`

`a.js
// import '@babel/polyfill';

var promise = Promise.resolve('ok');
console.log(promise);

class Person {
    sayname() {
      return 'name'
    }
  }
  
  var john = new Person()
  const a = [1,2,3]
  console.log(john, a.flat())
`

`
// 转义出来的b.js
"use strict";

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

// import '@babel/polyfill';
var promise = Promise.resolve('ok');
console.log(promise);

var Person = /*#__PURE__*/function () {
  function Person() {
    _classCallCheck(this, Person);
  }

  _createClass(Person, [{
    key: "sayname",
    value: function sayname() {
      return 'name';
    }
  }]);

  return Person;
}();

var john = new Person();
var a = [1, 2, 3];
console.log(john, a.flat());

`

[示例webpack5-2]示例运行报错

安装示例依赖,运行npx webpack serve 发现无法运行,报错

[webpack-cli] TypeError: cli.isMultipleCompiler is not a function
    at Command.<anonymous> (E:\code\book-learn\webpack-babel-rumenyushlixiangjie\5\webpack5-2\node_modules\@webpack-cli\serve\lib\index.js:146:35)
    at async Promise.all (index 1)
    at async Command.<anonymous> (E:\code\book-learn\webpack-babel-rumenyushlixiangjie\5\webpack5-2\node_modules\webpack-cli\lib\webpack-cli.js:1687:7)

经排查,是webpack-cli 版本过低导致的,需要调整版本:"webpack-cli": "4.10.0"

因为书籍提到过,示例可能会有版本低导致的报错,所以可能这个是作者有预料的问题?不管怎样,看到了就报告一下。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.