Skip to content

Commit 931518d

Browse files
committed
Semantic search
1 parent e3d7f25 commit 931518d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4410
-1401
lines changed

esbuild.js

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const esbuild = require("esbuild")
2+
const { copy } = require("esbuild-plugin-copy")
23
const fs = require("fs")
34
const path = require("path")
45

@@ -25,40 +26,14 @@ const esbuildProblemMatcherPlugin = {
2526
},
2627
}
2728

28-
const copyWasmFiles = {
29-
name: "copy-wasm-files",
29+
// Plugin to handle native .node files
30+
const nativeNodeModulesPlugin = {
31+
name: "native-node-modules",
3032
setup(build) {
31-
build.onEnd(() => {
32-
// tree sitter
33-
const sourceDir = path.join(__dirname, "node_modules", "web-tree-sitter")
34-
const targetDir = path.join(__dirname, "dist")
35-
36-
// Copy tree-sitter.wasm
37-
fs.copyFileSync(path.join(sourceDir, "tree-sitter.wasm"), path.join(targetDir, "tree-sitter.wasm"))
38-
39-
// Copy language-specific WASM files
40-
const languageWasmDir = path.join(__dirname, "node_modules", "tree-sitter-wasms", "out")
41-
const languages = [
42-
"typescript",
43-
"tsx",
44-
"python",
45-
"rust",
46-
"javascript",
47-
"go",
48-
"cpp",
49-
"c",
50-
"c_sharp",
51-
"ruby",
52-
"java",
53-
"php",
54-
"swift",
55-
]
56-
57-
languages.forEach((lang) => {
58-
const filename = `tree-sitter-${lang}.wasm`
59-
fs.copyFileSync(path.join(languageWasmDir, filename), path.join(targetDir, filename))
60-
})
61-
})
33+
build.onResolve({ filter: /\.node$/ }, (args) => ({
34+
path: args.path,
35+
external: true, // Already correctly marked as external
36+
}))
6237
},
6338
}
6439

@@ -67,9 +42,27 @@ const extensionConfig = {
6742
minify: production,
6843
sourcemap: !production,
6944
logLevel: "silent",
45+
assetNames: "[name]",
7046
plugins: [
71-
copyWasmFiles,
72-
/* add to the end of plugins array */
47+
copy({
48+
resolveFrom: "cwd",
49+
assets: [
50+
{
51+
from: "./node_modules/tree-sitter-wasms/out/**/*.wasm",
52+
to: "./dist/",
53+
},
54+
{
55+
from: "./node_modules/web-tree-sitter/tree-sitter.wasm",
56+
to: "./dist/",
57+
},
58+
{
59+
from: "./node_modules/@lancedb/**/*.node",
60+
to: "./dist/",
61+
},
62+
],
63+
watch: true,
64+
}),
65+
nativeNodeModulesPlugin,
7366
esbuildProblemMatcherPlugin,
7467
],
7568
entryPoints: ["src/extension.ts"],
@@ -78,6 +71,7 @@ const extensionConfig = {
7871
platform: "node",
7972
outfile: "dist/extension.js",
8073
external: ["vscode"],
74+
loader: { ".node": "file" },
8175
}
8276

8377
async function main() {

jest.config.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@ module.exports = {
77
"^.+\\.tsx?$": [
88
"ts-jest",
99
{
10-
tsconfig: {
11-
module: "CommonJS",
12-
moduleResolution: "node",
13-
esModuleInterop: true,
14-
allowJs: true,
15-
},
16-
diagnostics: false,
17-
isolatedModules: true,
10+
tsconfig: "tsconfig.json",
1811
},
1912
],
2013
},
@@ -30,9 +23,11 @@ module.exports = {
3023
"^strip-ansi$": "<rootDir>/src/__mocks__/strip-ansi.js",
3124
"^default-shell$": "<rootDir>/src/__mocks__/default-shell.js",
3225
"^os-name$": "<rootDir>/src/__mocks__/os-name.js",
26+
"^(\\.{1,2}/.*)\\.js$": "$1",
27+
"^@xenova/transformers$": "<rootDir>/src/services/semantic-search/embeddings/__mocks__/transformers.ts",
3328
},
3429
transformIgnorePatterns: [
35-
"node_modules/(?!(@modelcontextprotocol|delay|p-wait-for|globby|serialize-error|strip-ansi|default-shell|os-name)/)",
30+
"node_modules/(?!(@modelcontextprotocol|delay|p-wait-for|globby|serialize-error|strip-ansi|default-shell|os-name|@xenova/transformers)/)",
3631
],
3732
roots: ["<rootDir>/src", "<rootDir>/webview-ui/src"],
3833
modulePathIgnorePatterns: [".vscode-test"],

0 commit comments

Comments
 (0)