Skip to content

Commit f9ed9cb

Browse files
authored
refactor: external TS of worker (#127)
1 parent 4301d86 commit f9ed9cb

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

empty.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

vite.config.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import path from 'node:path'
2-
import { defineConfig, Plugin, UserConfig } from 'vite'
1+
import { Plugin, mergeConfig } from 'vite'
32
import base from './vite.preview.config'
43

54
const genStub: Plugin = {
@@ -14,28 +13,22 @@ const genStub: Plugin = {
1413
},
1514
}
1615

17-
export default defineConfig({
18-
...base,
19-
plugins: [...(base as UserConfig).plugins!, genStub],
16+
export default mergeConfig(base, {
17+
plugins: [genStub],
2018
optimizeDeps: {
2119
// avoid late discovered deps
2220
include: [
2321
'path-browserify',
2422
'onigasm',
2523
'typescript',
24+
'@volar/cdn',
2625
'@vue/language-service',
2726
'monaco-editor-core/esm/vs/editor/editor.worker',
2827
'@volar/monaco/worker',
2928
'vue/server-renderer',
3029
],
3130
},
3231
base: './',
33-
resolve: {
34-
alias: {
35-
typescript: path.resolve(__dirname, './empty.js'),
36-
path: 'path-browserify',
37-
},
38-
},
3932
build: {
4033
target: 'esnext',
4134
minify: false,

vite.preview.config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import path from 'node:path'
21
import { defineConfig } from 'vite'
32
import vue from '@vitejs/plugin-vue'
43
import replace from '@rollup/plugin-replace'
@@ -13,10 +12,14 @@ export default defineConfig({
1312
],
1413
resolve: {
1514
alias: {
16-
typescript: path.resolve(__dirname, './empty.js'),
1715
path: 'path-browserify',
1816
},
1917
},
18+
build: {
19+
commonjsOptions: {
20+
ignore: ['typescript'],
21+
},
22+
},
2023
worker: {
2124
format: 'es',
2225
plugins: [

0 commit comments

Comments
 (0)