From 6ce2490010e2c8b57e1e4af845350c4b8b229446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Wed, 26 Aug 2020 18:24:01 +0800 Subject: [PATCH] chore: update --- package.json | 6 +- script/build.js | 2 + script/rollup.config.js | 45 ++++++++++----- yarn.lock | 122 ++++++++++++++++++++++++++++++++++++---- 4 files changed, 146 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index c00b186..2faa5a8 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,12 @@ "ele:dev": "node script/build --env=development --watch" }, "dependencies": { - "vue": "^3.0.0-rc.1" + "vue": "^3.0.0-rc.8" }, "devDependencies": { "@rollup/plugin-commonjs": "^15.0.0", "@rollup/plugin-node-resolve": "^9.0.0", - "@rollup/plugin-typescript": "^5.0.2", - "@vue/compiler-sfc": "^3.0.0-rc.1", + "@vue/compiler-sfc": "^3.0.0-rc.8", "chalk": "^4.1.0", "concurrently": "^5.3.0", "dotenv": "^8.2.0", @@ -29,6 +28,7 @@ "electron-is-dev": "^1.2.0", "minimist": "^1.2.5", "ora": "^5.0.0", + "rollup-plugin-esbuild": "^2.4.2", "typescript": "^3.9.7", "vite": "^1.0.0-rc.1", "wait-on": "^5.2.0" diff --git a/script/build.js b/script/build.js index e54c646..2bbd057 100644 --- a/script/build.js +++ b/script/build.js @@ -35,6 +35,8 @@ if (argv.watch) { if (ev.code === 'END') { // init-未启动、started-第一次启动、restarted-重新启动 electron.electronState === 'init' ? electron.start() : electron.restart(); + } else if (ev.code === 'ERROR') { + console.log(ev.error) } }); }); diff --git a/script/rollup.config.js b/script/rollup.config.js index 1cdbb67..8984925 100644 --- a/script/rollup.config.js +++ b/script/rollup.config.js @@ -1,27 +1,44 @@ -const path = require('path'); -const { nodeResolve } = require('@rollup/plugin-node-resolve'); -const commonjs = require('@rollup/plugin-commonjs'); -const typescript = require('@rollup/plugin-typescript'); +const path = require('path') +const { nodeResolve } = require('@rollup/plugin-node-resolve') +const commonjs = require('@rollup/plugin-commonjs') +const esbuild = require('rollup-plugin-esbuild') module.exports = (env = 'production') => { return { input: path.join(__dirname, '../src/main/index.ts'), output: { - file: path.join(__dirname, '../src/main/_.js'), + file: path.join(__dirname, '../dist/main/_.js'), format: 'cjs', name: 'ElectronMainBundle', sourcemap: true, }, plugins: [ - nodeResolve({ jsnext: true, preferBuiltins: true, browser: true }), // 消除碰到 node.js 模块时⚠警告 + nodeResolve(), commonjs(), - typescript(), - ], - external: [ - 'fs', - 'path', - 'electron', - 'electron-is-dev', + esbuild({ + // All options are optional + include: /\.[jt]sx?$/, // default, inferred from `loaders` option + exclude: /node_modules/, // default + // watch: process.argv.includes('--watch'), // rollup 中有配置 + sourceMap: false, // default + minify: process.env.NODE_ENV === 'production', + target: 'es2017', // default, or 'es20XX', 'esnext' + jsxFactory: 'React.createElement', + jsxFragment: 'React.Fragment', + // Like @rollup/plugin-replace + define: { + __VERSION__: '"x.y.z"' + }, + // Add extra loaders + loaders: { + // Add .json files support + // require @rollup/plugin-commonjs + '.json': 'json', + // Enable JSX in .js files too + '.js': 'jsx' + } + }), ], + external: ['fs', 'path', 'electron', 'electron-is-dev'], } -}; +} diff --git a/yarn.lock b/yarn.lock index c4ee437..340f517 100644 --- a/yarn.lock +++ b/yarn.lock @@ -174,15 +174,7 @@ is-module "^1.0.0" resolve "^1.17.0" -"@rollup/plugin-typescript@^5.0.2": - version "5.0.2" - resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-5.0.2.tgz#e879b73354851868b805bbd43f15c229123b8a71" - integrity sha512-CkS028Itwjqm1uLbFVfpJgtVtnNvZ+og/m6UlNRR5wOOnNTWPcVQzOu5xGdEX+WWJxdvWIqUq2uR/RBt2ZipWg== - dependencies: - "@rollup/pluginutils" "^3.0.1" - resolve "^1.14.1" - -"@rollup/pluginutils@^3.0.1", "@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.0.9", "@rollup/pluginutils@^3.1.0": +"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.0.9", "@rollup/pluginutils@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== @@ -384,6 +376,17 @@ estree-walker "^2.0.1" source-map "^0.6.1" +"@vue/compiler-core@3.0.0-rc.8": + version "3.0.0-rc.8" + resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.0-rc.8.tgz#c8a630b440d03a1790d34b3c5a7b3c86caa8a84e" + integrity sha512-67sHKlKhrBhxF72gJc8PkJeAA1iZ4x1krVDuS2yOvS44Gj+fNHu8Y25mThLu+eq2rXCUrrbbmZge9ND6VuyFUA== + dependencies: + "@babel/parser" "^7.10.4" + "@babel/types" "^7.10.4" + "@vue/shared" "3.0.0-rc.8" + estree-walker "^2.0.1" + source-map "^0.6.1" + "@vue/compiler-dom@3.0.0-rc.5", "@vue/compiler-dom@^3.0.0-rc.5": version "3.0.0-rc.5" resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.0.0-rc.5.tgz#83905e8601123a3654b90fbd80708a16530ce21a" @@ -392,7 +395,15 @@ "@vue/compiler-core" "3.0.0-rc.5" "@vue/shared" "3.0.0-rc.5" -"@vue/compiler-sfc@^3.0.0-rc.1", "@vue/compiler-sfc@^3.0.0-rc.5": +"@vue/compiler-dom@3.0.0-rc.8": + version "3.0.0-rc.8" + resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.0.0-rc.8.tgz#a4fd66356e1dbe7bf3f3e41f6034e682b7c22b3d" + integrity sha512-xnYswIMWTu8ck5ZcyXrZBhB/gBXla5JpfdEkoPqjNNSXZn1w6N398KuB6UQtjSDjjIsZ7shs7/x5hgtnqTNBJQ== + dependencies: + "@vue/compiler-core" "3.0.0-rc.8" + "@vue/shared" "3.0.0-rc.8" + +"@vue/compiler-sfc@^3.0.0-rc.5": version "3.0.0-rc.5" resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.0.0-rc.5.tgz#374e52a6fbf8fb9aee1213026050a0f1c496fecf" integrity sha512-huoIFEfFCJxHcpoByAUQti7CIwJdHPLJXKuy2HG7J1B+IEKugtBdF50CLH35ZD8dWM0nyOMFFqTbO7i6CCjL3Q== @@ -414,6 +425,28 @@ postcss-selector-parser "^6.0.2" source-map "^0.6.1" +"@vue/compiler-sfc@^3.0.0-rc.8": + version "3.0.0-rc.8" + resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.0.0-rc.8.tgz#ca2a90188039def429103732eaefa705743bb406" + integrity sha512-oJXHqMVVXRiI04rV5ncbyv+lwJMSxMFHxZBCt10bUDBBl9E7ze6/01OcSI4/mzB0RRDa1X1byMDMAgLq/07lAw== + dependencies: + "@babel/parser" "^7.10.4" + "@babel/types" "^7.10.4" + "@vue/compiler-core" "3.0.0-rc.8" + "@vue/compiler-dom" "3.0.0-rc.8" + "@vue/compiler-ssr" "3.0.0-rc.8" + "@vue/shared" "3.0.0-rc.8" + consolidate "^0.15.1" + estree-walker "^2.0.1" + hash-sum "^2.0.0" + lru-cache "^5.1.1" + magic-string "^0.25.7" + merge-source-map "^1.1.0" + postcss "^7.0.27" + postcss-modules "^3.1.0" + postcss-selector-parser "^6.0.2" + source-map "^0.6.1" + "@vue/compiler-ssr@3.0.0-rc.5": version "3.0.0-rc.5" resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.0.0-rc.5.tgz#878406c59daff362ecdcb199fb9467a769ca8de5" @@ -422,6 +455,14 @@ "@vue/compiler-dom" "3.0.0-rc.5" "@vue/shared" "3.0.0-rc.5" +"@vue/compiler-ssr@3.0.0-rc.8": + version "3.0.0-rc.8" + resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.0.0-rc.8.tgz#4b6137922ede1c6abca74e15fda8baf7163e14e0" + integrity sha512-0NtZ6e90CpD/MJRDY0AgGNA1t3utjMkg1A/xc2RruUvJgpCsr/9sj6wK0ZoXV/MKKKFzE5DVgPjwVs0o5wxTfg== + dependencies: + "@vue/compiler-dom" "3.0.0-rc.8" + "@vue/shared" "3.0.0-rc.8" + "@vue/reactivity@3.0.0-rc.5": version "3.0.0-rc.5" resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.0-rc.5.tgz#45cff8d839d7ad130b1e499239090050fdecff13" @@ -429,6 +470,13 @@ dependencies: "@vue/shared" "3.0.0-rc.5" +"@vue/reactivity@3.0.0-rc.8": + version "3.0.0-rc.8" + resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.0-rc.8.tgz#329a00e63781663516e5b356ab17e4782bafa7d6" + integrity sha512-/NjP+CI3ggeRXaIlJCI/zJBuClOhwy+SPvt8mcIQEMeewn67bh1Qzl5iqD+yFFzaS3MR3ofdkcCiq1UQ/k2Omg== + dependencies: + "@vue/shared" "3.0.0-rc.8" + "@vue/runtime-core@3.0.0-rc.5": version "3.0.0-rc.5" resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.0.0-rc.5.tgz#dd59af3a5fc089d1cdc05a657320c0dc17e5c362" @@ -437,6 +485,14 @@ "@vue/reactivity" "3.0.0-rc.5" "@vue/shared" "3.0.0-rc.5" +"@vue/runtime-core@3.0.0-rc.8": + version "3.0.0-rc.8" + resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.0.0-rc.8.tgz#3672094478c7dcf84e6906ac6f0c20fe386fcf9c" + integrity sha512-VZpfCqsjz9rixDWCrEB4aI2qjlTslxAlK+5lVK+4jq7Tz2ZLQa93/Zg9p5DRzdI5GCd3nkOxo9hFXkPu+B2pIw== + dependencies: + "@vue/reactivity" "3.0.0-rc.8" + "@vue/shared" "3.0.0-rc.8" + "@vue/runtime-dom@3.0.0-rc.5": version "3.0.0-rc.5" resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.0-rc.5.tgz#2fd75a1f29b23abf0ffe5ccdedabda11721c5b5b" @@ -446,11 +502,25 @@ "@vue/shared" "3.0.0-rc.5" csstype "^2.6.8" +"@vue/runtime-dom@3.0.0-rc.8": + version "3.0.0-rc.8" + resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.0-rc.8.tgz#96bde809e1d49ff0655bc63e7852cdaa25b23a8e" + integrity sha512-Da1wMDU1bh1c5WLSc3E78ns3XphZG4WHl6v0elhFkwpnSF5qB14ZYnuuqXVZ4N8Afe6ZjvtM4GSWOZlD4TkYng== + dependencies: + "@vue/runtime-core" "3.0.0-rc.8" + "@vue/shared" "3.0.0-rc.8" + csstype "^2.6.8" + "@vue/shared@3.0.0-rc.5": version "3.0.0-rc.5" resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.0-rc.5.tgz#cea2378e3e37363ddc1f5dd158edc9c9b5b3fff0" integrity sha512-ZhcgGzBpp+pUzisZgQpM4ctIGgLpYjBj7/rZfbhEPxFHF/BuTV2jmhXvAl8aF9xDAejIcw85xCy92gDSwKtPag== +"@vue/shared@3.0.0-rc.8": + version "3.0.0-rc.8" + resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.0-rc.8.tgz#d6b80e14c202c37d9f1953965a1517eab46c1d3b" + integrity sha512-GSvG6mbDcOQtLKfeNe77ds0oo5PRfTDhsPlqx1fwvpyROS/BAOo1YK17CXwmI+Vsf+51L/l42tTneBTdhQotmg== + accepts@^1.3.5: version "1.3.7" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" @@ -1973,6 +2043,11 @@ joi@^17.1.1: "@hapi/pinpoint" "^2.0.0" "@hapi/topo" "^5.0.0" +joycon@^2.2.5: + version "2.2.5" + resolved "https://registry.yarnpkg.com/joycon/-/joycon-2.2.5.tgz#8d4cf4cbb2544d7b7583c216fcdfec19f6be1615" + integrity sha512-YqvUxoOcVPnCp0VU1/56f+iKSdvIRJYPznH22BdXV3xMk75SFXhWeJkZ8C9XxUWt1b5x2X1SxuFygW1U0FmkEQ== + js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -2831,7 +2906,7 @@ resolve-path@^1.4.0: http-errors "~1.6.2" path-is-absolute "1.0.1" -resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.14.1, resolve@^1.17.0: +resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.17.0: version "1.17.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== @@ -2880,6 +2955,15 @@ rollup-plugin-dynamic-import-variables@^1.0.1: globby "^11.0.0" magic-string "^0.25.7" +rollup-plugin-esbuild@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/rollup-plugin-esbuild/-/rollup-plugin-esbuild-2.4.2.tgz#631f272a06d349b5d7719ed20bae4fedd3ba756f" + integrity sha512-GJOaC2onOPcCN0w7tYv60Thg3ciX40YRubeGyS/DRo862udAiFuQGTIBSyNX20EWyvYLZmZ967ziGdzUJtIaAg== + dependencies: + "@rollup/pluginutils" "^3.1.0" + joycon "^2.2.5" + strip-json-comments "^3.1.1" + rollup-plugin-terser@^5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-5.3.0.tgz#9c0dd33d5771df9630cd027d6a2559187f65885e" @@ -3171,6 +3255,11 @@ strip-final-newline@^2.0.0: resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== +strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" @@ -3463,7 +3552,7 @@ vite@^1.0.0-rc.1: vue "^3.0.0-rc.5" ws "^7.2.3" -vue@^3.0.0-rc.1, vue@^3.0.0-rc.5: +vue@^3.0.0-rc.5: version "3.0.0-rc.5" resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.0-rc.5.tgz#973175d45a892b3bd23ef5de7faa4add9c66275f" integrity sha512-8t8Y4sHMBGD5iLZ7JfBGmKBJlzesPoL+/nW9EV8s+4LwnKC4rGlRp+Lj2rcign4iQaj0GFaL7DrQ8IoOfVX6+w== @@ -3472,6 +3561,15 @@ vue@^3.0.0-rc.1, vue@^3.0.0-rc.5: "@vue/runtime-dom" "3.0.0-rc.5" "@vue/shared" "3.0.0-rc.5" +vue@^3.0.0-rc.8: + version "3.0.0-rc.8" + resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.0-rc.8.tgz#001b9d7a4033d6ff4b601c6457fc080e192fead9" + integrity sha512-2TPckyMoOjEawJBsjb+02GusPBBTwgCqGSjQYsJnToCPDR7PnVCkA4dbGJYlw1w9heXfwgyI+9qmZT0vMVLGmg== + dependencies: + "@vue/compiler-dom" "3.0.0-rc.8" + "@vue/runtime-dom" "3.0.0-rc.8" + "@vue/shared" "3.0.0-rc.8" + wait-on@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/wait-on/-/wait-on-5.2.0.tgz#6711e74422523279714a36d52cf49fb47c9d9597"