Skip to content

Commit 7672665

Browse files
feat: add verification script for production bundle and update build process to include new dependencies
1 parent e49c3ce commit 7672665

4 files changed

Lines changed: 86 additions & 2 deletions

File tree

‎.vscodeignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ node_modules/**
1616
!node_modules/@alexaltea/capstone-js/package.json
1717
!node_modules/@alexaltea/capstone-js/dist/capstone.js
1818
!node_modules/@alexaltea/capstone-js/dist/capstone.wasm
19+
!node_modules/@blu3r4y/lzma/package.json
20+
!node_modules/@blu3r4y/lzma/index.js
21+
!node_modules/@blu3r4y/lzma/src/lzma_worker.js
1922
!node_modules/jq-web/package.json
2023
!node_modules/jq-web/jq.js
2124
!node_modules/jq-web/jq.wasm
25+
!node_modules/node-md6/package.json
26+
!node_modules/node-md6/md6.js
2227

2328
# TypeScript config
2429
tsconfig*.json

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Fixed MD6 and LM hashing, OpenPGP imports and keyring ordering, asynchronous jq execution, user-agent parsing, image decoding, and cross-realm ArrayBuffer/Promise handling in pipelines.
2222
- Replaced the x86 disassembly placeholder with the Capstone backend and packaged the required Capstone, jq, and Bzip2 WebAssembly runtime files.
2323
- Ensure OCR workers are terminated on success and failure, and reject unsupported OCR engine modes before worker creation.
24+
- Prevent extension activation from failing on bundled dependencies that resolve runtime worker files or require non-strict CommonJS execution.
2425

2526
## [0.8.0] - 2026-07-17
2627

‎package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,9 @@
457457
},
458458
"scripts": {
459459
"vscode:prepublish": "npm run build",
460-
"compile": "esbuild src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --external:libbzip2-wasm --external:@alexaltea/capstone-js --external:jq-web --platform=node --format=cjs --sourcemap",
461-
"build": "npm run compile",
460+
"compile": "esbuild src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --external:libbzip2-wasm --external:@alexaltea/capstone-js --external:@blu3r4y/lzma --external:jq-web --external:node-md6 --platform=node --format=cjs --sourcemap --define:require.resolve=false",
461+
"verify:bundle": "node scripts/verify-bundle.cjs",
462+
"build": "npm run compile && npm run verify:bundle",
462463
"watch": "npm run compile -- --watch",
463464
"test": "jest",
464465
"test:watch": "jest --watch",

‎scripts/verify-bundle.cjs‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Loads the production bundle with a permissive VS Code API stand-in.
3+
* This catches top-level module resolution failures before a VSIX is built.
4+
*/
5+
6+
"use strict";
7+
8+
const Module = require("module");
9+
const path = require("path");
10+
11+
let vscodeValue;
12+
vscodeValue = new Proxy(function vscodeApiValue() {
13+
return vscodeValue;
14+
}, {
15+
get(_target, property) {
16+
if (property === Symbol.toPrimitive) return () => 0;
17+
if (property === "then") return undefined;
18+
return vscodeValue;
19+
},
20+
construct() {
21+
return vscodeValue;
22+
},
23+
apply() {
24+
return vscodeValue;
25+
},
26+
});
27+
28+
const vscodeNames = [
29+
"window",
30+
"workspace",
31+
"commands",
32+
"languages",
33+
"env",
34+
"Uri",
35+
"Position",
36+
"Range",
37+
"Selection",
38+
"MarkdownString",
39+
"Hover",
40+
"CodeLens",
41+
"EventEmitter",
42+
"TreeItem",
43+
"ThemeIcon",
44+
"ThemeColor",
45+
"ViewColumn",
46+
"TreeItemCollapsibleState",
47+
"OverviewRulerLane",
48+
"ConfigurationTarget",
49+
"StatusBarAlignment",
50+
"ProgressLocation",
51+
"TextEditorRevealType",
52+
"ExtensionMode",
53+
];
54+
const vscode = Object.fromEntries(
55+
vscodeNames.map((name) => [name, vscodeValue]),
56+
);
57+
58+
const projectRoot = path.resolve(__dirname, "..");
59+
const bundlePath = process.argv[2]
60+
? path.resolve(process.argv[2])
61+
: path.join(projectRoot, "dist", "extension.js");
62+
const originalLoad = Module._load;
63+
64+
try {
65+
Module._load = function loadWithVscodeMock(request) {
66+
if (request === "vscode") return vscode;
67+
return originalLoad.apply(this, arguments);
68+
};
69+
const extension = require(bundlePath);
70+
if (typeof extension.activate !== "function") {
71+
throw new Error("Production bundle does not export activate().");
72+
}
73+
} finally {
74+
Module._load = originalLoad;
75+
}
76+
77+
console.log("Production bundle activation import verified.");

0 commit comments

Comments
 (0)