From e49e7eefe421c8b8d228b6fda238cb3b1efee731 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: Mon, 5 Oct 2020 21:25:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E5=85=A8=E9=9D=A2=E7=9A=84=E6=AD=A3?= =?UTF-8?q?=E5=88=99:=20cjs2esm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 8 +++----- yarn.lock | 10 +++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 437154a..d1040c4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -45,13 +45,11 @@ const config: UserConfig = { { name: '@rollup/plugin-replace-electron-store', transform(code, id) { - // const Store = require('electron-store') - const electronStoreReg = /(const|let|var)[\n\s]+(\w+)[\n\s]*=[\n\s]*require\(["|']electron-store["|']\)/g + // const Store = require('electron-store') -> import Store from 'electron-store' + const electronStoreReg = /(const|let|var)[\n\s]+(\w+)[\n\s]*=[\n\s]*require\(["|'](.+)["|']\)/g const res = code.match(electronStoreReg) - /*@replace = import Store from 'electron-store'*/ - // const replaceStore = /\/\*\s*@replace\s*=\s*([\S\s]+)\s*\*\//g if (res) { - code = code.replace(electronStoreReg, `import $2 from 'electron-store'`) + code = code.replace(electronStoreReg, `import $2 from '$3'`) } return code }, diff --git a/yarn.lock b/yarn.lock index bfe4ea2..2f0400e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3509,10 +3509,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.9.7: - version "3.9.7" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" - integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== +typescript@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5" + integrity sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg== ultron@~1.1.0: version "1.1.1" @@ -3597,7 +3597,7 @@ vary@^1.1.2: resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= -vite@^1.0.0-rc.1: +vite@^1.0.0-rc.4: version "1.0.0-rc.4" resolved "https://registry.yarnpkg.com/vite/-/vite-1.0.0-rc.4.tgz#210106136861b231704e6381ac9eb1bcd655d4f0" integrity sha512-D9gpKKaE2U0YpIxNrSn+nlFPBT0sfg68Y1EReYW8YHMhbNFcxwS7RZIa1W/8Pq6yDfVRAhbOZNijv1mLG5pCEg==