From 932d0e2af3add79af50e12f8502263db450d7072 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Fri, 27 Nov 2020 19:17:04 +0300 Subject: [PATCH] Setup webpack and babel for webOS 1.2 --- package.json | 5 ++++- src/components/viewContainer.js | 3 ++- webpack.common.js | 4 ++-- yarn.lock | 14 +++++++++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 25ecb72b43..2cfbd724ea 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,10 @@ "@babel/plugin-proposal-class-properties": "^7.10.1", "@babel/plugin-proposal-private-methods": "^7.12.1", "@babel/preset-env": "^7.12.7", + "@uupaa/dynamic-import-polyfill": "^1.0.2", "autoprefixer": "^9.8.6", "babel-loader": "^8.2.2", + "babel-plugin-dynamic-import-polyfill": "^1.0.0", "clean-webpack-plugin": "^3.0.0", "confusing-browser-globals": "^1.0.10", "copy-webpack-plugin": "^6.3.2", @@ -87,7 +89,8 @@ ], "plugins": [ "@babel/plugin-proposal-class-properties", - "@babel/plugin-proposal-private-methods" + "@babel/plugin-proposal-private-methods", + "babel-plugin-dynamic-import-polyfill" ] }, "browserslist": [ diff --git a/src/components/viewContainer.js b/src/components/viewContainer.js index 7bec82ee75..cfff424a13 100644 --- a/src/components/viewContainer.js +++ b/src/components/viewContainer.js @@ -1,3 +1,4 @@ +import { importModule } from '@uupaa/dynamic-import-polyfill'; import './viewManager/viewContainer.css'; import Dashboard from '../scripts/clientUtils'; @@ -17,7 +18,7 @@ import Dashboard from '../scripts/clientUtils'; controllerUrl = Dashboard.getPluginUrl(controllerUrl); const apiUrl = ApiClient.getUrl('/web/' + controllerUrl); - return import(/* webpackIgnore: true */ apiUrl).then((ControllerFactory) => { + return importModule(apiUrl).then((ControllerFactory) => { options.controllerFactory = ControllerFactory; }); } diff --git a/webpack.common.js b/webpack.common.js index 3932854efb..ce3a9d321d 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -24,7 +24,7 @@ const LibarchiveWasm = [ module.exports = { context: path.resolve(__dirname, 'src'), - target: 'web', + target: 'browserslist', resolve: { modules: [ path.resolve(__dirname, 'node_modules') @@ -91,7 +91,7 @@ module.exports = { }, { test: /\.js$/, - exclude: /node_modules[\\/](?!date-fns|epubjs)/, + exclude: /node_modules[\\/](?!@uupaa[\\/]dynamic-import-polyfill|date-fns|epubjs|pdfjs-dist)/, use: [{ loader: 'babel-loader', options: { diff --git a/yarn.lock b/yarn.lock index 3d2895b2b7..fae81a5cd7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -152,7 +152,7 @@ dependencies: "@babel/types" "^7.12.1" -"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.12.1", "@babel/helper-module-imports@^7.12.5": +"@babel/helper-module-imports@7.x", "@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.12.1", "@babel/helper-module-imports@^7.12.5": version "7.12.5" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.12.5.tgz#1bfc0229f794988f76ed0a4d4e90860850b54dfb" integrity sha512-SR713Ogqg6++uexFRORf/+nPXMmWIn80TALu0uaFb+iQIUoR7bOC7zBWyzBs5b3tBBJXuyD0cRu1F15GyzjOWA== @@ -1148,6 +1148,11 @@ "@types/webpack-sources" "*" source-map "^0.6.0" +"@uupaa/dynamic-import-polyfill@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@uupaa/dynamic-import-polyfill/-/dynamic-import-polyfill-1.0.2.tgz#e540cfd8671058fe1e48f816fc8be07e058d5d3a" + integrity sha512-V3vzdXunOKKob1F+2ldv/4iGQoQA/iyqtW8PVlr1v16xCCKL831pGUubT+vs5/9wxTE/zBKEhjIjmmpK6nqw2A== + "@webassemblyjs/ast@1.9.0": version "1.9.0" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964" @@ -1606,6 +1611,13 @@ babel-plugin-dynamic-import-node@^2.3.3: dependencies: object.assign "^4.1.0" +babel-plugin-dynamic-import-polyfill@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-polyfill/-/babel-plugin-dynamic-import-polyfill-1.0.0.tgz#f251f47ae05ab193cb0ffb93cae0cfe0bf2bd122" + integrity sha512-fqdut9hGeaAgdX3sbAY25TkqA7LPmZB+Hf1XI67AppvhUw1cBST58BPwl5kPwDZYIvmqRwnsVKM0lppsQAsxhg== + dependencies: + "@babel/helper-module-imports" "7.x" + babel-plugin-syntax-object-rest-spread@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"