Skip to content

Commit

Permalink
update: demo
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyguo committed Aug 1, 2019
1 parent b187223 commit 7de3da0
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 17 deletions.
6 changes: 3 additions & 3 deletions demo/dist/commons.chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony default export */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _subPageA_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subPageA.js */ \"./src/subPageA.js\");\n\n// import React from \"react\";\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (\"pageA\");\n\n//# sourceURL=webpack:///./src/pageA.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _subPageA_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subPageA.js */ \"./src/subPageA.js\");\n\n\nconsole.log(\"PageA\");\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (\"PageA\");\n\n//# sourceURL=webpack:///./src/pageA.js?");

/***/ }),

Expand All @@ -32,7 +32,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _sub
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _subPageB_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subPageB.js */ \"./src/subPageB.js\");\n\n\nconsole.log(\"At page 'B' :\", _);\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (\"pageB\");\n\n//# sourceURL=webpack:///./src/pageB.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _subPageB_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./subPageB.js */ \"./src/subPageB.js\");\n\n\nconsole.log(\"PageB\");\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (\"PageB\");\n\n//# sourceURL=webpack:///./src/pageB.js?");

/***/ }),

Expand All @@ -44,7 +44,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _sub
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _module_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./module.js */ \"./src/module.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"react\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! jquery */ \"jquery\");\n/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_2__);\n\n\n\n\nconsole.log(\"subPageA\")\nconsole.log(react__WEBPACK_IMPORTED_MODULE_1___default.a)\n/* harmony default export */ __webpack_exports__[\"default\"] = (\"subPageA\");\n\n//# sourceURL=webpack:///./src/subPageA.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _module_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./module.js */ \"./src/module.js\");\n/* harmony import */ var reactComponet__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! reactComponet */ \"reactComponet\");\n/* harmony import */ var reactComponet__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(reactComponet__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! jquery */ \"jquery\");\n/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_2__);\n\n\n\n\nconsole.log(\"subPageA\")\nconsole.log(reactComponet__WEBPACK_IMPORTED_MODULE_1___default.a)\n/* harmony default export */ __webpack_exports__[\"default\"] = (\"subPageA\");\n\n//# sourceURL=webpack:///./src/subPageA.js?");

/***/ }),

Expand Down
9 changes: 9 additions & 0 deletions demo/dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Webpack App</title>
</head>
<body>
<script type="text/javascript" src="commons.chunk.js"></script><script type="text/javascript" src="pageA.bundle.js"></script><script type="text/javascript" src="pageB.bundle.js"></script></body>
</html>
14 changes: 7 additions & 7 deletions demo/dist/pageA.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,27 @@ eval("(function() { module.exports = window[\"jQuery\"]; }());\n\n//# sourceURL=

/***/ }),

/***/ "react":
/*!*************************************!*\
!*** external ["React","subtract"] ***!
\*************************************/
/***/ "reactComponet":
/*!**************************************!*\
!*** external ["React","Component"] ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = React[\"subtract\"];\n\n//# sourceURL=webpack:///external_%5B%22React%22,%22subtract%22%5D?");
eval("module.exports = React[\"Component\"];\n\n//# sourceURL=webpack:///external_%5B%22React%22,%22Component%22%5D?");

/***/ })

/******/ });

};
if (window["jQuery"] && React["subtract"]) {
if (window["jQuery"] && window.React && React["Component"]) {
entryInit();
} else {
var hasInit = false;
var callback = function () {
if(hasInit) return;
if (window["jQuery"] && React["subtract"]) {
if (window["jQuery"] && window.React && React["Component"]) {
hasInit = true;
document.removeEventListener('load', callback, true);
entryInit();
Expand Down
1 change: 1 addition & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.10.1",
"webpack-cli": "^3.1.0"
}
Expand Down
5 changes: 3 additions & 2 deletions demo/src/pageA.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./subPageA.js";
// import React from "react";

export default "pageA";
console.log("PageA");

export default "PageA";
4 changes: 2 additions & 2 deletions demo/src/pageB.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "./subPageB.js";

console.log("At page 'B' :", _);
console.log("PageB");

export default "pageB";
export default "PageB";
4 changes: 2 additions & 2 deletions demo/src/subPageA.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "./module.js";
import React from "react";
import reactComponet from "reactComponet";
import $ from "jquery";

console.log("subPageA")
console.log(React)
console.log(reactComponet)
export default "subPageA";
4 changes: 3 additions & 1 deletion demo/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WaitExternalPlugin = require('..//wait-external-webpack-plugin');

module.exports = {
Expand All @@ -17,7 +18,7 @@ module.exports = {
jquery: 'window jQuery',
},
{
react : ['React', 'subtract']
reactComponet : ['React', 'Component']
}],
optimization: {
splitChunks: {
Expand All @@ -41,5 +42,6 @@ module.exports = {
new WaitExternalPlugin({
test: /\.js$/,
}),
new HtmlWebpackPlugin(),
]
};

0 comments on commit 7de3da0

Please sign in to comment.