Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/out
/dist
*.vsix
/node_modules
package-lock.json
/testproj
Expand Down
6 changes: 2 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"preLaunchTask": "compile"
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"preLaunchTask": "build"
}
]
}
30 changes: 21 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,35 @@
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"label": "compile",
"script": "compile",
"label": "build",
"dependsOn": ["compile", "esbuild"],
"dependsOrder": "sequence",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"label": "compile",
"script": "compile",
"presentation": {
"group": "build"
},
"problemMatcher": [
"$tsc"
]
"problemMatcher": ["$tsc"]
},
{
"type": "npm",
"label": "esbuild",
"script": "esbuild",
"presentation": {
"group": "build"
}
},
{
"type": "npm",
"script": "watch",
"problemMatcher": [
"$tsc-watch"
]
"problemMatcher": ["$tsc-watch"]
}
]
}
17 changes: 17 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**
!dist/extension.js
!graphics/**
!language-configuration.json
!LICENSE
!res/**
!snippets/**
!syntaxes/**
!package.json

!node_modules/vscode-languageclient/**
!node_modules/vscode-cpptools/**
!node_modules/which/**
!node_modules/isexe/**
!node_modules/adm-zip/**

**/*.ts
71 changes: 71 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// this is mostly copied from https://code.visualstudio.com/api/working-with-extensions/bundling-extension#using-esbuild
// no, we can't make it a typescript file, because then tsc complains it's not in the rootDir

import { context } from "esbuild";

const production = process.argv.includes("--production");
const watch = process.argv.includes("--watch");

async function main() {
const ctx = await context({
entryPoints: ["src/extension.ts"],
bundle: true,
format: "esm",
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: "node",
outfile: "dist/extension.js",
// basically required as long as we have CJS dependencies
// node supports loading mixed ESM and CJS, applying the ESM import optimizations to the ESM subset.
// We'd lose out on that if we were to bundle everything into CJS
//packages: "external",
external: [
"vscode",
"vscode-languageclient",
"vscode-cpptools",
"which",
"isexe",
"adm-zip",
],
logLevel: "warning",
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin,
],
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

/**
* @type {import('esbuild').Plugin}
*/
const esbuildProblemMatcherPlugin = {
name: "esbuild-problem-matcher",

setup(build) {
build.onStart(() => {
console.log("[watch] build started");
});
build.onEnd((result) => {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
if (location == null) return;
console.error(
` ${location.file}:${location.line}:${location.column}:`,
);
});
console.log("[watch] build finished");
});
},
};

main().catch((e) => {
console.error(e);
process.exit(1);
});
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"onDebugDynamicConfigurations:cppdbg",
"onDebugDynamicConfigurations:lldb"
],
"main": "./out/extension.js",
"main": "./dist/extension.js",
"contributes": {
"commands": [
{
Expand Down Expand Up @@ -575,17 +575,19 @@
},
"scripts": {
"compile": "tsc -p ./",
"esbuild": "node ./esbuild.js",
"markdownlint:check": "npx -y markdownlint-cli2 **.md",
"postinstall": "husky",
"prettier:check": "prettier --check **.md **.ts **.yml **.json",
"vscode:prepublish": "npm run compile",
"vscode:prepublish": "npm run compile && node ./esbuild.js --production",
"watch": "tsc -watch -p ./"
},
"devDependencies": {
"@types/adm-zip": "^0.5.1",
"@types/node": "^22.0.0",
"@types/vscode": "^1.101.0",
"@types/which": "^3.0.0",
"esbuild": "^0.27.0",
"husky": "^9.0.0",
"lint-staged": "^16.0.0",
"prettier": "^3.0.3",
Expand Down
4 changes: 2 additions & 2 deletions src/debug/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as os from "os";
import * as os from "node:os";
import * as vscode from "vscode";
import * as path from "path";
import * as path from "node:path";
import { getMesonTargets } from "../introspection.js";
import { Target } from "../types.js";
import { extensionConfiguration, getTargetName } from "../utils.js";
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from "vscode";
import * as path from "path";
import * as path from "node:path";
import { extensionConfiguration, extensionConfigurationSet } from "./utils.js";
import { SettingsKey } from "./types.js";

Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as os from "os";
import * as os from "node:os";
import * as vscode from "vscode";
import { getMesonTasks, getTasks, runTask, runFirstTask } from "./tasks.js";
import { MesonProjectExplorer } from "./treeview/index.js";
Expand Down
2 changes: 1 addition & 1 deletion src/introspection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import { exec, extensionConfiguration, parseJSONFileIfExists, getOutputChannel } from "./utils.js";
import { Targets, Dependencies, BuildOptions, Tests, ProjectInfo, Compilers } from "./types.js";
import { type VersionArray, Version } from "./version.js";
Expand Down
12 changes: 6 additions & 6 deletions src/lsp/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Admzip from "adm-zip";
import * as which from "which";
import * as https from "https";
import * as crypto from "crypto";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import which from "which";
import * as https from "node:https";
import * as crypto from "node:crypto";
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
import * as vscode from "vscode";
import {
DidChangeConfigurationNotification,
Expand Down
2 changes: 1 addition & 1 deletion src/lsp/mesonlsp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as os from "os";
import * as os from "node:os";
import * as vscode from "vscode";

import { Executable } from "vscode-languageclient/node.js";
Expand Down
2 changes: 1 addition & 1 deletion src/tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as os from "os";
import * as os from "node:os";
import * as vscode from "vscode";
import { ExecResult, exec, extensionConfiguration, getTargetName } from "./utils.js";
import { Target, Targets, Test, Tests, DebugEnvironmentConfiguration } from "./types.js";
Expand Down
2 changes: 1 addition & 1 deletion src/treeview/nodes/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import * as vscode from "vscode";
import { isThenable } from "../../utils.js";
import { BaseNode } from "../basenode.js";
Expand Down
2 changes: 1 addition & 1 deletion src/treeview/nodes/sources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import * as vscode from "vscode";

import { extensionRelative } from "../../utils.js";
Expand Down
2 changes: 1 addition & 1 deletion src/treeview/nodes/targets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import * as vscode from "vscode";

import { BaseNode } from "../basenode.js";
Expand Down
8 changes: 4 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as fs from "fs";
import * as path from "path";
import * as cp from "child_process";
import * as fs from "node:fs";
import * as path from "node:path";
import * as cp from "node:child_process";
import * as vscode from "vscode";
import which from "which";

import { createHash, BinaryLike } from "crypto";
import { createHash, BinaryLike } from "node:crypto";
import {
ExtensionConfiguration,
Target,
Expand Down
Loading
Loading