✨ feat(vscode): 代码阅读的解析与模板直译核心
This commit is contained in:
1 parent
af56985d9a
commit
4d34b8c715
24 files changed
+2294
No files matched your search
@@ -1,4 +1,7 @@
|
||||
/* eslint-disable no-console -- 构建脚本,向终端打印进度是它的正当输出 */
|
||||
import { copyFileSync, mkdirSync } from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import * as esbuild from 'esbuild'
|
||||
|
||||
@@ -19,7 +22,26 @@ const options = {
|
||||
logLevel: 'info',
|
||||
}
|
||||
|
||||
// 代码阅读的解析运行时(web-tree-sitter,由 esbuild 打进 index.cjs)和它要加载的 wasm:
|
||||
// 运行时按 __dirname 找 dist/tree-sitter/,语法包只带用到的几种语言
|
||||
const TREE_SITTER_WASM = [
|
||||
'tree-sitter.wasm',
|
||||
'tree-sitter-typescript.wasm',
|
||||
'tree-sitter-tsx.wasm',
|
||||
'tree-sitter-javascript.wasm',
|
||||
'tree-sitter-python.wasm',
|
||||
]
|
||||
|
||||
function copyTreeSitterWasm() {
|
||||
const from = path.dirname(createRequire(import.meta.url).resolve('@vscode/tree-sitter-wasm'))
|
||||
const to = 'dist/tree-sitter'
|
||||
mkdirSync(to, { recursive: true })
|
||||
for (const file of TREE_SITTER_WASM)
|
||||
copyFileSync(path.join(from, file), path.join(to, file))
|
||||
}
|
||||
|
||||
async function main() {
|
||||
copyTreeSitterWasm()
|
||||
if (watch) {
|
||||
const ctx = await esbuild.context(options)
|
||||
await ctx.watch()
|
||||
|
||||
Reference in new issue
Block a user