From ad9e8a493700e48cc24e2efb19cc1f839dd2c4a5 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: Tue, 2 Nov 2021 10:19:31 +0800 Subject: [PATCH] chore: UPDATE --- react-ts/src/global.d.ts | 16 ++++++++++++++++ scripts/dev.ts | 2 +- scripts/rollup.config.ts | 12 +++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 react-ts/src/global.d.ts diff --git a/react-ts/src/global.d.ts b/react-ts/src/global.d.ts new file mode 100644 index 0000000..960d048 --- /dev/null +++ b/react-ts/src/global.d.ts @@ -0,0 +1,16 @@ + +export {} + +declare global { + interface Window { + /** Expose some Api through preload script */ + bridge: { + __dirname: string + __filename: string + fs: typeof import('fs') + path: typeof import('path') + ipcRenderer: import('electron').IpcRenderer + removeLoading: () => void + } + } +} diff --git a/scripts/dev.ts b/scripts/dev.ts index 0a2ba81..5386765 100644 --- a/scripts/dev.ts +++ b/scripts/dev.ts @@ -15,7 +15,7 @@ function eventHandle(ev: RollupWatcherEvent) { if (ev.code === 'ERROR') { console.error(TAG, ev.error) } else if (ev.code === 'BUNDLE_START') { - console.log(TAG, `Rebuild start - ${ev.output}`) + console.log(TAG, `Rebuild - ${ev.output}`) } } diff --git a/scripts/rollup.config.ts b/scripts/rollup.config.ts index f5064aa..3e416a6 100644 --- a/scripts/rollup.config.ts +++ b/scripts/rollup.config.ts @@ -2,8 +2,8 @@ import { builtinModules } from 'module' import { RollupOptions } from 'rollup' import commonjs from '@rollup/plugin-commonjs' import { nodeResolve } from '@rollup/plugin-node-resolve' -// import typescript from '@rollup/plugin-typescript' -import swc from 'rollup-plugin-swc' +import typescript from '@rollup/plugin-typescript' +// import swc from 'rollup-plugin-swc' function optionsFactory(options: RollupOptions): RollupOptions { return { @@ -15,9 +15,11 @@ function optionsFactory(options: RollupOptions): RollupOptions { }, plugins: [ commonjs(), - nodeResolve(), - // typescript(), - swc(), + nodeResolve({ + extensions: ['.ts', '.js', 'json'], + }), + typescript(), + // swc(), Error: Cannot find module 'regenerator-runtime' ], external: [ 'electron',