The Wayback Machine - https://web.archive.org/web/20200611083933/https://github.com/cocos-creator/engine/issues/2184
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

The code compiled with Creator has lots of duplicated _createClass declaration #2184

Open
zilongshanren opened this issue Dec 14, 2017 · 0 comments
Assignees

Comments

@zilongshanren
Copy link
Contributor

@zilongshanren zilongshanren commented Dec 14, 2017

If you write a bunch of ES6 classes, creator will bundle your classes with lots of duplicated babel helper functions in front of each compiled class:

var _createClass = (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);
    }
  }
  return function(Constructor, protoProps, staticProps) {
    if (protoProps) defineProperties(Constructor.prototype, protoProps);
    if (staticProps) defineProperties(Constructor, staticProps);
    return Constructor;
  };
})();

More info and possible solutions, refer to :

babel/babel#4709

https://stackoverflow.com/questions/38826550/duplicated-declarations-in-compiled-out-file-using-babel

@zilongshanren zilongshanren changed the title The code compiled has lots of duplicated _createClass declaration The code compiled with Creator has lots of duplicated _createClass declaration Dec 14, 2017
@jareguo jareguo self-assigned this Dec 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.