diff --git a/dist/index.js b/dist/index.js index d70f132..d34d62a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -233,7 +233,7 @@ eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn th /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__webpack_require__(/*! systemjs/dist/s */ \"./node_modules/systemjs/dist/s.js\");\n__webpack_require__(/*! systemjs/dist/extras/amd */ \"./node_modules/systemjs/dist/extras/amd.js\");\n__webpack_require__(/*! systemjs/dist/extras/named-register */ \"./node_modules/systemjs/dist/extras/named-register.js\");\n__webpack_require__(/*! systemjs/dist/extras/named-exports */ \"./node_modules/systemjs/dist/extras/named-exports.js\");\n__webpack_require__(/*! systemjs/dist/extras/transform */ \"./node_modules/systemjs/dist/extras/transform.js\");\nvar history_1 = __webpack_require__(/*! history */ \"./node_modules/history/esm/history.js\");\nvar systemJSImport = function (requestUrl) { return __awaiter(void 0, void 0, void 0, function () {\n var _a, component, mount, unmount;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0: return [4 /*yield*/, System.import(requestUrl)];\n case 1:\n _a = _b.sent(), component = _a.default, mount = _a.mount, unmount = _a.unmount;\n return [2 /*return*/, { component: component, mount: mount, unmount: unmount }];\n }\n });\n}); };\nvar getApp = function (apps, path) {\n var searchKey = path.substr(1);\n return \"./\" + searchKey + \"/\" + apps[searchKey].version + \"/index.js\";\n};\nexports.default = (function (_a) {\n var apps = _a.apps, navigations = _a.navigations, config = _a.config;\n return __awaiter(void 0, void 0, void 0, function () {\n var history, prevPathname, app, _b, component, mount, unmount;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n history = history_1.createBrowserHistory();\n prevPathname = window.location.pathname;\n /* tslint:disable-next-line */\n __webpack_require__.p = \"/static\" + __webpack_require__.p;\n app = getApp(apps, history.location.pathname);\n return [4 /*yield*/, systemJSImport(app)];\n case 1:\n _b = _c.sent(), component = _b.component, mount = _b.mount, unmount = _b.unmount;\n mount(component.default);\n history.listen(function (location) {\n if (location.pathname !== prevPathname) {\n prevPathname = location.pathname;\n unmount();\n }\n });\n return [2 /*return*/];\n }\n });\n });\n});\n\n\n//# sourceURL=webpack://bootstrap/./src/main.ts?"); +eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__webpack_require__(/*! systemjs/dist/s */ \"./node_modules/systemjs/dist/s.js\");\n__webpack_require__(/*! systemjs/dist/extras/amd */ \"./node_modules/systemjs/dist/extras/amd.js\");\n__webpack_require__(/*! systemjs/dist/extras/named-register */ \"./node_modules/systemjs/dist/extras/named-register.js\");\n__webpack_require__(/*! systemjs/dist/extras/named-exports */ \"./node_modules/systemjs/dist/extras/named-exports.js\");\n__webpack_require__(/*! systemjs/dist/extras/transform */ \"./node_modules/systemjs/dist/extras/transform.js\");\nvar history_1 = __webpack_require__(/*! history */ \"./node_modules/history/esm/history.js\");\nvar systemJSImport = function (requestUrl) { return __awaiter(void 0, void 0, void 0, function () {\n var _a, component, mount, unmount;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0: return [4 /*yield*/, System.import(requestUrl)];\n case 1:\n _a = _b.sent(), component = _a.default, mount = _a.mount, unmount = _a.unmount;\n return [2 /*return*/, { component: component, mount: mount, unmount: unmount }];\n }\n });\n}); };\nvar getApp = function (apps, path) {\n var searchKey = path.substr(1);\n return \"./\" + searchKey + \"/\" + apps[searchKey].version + \"/index.js\";\n};\nexports.default = (function (_a) {\n var apps = _a.apps, navigations = _a.navigations, config = _a.config;\n return __awaiter(void 0, void 0, void 0, function () {\n var history, prevPathname, app, _b, component, mount, unmount;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0:\n history = history_1.createBrowserHistory();\n prevPathname = window.location.pathname;\n app = getApp(apps, history.location.pathname);\n return [4 /*yield*/, systemJSImport(app)];\n case 1:\n _b = _c.sent(), component = _b.component, mount = _b.mount, unmount = _b.unmount;\n mount(component.default);\n history.listen(function (location) {\n if (location.pathname !== prevPathname) {\n prevPathname = location.pathname;\n unmount();\n }\n });\n return [2 /*return*/];\n }\n });\n });\n});\n\n\n//# sourceURL=webpack://bootstrap/./src/main.ts?"); /***/ }) diff --git a/src/main.ts b/src/main.ts index c3c9507..95d0fbf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,6 +9,8 @@ declare var System: { import(string): Promise } +declare var __webpack_public_path__: string; + const systemJSImport = async (requestUrl: string) => { const { default: component, mount, unmount } = await System.import( requestUrl @@ -16,7 +18,7 @@ const systemJSImport = async (requestUrl: string) => { return { component, mount, unmount } } -const getApp = (apps, path) => { +const getPublicPath = (apps, path) => { const searchKey = path.substr(1) return `./${searchKey}/${apps[searchKey].version}/index.js` } @@ -26,11 +28,12 @@ export default async ({ apps, navigations, config }) => { const history = createBrowserHistory() let prevPathname = window.location.pathname - - /* tslint:disable-next-line */ - __webpack_public_path__ = `/static${__webpack_public_path__}` - const app = getApp(apps, history.location.pathname) + const publicPath = getPublicPath(apps, history.location.pathname) + + __webpack_public_path__ = `${publicPath}${__webpack_public_path__}` + + const app = `${publicPath}/index.js` const { component, mount, unmount } = await systemJSImport(app);