-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
124 lines (122 loc) · 3.21 KB
/
Copy pathtsdown.config.ts
File metadata and controls
124 lines (122 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { copyFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { defineConfig } from 'tsdown'
const needsStub = [
'src/session/host.ts',
'src/tunnel/index.ts',
'src/ui/tunnels.ts',
'src/sync/ws/host.ts',
]
export default defineConfig([
{
entry: ['src/extension.ts'],
platform: 'node',
format: ['cjs'],
target: 'node22',
sourcemap: true,
external: [
'vscode',
],
define: {
'import.meta.env.TARGET': '"node"',
'__DEV__': 'true',
},
inputOptions: {
resolve: {
alias: {
'vscode-languageserver/browser': 'vscode-languageserver/node',
'vscode-languageclient/browser': 'vscode-languageclient/node',
'node-pty': resolve(import.meta.dirname, './src/terminal/pty/shims/node-pty.ts'),
'@vscode/windows-process-tree': resolve(import.meta.dirname, './src/terminal/pty/shims/windows-process-tree.ts'),
},
},
},
plugins: [
{
name: 'patch-deps-assets',
transform: {
order: 'pre',
filter: {
id: [
'**/node-pty/lib/unixTerminal.js',
'**/node-pty/lib/windowsPtyAgent.js',
'**/node-pty/lib/windowsConoutConnection.js',
],
},
handler(code, id) {
const subpath = id.split('/node_modules/').at(-1)!
console.log('Patching', subpath)
const utils = resolve(import.meta.dirname, './src/terminal/pty/shims/utils.ts')
const patched = `((() => require(${JSON.stringify(utils)}).resolveAsset(${JSON.stringify(dirname(subpath))}))())`
return code.replaceAll('__dirname', patched)
},
},
load: {
order: 'pre',
filter: {
id: [
'**/vscode-languageclient/lib/node/processes.js',
],
},
handler() {
return '"use strict";\nmodule.exports = {};'
},
},
},
],
},
{
entry: {
browser: 'src/extension.ts',
},
platform: 'browser',
format: ['cjs'],
target: 'es2020',
sourcemap: true,
external: [
'vscode',
],
define: {
'import.meta.env.TARGET': '"browser"',
'__DEV__': 'true',
},
inputOptions: {
resolve: {
conditionNames: ['browser', 'module', 'main'],
alias: Object.fromEntries(
needsStub.map(path => [
resolve(import.meta.dirname, path),
resolve(import.meta.dirname, path.replace(/\.ts$/, '.stub.ts')),
]),
),
},
},
},
{
entry: {
webview: 'src/webview/main.tsx',
},
platform: 'browser',
format: ['esm'],
target: 'es2020',
sourcemap: true,
inputOptions: {
transform: {
jsx: {
runtime: 'automatic',
importSource: 'vue',
},
define: {
'import.meta.env.TARGET': '"webview"',
'__VUE_OPTIONS_API__': 'false',
'__VUE_PROD_DEVTOOLS__': 'false',
'__VUE_PROD_HYDRATION_MISMATCH_DETAILS__': 'false',
'__DEV__': 'true',
},
},
},
onSuccess() {
copyFileSync('src/webview/styles.css', 'dist/webview.css')
},
},
])