Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion extensions/ql-vscode/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export default tseslint.config(
ecmaVersion: 2018,
sourceType: "module",
projectService: {
allowDefaultProject: ['jest.config.js'],
allowDefaultProject: [
"jest.config.js",
"test/babel-import-meta-url.cjs",
],
},
tsconfigRootDir: import.meta.dirname,
},
Expand Down Expand Up @@ -155,6 +158,11 @@ export default tseslint.config(
"react-hooks/exhaustive-deps": "off",
},
},
{
files: ["test/babel-import-meta-url.cjs"],
languageOptions: { sourceType: "commonjs" },
rules: { "import/no-commonjs": "off" },
},
{
files: ["test/vscode-tests/**/*"],
languageOptions: {
Expand Down
3 changes: 3 additions & 0 deletions extensions/ql-vscode/gulpfile.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
watchCheckTypeScript,
cleanOutput,
copyModules,
buildMswRuntime,
} from "./typescript";
import { compileTextMateGrammar } from "./textmate";
import { packageExtension } from "./package";
Expand All @@ -22,6 +23,7 @@ export const buildWithoutPackage = series(
parallel(
compileEsbuild,
copyModules,
buildMswRuntime,
checkTypeScript,
compileTextMateGrammar,
compileViewEsbuild,
Expand All @@ -32,6 +34,7 @@ export const buildWithoutPackage = series(
export const watch = parallel(
// Always build first, so that we don't have to run build manually
compileEsbuild,
buildMswRuntime,
compileViewEsbuild,
watchEsbuild,
watchCheckTypeScript,
Expand Down
2 changes: 2 additions & 0 deletions extensions/ql-vscode/gulpfile.ts/msw-runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { http } from "msw";
export { setupServer } from "msw/node";
36 changes: 36 additions & 0 deletions extensions/ql-vscode/gulpfile.ts/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ export function compileEsbuild() {
loader: {
".node": "copy",
},
plugins: [
{
name: "msw-runtime",
setup(build) {
build.onResolve({ filter: /^msw(\/node)?$/ }, () => ({
path: "./msw-runtime.mjs",
external: true,
}));
},
},
],
}),
dest("out"),
);
Expand All @@ -66,6 +77,23 @@ export function watchEsbuild() {
watch(["src/**/*.ts", "!src/view/**/*.ts"], compileEsbuild);
}

function compileMswRuntime() {
return pipeline(
src("./gulpfile.ts/msw-runtime.ts"),
esbuild({
outfile: "msw-runtime.mjs",
bundle: true,
format: "esm",
platform: "node",
target: "node22",
banner: {
js: 'import { createRequire } from "node:module"; const require = createRequire(import.meta.url);',
},
}),
dest("out"),
);
}

export function checkTypeScript() {
// This doesn't actually output the TypeScript files, it just
// runs the TypeScript compiler and reports any errors.
Expand All @@ -89,6 +117,13 @@ function copyWasmFiles() {
}).pipe(dest("out"));
}

function copyMswWasm() {
// The interceptor resolves this file relative to the ESM bundle's import.meta.url.
return src("node_modules/@mswjs/interceptors/lib/node/llhttp/llhttp.wasm", {
encoding: false,
}).pipe(dest("out/llhttp"));
}

function copyNativeAddonFiles() {
// We need to copy these files manually because we only want to include Windows x64 to limit
// the size of the extension. Windows x64 is the most common platform that requires short path
Expand All @@ -107,3 +142,4 @@ function copyNativeAddonFiles() {
}

export const copyModules = parallel(copyWasmFiles, copyNativeAddonFiles);
export const buildMswRuntime = parallel(compileMswRuntime, copyMswWasm);
Loading
Loading