Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 0bcb8b8

Browse files
authored
Merge pull request #2 from VerticalOne/add-babel
add babel-plugin-transform-builtin-classes plugin
2 parents ce79705 + 40285cc commit 0bcb8b8

File tree

5 files changed

+78
-11
lines changed

5 files changed

+78
-11
lines changed

.babelrc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
2-
"presets": [
3-
["env", {
4-
"modules": false
2+
"plugins": [
3+
["transform-builtin-classes", {
4+
"globals": ["HTMLElement"],
5+
"logIfPatched": true
56
}]
6-
]
7+
],
8+
"presets": [
9+
["env", { "modules": false }]
10+
],
711
}

dist/vue-wc-wrapper.global.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ function getAttributes (node) {
9898
return res
9999
}
100100

101+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
102+
101103
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; }; }();
102104

103105
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -106,6 +108,30 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
106108

107109
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
108110

111+
var _fixBabelExtend = function (O) {
112+
var gPO = O.getPrototypeOf || function (o) {
113+
return o.__proto__;
114+
},
115+
sPO = O.setPrototypeOf || function (o, p) {
116+
o.__proto__ = p;
117+
return o;
118+
},
119+
construct = (typeof Reflect === 'undefined' ? 'undefined' : _typeof(Reflect)) === 'object' ? Reflect.construct : function (Parent, args, Class) {
120+
var Constructor,
121+
a = [null];
122+
a.push.apply(a, args);
123+
Constructor = Parent.bind.apply(Parent, a);
124+
return sPO(new Constructor(), Class.prototype);
125+
};
126+
127+
return function fixBabelExtend(Class) {
128+
var Parent = gPO(Class);
129+
return sPO(Class, sPO(function Super() {
130+
return construct(Parent, arguments, gPO(this).constructor);
131+
}, Parent));
132+
};
133+
}(Object);
134+
109135
function wrap(Vue, Component) {
110136
var isAsync = typeof Component === 'function' && !Component.cid;
111137
var isInitialized = false;
@@ -176,7 +202,7 @@ function wrap(Vue, Component) {
176202
el._wrapper.props[camelized] = convertAttributeValue(value, key, camelizedPropsMap[camelized]);
177203
}
178204

179-
var CustomElement = function (_HTMLElement) {
205+
var CustomElement = _fixBabelExtend(function (_HTMLElement) {
180206
_inherits(CustomElement, _HTMLElement);
181207

182208
function CustomElement() {
@@ -276,7 +302,7 @@ function wrap(Vue, Component) {
276302
}]);
277303

278304
return CustomElement;
279-
}(HTMLElement);
305+
}(HTMLElement));
280306

281307
if (!isAsync) {
282308
initialize(Component);

dist/vue-wc-wrapper.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ function getAttributes (node) {
9595
return res
9696
}
9797

98+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
99+
98100
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; }; }();
99101

100102
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -103,6 +105,30 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
103105

104106
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
105107

108+
var _fixBabelExtend = function (O) {
109+
var gPO = O.getPrototypeOf || function (o) {
110+
return o.__proto__;
111+
},
112+
sPO = O.setPrototypeOf || function (o, p) {
113+
o.__proto__ = p;
114+
return o;
115+
},
116+
construct = (typeof Reflect === 'undefined' ? 'undefined' : _typeof(Reflect)) === 'object' ? Reflect.construct : function (Parent, args, Class) {
117+
var Constructor,
118+
a = [null];
119+
a.push.apply(a, args);
120+
Constructor = Parent.bind.apply(Parent, a);
121+
return sPO(new Constructor(), Class.prototype);
122+
};
123+
124+
return function fixBabelExtend(Class) {
125+
var Parent = gPO(Class);
126+
return sPO(Class, sPO(function Super() {
127+
return construct(Parent, arguments, gPO(this).constructor);
128+
}, Parent));
129+
};
130+
}(Object);
131+
106132
function wrap(Vue, Component) {
107133
var isAsync = typeof Component === 'function' && !Component.cid;
108134
var isInitialized = false;
@@ -173,7 +199,7 @@ function wrap(Vue, Component) {
173199
el._wrapper.props[camelized] = convertAttributeValue(value, key, camelizedPropsMap[camelized]);
174200
}
175201

176-
var CustomElement = function (_HTMLElement) {
202+
var CustomElement = _fixBabelExtend(function (_HTMLElement) {
177203
_inherits(CustomElement, _HTMLElement);
178204

179205
function CustomElement() {
@@ -273,7 +299,7 @@ function wrap(Vue, Component) {
273299
}]);
274300

275301
return CustomElement;
276-
}(HTMLElement);
302+
}(HTMLElement));
277303

278304
if (!isAsync) {
279305
initialize(Component);

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,8 @@
5555
"eslint --fix",
5656
"git add"
5757
]
58+
},
59+
"dependencies": {
60+
"babel-plugin-transform-builtin-classes": "^0.6.1"
5861
}
5962
}

yarn.lock

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,14 @@ babel-plugin-transform-async-to-generator@^6.22.0:
419419
babel-plugin-syntax-async-functions "^6.8.0"
420420
babel-runtime "^6.22.0"
421421

422+
babel-plugin-transform-builtin-classes@^0.6.1:
423+
version "0.6.1"
424+
resolved "https://registry.yarnpkg.com/babel-plugin-transform-builtin-classes/-/babel-plugin-transform-builtin-classes-0.6.1.tgz#09286f575267f01d09d279a7d8e02d58739f16c2"
425+
dependencies:
426+
babel-plugin-transform-es2015-classes "^6.24.1"
427+
babel-runtime "^6.23.0"
428+
babel-template "^6.25.0"
429+
422430
babel-plugin-transform-es2015-arrow-functions@^6.22.0:
423431
version "6.22.0"
424432
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221"
@@ -441,7 +449,7 @@ babel-plugin-transform-es2015-block-scoping@^6.23.0:
441449
babel-types "^6.26.0"
442450
lodash "^4.17.4"
443451

444-
babel-plugin-transform-es2015-classes@^6.23.0:
452+
babel-plugin-transform-es2015-classes@^6.23.0, babel-plugin-transform-es2015-classes@^6.24.1:
445453
version "6.24.1"
446454
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db"
447455
dependencies:
@@ -662,14 +670,14 @@ babel-register@^6.26.0:
662670
mkdirp "^0.5.1"
663671
source-map-support "^0.4.15"
664672

665-
babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0:
673+
babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0, babel-runtime@^6.26.0:
666674
version "6.26.0"
667675
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
668676
dependencies:
669677
core-js "^2.4.0"
670678
regenerator-runtime "^0.11.0"
671679

672-
babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0:
680+
babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.25.0, babel-template@^6.26.0:
673681
version "6.26.0"
674682
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02"
675683
dependencies:

0 commit comments

Comments
 (0)