feat: support react to mp

This commit is contained in:
dntzhang 2019-08-16 09:26:45 +08:00
parent 0e32ce86c8
commit 41b4d799da
11 changed files with 561 additions and 806 deletions

View File

@ -149,47 +149,48 @@ module.exports = function(window, document) {var navigator = window.navigator;va
/******/
/******/
/******/ // add entry module to deferred list
/******/ deferredModules.push([13,0,3]);
/******/ deferredModules.push([18,0,3]);
/******/ // run deferred modules when ready
/******/ return checkDeferredModules();
/******/ })
/************************************************************************/
/******/ ({
/***/ 11:
/***/ 16:
/***/ (function(module, exports, __webpack_require__) {
// extracted by mini-css-extract-plugin
/***/ }),
/***/ 13:
/***/ 18:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./node_modules/preact/dist/preact.umd.js
var preact_umd = __webpack_require__(0);
// EXTERNAL MODULE: ./node_modules/react/index.js
var react = __webpack_require__(0);
var react_default = /*#__PURE__*/__webpack_require__.n(react);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/objectDestructuringEmpty.js
var objectDestructuringEmpty = __webpack_require__(3);
var objectDestructuringEmpty_default = /*#__PURE__*/__webpack_require__.n(objectDestructuringEmpty);
// EXTERNAL MODULE: ./node_modules/react-dom/index.js
var react_dom = __webpack_require__(3);
var react_dom_default = /*#__PURE__*/__webpack_require__.n(react_dom);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/classCallCheck.js
var classCallCheck = __webpack_require__(4);
var classCallCheck = __webpack_require__(5);
var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/createClass.js
var createClass = __webpack_require__(5);
var createClass = __webpack_require__(6);
var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
var possibleConstructorReturn = __webpack_require__(6);
var possibleConstructorReturn = __webpack_require__(7);
var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/getPrototypeOf.js
var getPrototypeOf = __webpack_require__(7);
var getPrototypeOf = __webpack_require__(8);
var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/assertThisInitialized.js
@ -197,7 +198,7 @@ var assertThisInitialized = __webpack_require__(1);
var assertThisInitialized_default = /*#__PURE__*/__webpack_require__.n(assertThisInitialized);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/inherits.js
var inherits = __webpack_require__(8);
var inherits = __webpack_require__(9);
var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
@ -205,7 +206,7 @@ var defineProperty = __webpack_require__(2);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
// EXTERNAL MODULE: ./src/components/counter/index.css
var counter = __webpack_require__(11);
var counter = __webpack_require__(16);
// CONCATENATED MODULE: ./src/components/counter/index.js
@ -218,11 +219,10 @@ var counter = __webpack_require__(11);
var counter_Counter =
/*#__PURE__*/
function (_Component) {
inherits_default()(Counter, _Component);
function (_React$Component) {
inherits_default()(Counter, _React$Component);
function Counter() {
var _getPrototypeOf2;
@ -268,33 +268,31 @@ function (_Component) {
createClass_default()(Counter, [{
key: "render",
value: function render(_ref, _ref2) {
objectDestructuringEmpty_default()(_ref);
var count = _ref2.count;
return Object(preact_umd["h"])("div", null, Object(preact_umd["h"])("button", {
value: function render() {
return react_default.a.createElement("div", null, react_default.a.createElement("button", {
onClick: this.sub
}, "-"), Object(preact_umd["h"])("span", null, count), Object(preact_umd["h"])("button", {
}, "-"), react_default.a.createElement("span", null, this.state.count), react_default.a.createElement("button", {
onClick: this.add
}, "+"), Object(preact_umd["h"])("div", {
}, "+"), react_default.a.createElement("div", {
onClick: this.clickHandle
}, "\u8DF3\u8F6C"));
}
}]);
return Counter;
}(preact_umd["Component"]);
}(react_default.a.Component);
/* harmony default export */ var components_counter = (counter_Counter);
// CONCATENATED MODULE: ./src/index.js
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return createApp; });
function createApp() {
var container = document.createElement('div');
container.id = 'app';
document.body.appendChild(container);
Object(preact_umd["render"])(Object(preact_umd["h"])(components_counter, null), container);
react_dom_default.a.render(react_default.a.createElement(components_counter, null), container);
}
"undefined" != typeof wx && wx.getSystemInfoSync || createApp();

View File

@ -149,27 +149,30 @@ module.exports = function(window, document) {var navigator = window.navigator;va
/******/
/******/
/******/ // add entry module to deferred list
/******/ deferredModules.push([12,0]);
/******/ deferredModules.push([17,0]);
/******/ // run deferred modules when ready
/******/ return checkDeferredModules();
/******/ })
/************************************************************************/
/******/ ({
/***/ 12:
/***/ 17:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return createApp; });
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(preact__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
function createApp() {
var container = document.createElement('div');
container.id = 'app';
document.body.appendChild(container);
Object(preact__WEBPACK_IMPORTED_MODULE_0__["render"])(Object(preact__WEBPACK_IMPORTED_MODULE_0__["h"])("div", null, "\u6211\u662Flog\u9875\u9762"), container);
react_dom__WEBPACK_IMPORTED_MODULE_1___default.a.render(react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", null, "\u6211\u662Flog\u9875\u9762"), container);
}
"undefined" != typeof wx && wx.getSystemInfoSync || createApp();

View File

@ -35,17 +35,9 @@ function _defineProperty(obj, key, value) {
module.exports = _defineProperty;
/***/ }),
/* 3 */
/***/ (function(module, exports) {
function _objectDestructuringEmpty(obj) {
if (obj == null) throw new TypeError("Cannot destructure undefined");
}
module.exports = _objectDestructuringEmpty;
/***/ }),
/* 4 */
/* 3 */,
/* 4 */,
/* 5 */
/***/ (function(module, exports) {
function _classCallCheck(instance, Constructor) {
@ -57,7 +49,7 @@ function _classCallCheck(instance, Constructor) {
module.exports = _classCallCheck;
/***/ }),
/* 5 */
/* 6 */
/***/ (function(module, exports) {
function _defineProperties(target, props) {
@ -79,10 +71,10 @@ function _createClass(Constructor, protoProps, staticProps) {
module.exports = _createClass;
/***/ }),
/* 6 */
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
var _typeof = __webpack_require__(9);
var _typeof = __webpack_require__(14);
var assertThisInitialized = __webpack_require__(1);
@ -97,7 +89,7 @@ function _possibleConstructorReturn(self, call) {
module.exports = _possibleConstructorReturn;
/***/ }),
/* 7 */
/* 8 */
/***/ (function(module, exports) {
function _getPrototypeOf(o) {
@ -110,10 +102,10 @@ function _getPrototypeOf(o) {
module.exports = _getPrototypeOf;
/***/ }),
/* 8 */
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
var setPrototypeOf = __webpack_require__(10);
var setPrototypeOf = __webpack_require__(15);
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
@ -133,7 +125,11 @@ function _inherits(subClass, superClass) {
module.exports = _inherits;
/***/ }),
/* 9 */
/* 10 */,
/* 11 */,
/* 12 */,
/* 13 */,
/* 14 */
/***/ (function(module, exports) {
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
@ -155,7 +151,7 @@ function _typeof(obj) {
module.exports = _typeof;
/***/ }),
/* 10 */
/* 15 */
/***/ (function(module, exports) {
function _setPrototypeOf(o, p) {

File diff suppressed because it is too large Load Diff

View File

@ -146,10 +146,10 @@ module.exports = {
"presets": [
"@babel/preset-env",
[
"@babel/preset-react",
{
"pragma": "h"
}
"@babel/preset-react"
// {
// "pragma": "h"
// }
]
],
"plugins": [
@ -162,8 +162,8 @@ module.exports = {
],
"@babel/plugin-proposal-function-bind",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-syntax-dynamic-import",
"styled-jsx/babel"
"@babel/plugin-syntax-dynamic-import"
// "styled-jsx/babel"
],
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/

View File

@ -180,10 +180,10 @@ module.exports = {
"presets": [
"@babel/preset-env",
[
"@babel/preset-react",
{
"pragma": "h"
}
"@babel/preset-react"
// {
// "pragma": "h"
// }
]
],
"plugins": [

View File

@ -16,8 +16,8 @@
"fix": "eslint src --fix"
},
"dependencies": {
"preact": "^8.5.1",
"styled-jsx": "^3.2.1"
"react": "^16.9.0",
"react-dom": "^16.9.0"
},
"browserslist": [
"> 1%",
@ -156,7 +156,5 @@
"tabWidth": 2,
"useTabs": false
},
"alias":{
}
"alias": {}
}

View File

@ -81,7 +81,7 @@ module.exports = {
exclude: /node_modules/,
options: {
plugins : [
["transform-react-jsx", { "pragma":"h" }]
["transform-react-jsx"]
]
}
},

View File

@ -1,7 +1,7 @@
import { h, Component } from 'preact'
import React from 'react'
import './index.css'
class Counter extends Component {
class Counter extends React.Component {
state = { count: 1 }
sub = () => {
@ -22,11 +22,11 @@ class Counter extends Component {
}
}
render({ }, { count }) {
render() {
return (
<div>
<button onClick={this.sub}>-</button>
<span>{count}</span>
<span>{this.state.count}</span>
<button onClick={this.add}>+</button>
<div onClick={this.clickHandle}>跳转</div>
</div>

View File

@ -1,4 +1,5 @@
import { render, h } from 'preact'
import React from 'react'
import ReactDOM from 'react-dom'
import Counter from './components/counter'
export default function createApp() {
@ -6,7 +7,7 @@ export default function createApp() {
container.id = 'app'
document.body.appendChild(container)
render(<Counter />, container)
ReactDOM.render(<Counter />, container)
}
"undefined" != typeof wx && wx.getSystemInfoSync || createApp()

View File

@ -1,11 +1,12 @@
import { render, h } from 'preact'
import React from 'react'
import ReactDOM from 'react-dom'
export default function createApp() {
const container = document.createElement('div')
container.id = 'app'
document.body.appendChild(container)
render(<div >我是log页面</div>, container)
ReactDOM.render(<div >我是log页面</div>, container)
}
"undefined" != typeof wx && wx.getSystemInfoSync || createApp()