diff --git a/.vscodeignore b/.vscodeignore index 7451f6ac..b4ae792f 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -8,7 +8,8 @@ package-lock.json .pipelines/ .config/ img/ -node_modules/ +# VSCE includes npm production dependencies; bundled libraries are devDependencies. +node_modules/@vscode/codicons/ !node_modules/@vscode/codicons/dist/codicon.css !node_modules/@vscode/codicons/dist/codicon.ttf out/edge/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d7b347a3..a1647b3d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,6 +35,14 @@ Here are a list of recommended VS Code extensions to use when developing for vsc * Select `Launch Tests` debug configuration * Press `F5` to attach the debugger and start the tests +## Packaging dependencies + +Libraries bundled by webpack belong in `devDependencies`: their code ships in the generated bundles, +so their package directories do not need to be included in the VSIX. Keep packages in `dependencies` +only when their files are needed at runtime. VSCE automatically includes their production dependency +trees. This preserves the external `vscode-chrome-debug-core` modules and localization resources; +`.vscodeignore` limits `@vscode/codicons` to the CSS and font used by the webviews. + ## Issue tags * "Bug": Something that should work is broken * "Enhancement": AKA feature request - adds new functionality diff --git a/package-lock.json b/package-lock.json index b52a99ba..ce5ed4cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,14 +10,7 @@ "license": "SEE LICENSE IN LICENSE", "dependencies": { "@vscode/codicons": "0.0.45", - "@vscode/extension-telemetry": "1.5.2", - "bufferutil": "4.1.0", - "lit-html": "^3.3.3", - "puppeteer-core": "25.16.0", - "utf-8-validate": "6.0.6", - "vscode-chrome-debug-core": "6.8.11", - "ws": "8.22.0", - "xmlhttprequest": "1.8.0" + "vscode-chrome-debug-core": "6.8.11" }, "devDependencies": { "@opentelemetry/tracing": "0.24.0", @@ -28,7 +21,9 @@ "@types/ws": "8.18.2", "@typescript-eslint/eslint-plugin": "8.72.0", "@typescript-eslint/parser": "8.72.0", + "@vscode/extension-telemetry": "1.5.2", "@vscode/vsce": "^3.9.2", + "bufferutil": "4.1.0", "copy-webpack-plugin": "14.0.0", "eslint": "9.39.5", "eslint-plugin-import": "2.32.0", @@ -37,13 +32,18 @@ "fs-extra": "11.4.1", "jest": "30.5.2", "jest-environment-jsdom": "^30.5.2", + "lit-html": "^3.3.3", + "puppeteer-core": "25.16.0", "ts-jest": "29.4.15", "ts-loader": "9.6.2", "typescript": "6.0.3", "uglify-js": "3.19.3", "unzipper": "0.12.5", + "utf-8-validate": "6.0.6", "webpack": "5.112.2", - "webpack-cli": "7.2.3" + "webpack-cli": "7.2.3", + "ws": "8.22.0", + "xmlhttprequest": "1.8.0" }, "engines": { "vscode": "^1.136.0" @@ -2201,6 +2201,7 @@ "version": "4.4.4", "resolved": "https://registry.npmjs.org/@microsoft/1ds-core-js/-/1ds-core-js-4.4.4.tgz", "integrity": "sha1-xUJD3qPmdbAoQZbeQE54ZxTMT/g=", + "dev": true, "license": "MIT", "dependencies": { "@microsoft/applicationinsights-core-js": "3.4.4", @@ -2214,6 +2215,7 @@ "version": "4.4.4", "resolved": "https://registry.npmjs.org/@microsoft/1ds-post-js/-/1ds-post-js-4.4.4.tgz", "integrity": "sha1-WaFHAkhS9nNdZ7+1/OM4Cd9a7x0=", + "dev": true, "license": "MIT", "dependencies": { "@microsoft/applicationinsights-core-js": "3.4.4", @@ -2227,6 +2229,7 @@ "version": "3.4.4", "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-3.4.4.tgz", "integrity": "sha1-Ls+QmUHA4yVD3S3OAE3+LfYqNeU=", + "dev": true, "license": "MIT", "dependencies": { "@microsoft/applicationinsights-core-js": "3.4.4", @@ -2243,6 +2246,7 @@ "version": "3.4.4", "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-common/-/applicationinsights-common-3.4.4.tgz", "integrity": "sha1-zy7uCxCK/bu8Ak3K2O7Y2wREXhA=", + "dev": true, "license": "MIT", "dependencies": { "@microsoft/applicationinsights-core-js": "3.4.4", @@ -2258,6 +2262,7 @@ "version": "3.4.4", "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-3.4.4.tgz", "integrity": "sha1-8yehNw34Vcl88sWOJj4djZxJ5Mg=", + "dev": true, "license": "MIT", "dependencies": { "@microsoft/applicationinsights-shims": "3.0.1", @@ -2273,6 +2278,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-shims/-/applicationinsights-shims-3.0.1.tgz", "integrity": "sha1-OGW3Os6EBbnEYYzFxXHy/jh28G8=", + "dev": true, "license": "MIT", "dependencies": { "@nevware21/ts-utils": ">= 0.9.4 < 2.x" @@ -2282,6 +2288,7 @@ "version": "3.4.4", "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-web-basic/-/applicationinsights-web-basic-3.4.4.tgz", "integrity": "sha1-qwgTikWVAaf/F+0ybS0MdPKAzHc=", + "dev": true, "license": "MIT", "dependencies": { "@microsoft/applicationinsights-channel-js": "3.4.4", @@ -2299,6 +2306,7 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/@microsoft/dynamicproto-js/-/dynamicproto-js-2.0.5.tgz", "integrity": "sha1-9NCLCwbFcNaerXzSq69BQCUITGc=", + "dev": true, "license": "MIT", "dependencies": { "@nevware21/ts-utils": ">= 0.14.0 < 2.x" @@ -2330,6 +2338,7 @@ "version": "0.5.5", "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.5.5.tgz", "integrity": "sha1-UJZI48PDqpq2E8AMce7k/pvYo8M=", + "dev": true, "license": "MIT", "dependencies": { "@nevware21/ts-utils": ">= 0.12.2 < 2.x" @@ -2339,6 +2348,7 @@ "version": "0.16.0", "resolved": "https://registry.npmjs.org/@nevware21/ts-utils/-/ts-utils-0.16.0.tgz", "integrity": "sha1-5KOcjrEi54ESMVx5oAkWI4t/PEw=", + "dev": true, "funding": [ { "type": "github", @@ -2797,6 +2807,7 @@ "version": "3.2.6", "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.2.6.tgz", "integrity": "sha512-MJP29gVoHznmqmwhH1tlZqzfeQ3aylTpSSa6WKZXtkwYUH02i9imBmWGTyZrbnAou5paX78SE4jMAUqnEPf8ug==", + "dev": true, "license": "Apache-2.0", "dependencies": { "modern-tar": "^0.8.6", @@ -2825,6 +2836,7 @@ "version": "6.4.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -2837,6 +2849,7 @@ "version": "6.2.3", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", "integrity": "sha1-wETV3MUhoHZBNHJZehrLHxA8QEE=", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -2849,6 +2862,7 @@ "version": "9.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", "integrity": "sha1-b3iQ84b28feZU63B943sRvzC0pE=", + "dev": true, "license": "ISC", "dependencies": { "string-width": "^7.2.0", @@ -2863,6 +2877,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha1-tbuOIWXOJ11NQ0dt0nAK2Qkdttw=", + "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^10.3.0", @@ -2880,12 +2895,14 @@ "version": "10.6.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", "integrity": "sha1-vz1uj3+P0ipl2XA0dbwBRzV6aw0=", + "dev": true, "license": "MIT" }, "node_modules/@puppeteer/browsers/node_modules/string-width": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", + "dev": true, "license": "MIT", "dependencies": { "get-east-asian-width": "^1.5.0", @@ -2902,6 +2919,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", "integrity": "sha1-0iomlSKDamJ6+NBLXD/Sx/o+MuM=", + "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^6.2.2" @@ -2917,6 +2935,7 @@ "version": "9.0.2", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", "integrity": "sha1-lWgy3qlJQwbm0gnrhxZDu4c9fJg=", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^6.2.1", @@ -2934,6 +2953,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha1-tbuOIWXOJ11NQ0dt0nAK2Qkdttw=", + "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^10.3.0", @@ -2951,6 +2971,7 @@ "version": "18.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", + "dev": true, "license": "MIT", "dependencies": { "cliui": "^9.0.1", @@ -2968,6 +2989,7 @@ "version": "22.0.0", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", "integrity": "sha1-h7gglAUbBWdxc0bs0A/RSASzV8g=", + "dev": true, "license": "ISC", "engines": { "node": "^20.19.0 || ^22.12.0 || >=23" @@ -3559,7 +3581,8 @@ "node_modules/@types/trusted-types": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", - "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "dev": true }, "node_modules/@types/vscode": { "version": "1.136.0", @@ -4245,6 +4268,7 @@ "version": "1.5.2", "resolved": "https://registry.npmjs.org/@vscode/extension-telemetry/-/extension-telemetry-1.5.2.tgz", "integrity": "sha1-KsL23kVWWOJgGA/l6r9zvNbaUUY=", + "dev": true, "license": "MIT", "dependencies": { "@microsoft/1ds-core-js": "^4.4.1", @@ -5425,6 +5449,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.1.0.tgz", "integrity": "sha1-pGI1Qd0jhnYmuwigUewNLsC3ApQ=", + "dev": true, "hasInstallScript": true, "license": "MIT", "peer": true, @@ -5627,6 +5652,7 @@ "version": "157.0.8090-0", "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-157.0.8090-0.tgz", "integrity": "sha512-KJw7IQgqXwxpJgJlEIPg5mr2ZoqA+jkTRtc5EABI7sUJ3bu3cpI7NuEBoj4Gn1AsF78CaT9So5WQWspK3/wYag==", + "dev": true, "license": "Apache-2.0", "dependencies": { "mitt": "^3.0.1", @@ -6138,6 +6164,7 @@ "version": "0.0.1704951", "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1704951.tgz", "integrity": "sha512-GQhQOs9u/Mvm1zMtJIH872JS4AskuZdUSsPNPk4ChahtWAUqgz6atEtIsMt+nO7MqF1Ic4HxII/k8Cu36JivNg==", + "dev": true, "license": "BSD-3-Clause", "peer": true }, @@ -6560,6 +6587,7 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, "engines": { "node": ">=6" } @@ -7376,6 +7404,7 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha1-T5RBKoLbMvNuOwuXQfipf+sDH34=", + "dev": true, "license": "ISC", "engines": { "node": "6.* || 8.* || >= 10.*" @@ -7385,6 +7414,7 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -10364,6 +10394,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-3.3.3.tgz", "integrity": "sha1-pj/QL7jBx7cFfugFq2xhL96+8LE=", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "@types/trusted-types": "^2.0.2" @@ -10761,6 +10792,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", "integrity": "sha1-6jbPDMMEA2Aa4HTI93twks2rNtE=", + "dev": true, "license": "MIT" }, "node_modules/mkdirp": { @@ -10785,6 +10817,7 @@ "version": "0.8.6", "resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.8.6.tgz", "integrity": "sha512-LYSks0tNVqbtez/9OB0YFP6qLRSqkdAxJWOQpVaR67lNTbj2zNLyYpowkRMia5lXLCZKzxwoxkxH2MbbBR2aEg==", + "dev": true, "license": "MIT", "engines": { "node": ">=18.0.0" @@ -10862,6 +10895,7 @@ "version": "4.8.2", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.2.tgz", "integrity": "sha512-IRUxE4BVsHWXkV/SFOut4qTlagw2aM8T5/vnTsmrHJvVoKueJHRc/JaFND7QDDc61kLYUJ6qlZM3sqTSyx2dTw==", + "dev": true, "bin": { "node-gyp-build": "bin.js", "node-gyp-build-optional": "optional.js", @@ -11427,7 +11461,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/picocolors": { @@ -11636,6 +11670,7 @@ "version": "25.16.0", "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-25.16.0.tgz", "integrity": "sha512-VA5Pf54N8shfopNkZZXCdiiwfnnY8ZJYAMqFQRhlH5mGUhfwf53Ar770GPtdpTDLUqvQeYpIBtC9/G2Jij2IJw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@puppeteer/browsers": "3.2.6", @@ -13485,6 +13520,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "dev": true, "peer": true }, "node_modules/tunnel": { @@ -13626,6 +13662,7 @@ "version": "2.12.3", "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.3.tgz", "integrity": "sha512-/dtuMZyutHLlrxWhhC1uib00ELUr2dZ8C9B8YzZYsJmeE3V56OxRblrSM2UaF142pcMtak7ehZ6+poWGeehNIg==", + "dev": true, "license": "MIT" }, "node_modules/typed-rest-client": { @@ -13856,6 +13893,7 @@ "version": "6.0.6", "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-6.0.6.tgz", "integrity": "sha1-ioQsmxWvP2Mjo9XtXrnmHSCNjCI=", + "dev": true, "hasInstallScript": true, "license": "MIT", "peer": true, @@ -14010,6 +14048,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-1.0.1.tgz", "integrity": "sha512-WXWs/aXF2a6Al1Z2/V/7Gp2oPZOAAmHjJOTmv4KCXRJ122IMj3tSSMc6a4q3K4QOmhQbse/Ahr+oTVJOU2dUiw==", + "dev": true, "license": "Apache-2.0" }, "node_modules/webidl-conversions": { @@ -14468,6 +14507,7 @@ "version": "8.22.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", + "dev": true, "license": "MIT", "engines": { "node": ">=10.0.0" @@ -14544,6 +14584,7 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", "integrity": "sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA==", + "dev": true, "engines": { "node": ">=0.4.0" } @@ -14552,6 +14593,7 @@ "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha1-f0k00PfKjFb5UxSTndzS3ZHOHVU=", + "dev": true, "license": "ISC", "engines": { "node": ">=10" @@ -14595,9 +14637,8 @@ "version": "3.4.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-3.4.0.tgz", "integrity": "sha1-iLKiFFXzfKfczy7rM7rLQ5IyJxk=", - "devOptional": true, + "dev": true, "license": "MIT", - "peer": true, "dependencies": { "pend": "~1.2.0" }, @@ -14630,6 +14671,7 @@ "version": "4.6.7", "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" diff --git a/package.json b/package.json index 1068b408..9717bb7a 100644 --- a/package.json +++ b/package.json @@ -669,14 +669,7 @@ }, "dependencies": { "@vscode/codicons": "0.0.45", - "@vscode/extension-telemetry": "1.5.2", - "bufferutil": "4.1.0", - "lit-html": "^3.3.3", - "puppeteer-core": "25.16.0", - "utf-8-validate": "6.0.6", - "vscode-chrome-debug-core": "6.8.11", - "ws": "8.22.0", - "xmlhttprequest": "1.8.0" + "vscode-chrome-debug-core": "6.8.11" }, "devDependencies": { "@opentelemetry/tracing": "0.24.0", @@ -687,7 +680,9 @@ "@types/ws": "8.18.2", "@typescript-eslint/eslint-plugin": "8.72.0", "@typescript-eslint/parser": "8.72.0", + "@vscode/extension-telemetry": "1.5.2", "@vscode/vsce": "^3.9.2", + "bufferutil": "4.1.0", "copy-webpack-plugin": "14.0.0", "eslint": "9.39.5", "eslint-plugin-import": "2.32.0", @@ -695,13 +690,18 @@ "eslint-plugin-prefer-arrow": "1.2.3", "fs-extra": "11.4.1", "jest": "30.5.2", + "lit-html": "^3.3.3", + "puppeteer-core": "25.16.0", "ts-jest": "29.4.15", "ts-loader": "9.6.2", "typescript": "6.0.3", "uglify-js": "3.19.3", "unzipper": "0.12.5", + "utf-8-validate": "6.0.6", "jest-environment-jsdom": "^30.5.2", "webpack": "5.112.2", - "webpack-cli": "7.2.3" + "webpack-cli": "7.2.3", + "ws": "8.22.0", + "xmlhttprequest": "1.8.0" } } diff --git a/src/devtoolsPanel.ts b/src/devtoolsPanel.ts index 1574021f..99166a41 100644 --- a/src/devtoolsPanel.ts +++ b/src/devtoolsPanel.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import * as path from 'path'; import * as vscode from 'vscode'; -import * as debugCore from 'vscode-chrome-debug-core'; +import { UrlPathTransformer } from 'vscode-chrome-debug-core/out/src/transformers/urlPathTransformer'; import { performance } from 'perf_hooks'; import { TelemetryReporter } from '@vscode/extension-telemetry'; import { SettingsProvider } from './common/settingsProvider'; @@ -524,7 +524,7 @@ export class DevToolsPanel { } // Convert the local url to a workspace path - const transformer = new debugCore.UrlPathTransformer(); + const transformer = new UrlPathTransformer(); void transformer.launch({ pathMapping: this.config.pathMapping }); // origin in this case is trivial since we expect fixSource to take it out diff --git a/src/extension.ts b/src/extension.ts index a9c76a9e..8f5d790d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,7 +3,9 @@ import { Browser, Target, TargetType } from 'puppeteer-core'; import * as vscode from 'vscode'; -import * as debugCore from 'vscode-chrome-debug-core'; +import type { ITarget } from 'vscode-chrome-debug-core/out/src/chrome/chromeConnection'; +import { getMatchingTargets } from 'vscode-chrome-debug-core/out/src/chrome/chromeUtils'; +import { retryAsync } from 'vscode-chrome-debug-core/out/src/utils'; import { TelemetryReporter } from '@vscode/extension-telemetry'; import { CDPTarget } from './cdpTarget'; import { CDPTargetsProvider } from './cdpTargetsProvider'; @@ -310,7 +312,7 @@ export async function attach( do { try { // Keep trying to attach to the list endpoint until timeout - responseArray = await debugCore.utils.retryAsync( + responseArray = await retryAsync( () => getListOfTargets(hostname, port, useHttps), timeout, /* intervalDelay=*/ SETTINGS_DEFAULT_ATTACH_INTERVAL) as IRemoteTargetJson[]; @@ -323,9 +325,9 @@ export async function attach( let targetWebsocketUrl = ''; if (attachUrl) { // Match the targets using the edge debug adapter logic - let matchedTargets: debugCore.chromeConnection.ITarget[] | undefined; + let matchedTargets: ITarget[] | undefined; try { - matchedTargets = debugCore.chromeUtils.getMatchingTargets(responseArray as unknown as debugCore.chromeConnection.ITarget[], attachUrl); + matchedTargets = getMatchingTargets(responseArray as unknown as ITarget[], attachUrl); } catch (e) { void ErrorReporter.showErrorDialog({ errorCode: ErrorCodes.Error, diff --git a/src/utils.ts b/src/utils.ts index 59aa2157..e968804a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,7 +8,7 @@ import * as os from 'os'; import * as path from 'path'; import * as url from 'url'; import * as vscode from 'vscode'; -import * as debugCore from 'vscode-chrome-debug-core'; +import { canonicalizeUrl, escapeRegexSpecialChars, properJoin } from 'vscode-chrome-debug-core/out/src/utils'; import { TelemetryReporter } from '@vscode/extension-telemetry'; import packageJson from '../package.json'; import { DebugTelemetryReporter } from './debugTelemetryReporter'; @@ -579,7 +579,7 @@ export function applyPathMapping( } // Does it match? - const escapedLeftPattern = debugCore.utils.escapeRegexSpecialChars(leftPattern, '/*'); + const escapedLeftPattern = escapeRegexSpecialChars(leftPattern, '/*'); const leftRegexSegment = escapedLeftPattern .replace(/\*/g, '(.*)') .replace(/\\\\/g, '/'); @@ -599,7 +599,7 @@ export function applyPathMapping( return mappedPath; } - mappedPath = debugCore.utils.properJoin(mappedPath); // Fix any ..'s + mappedPath = properJoin(mappedPath); // Fix any ..'s mappedPath = replaceWorkSpaceFolderPlaceholder(mappedPath); return mappedPath; } @@ -659,7 +659,7 @@ function replaceWorkSpaceFolderPlaceholder(customPath: string) { */ parsedPath = vscode.workspace.workspaceFolders[0].uri.toString(); const replacedPath = customPath.replace('${workspaceFolder}', parsedPath); - return debugCore.utils.canonicalizeUrl(replacedPath); + return canonicalizeUrl(replacedPath); } return parsedPath; diff --git a/test/chromeDebugCoreNls.test.ts b/test/chromeDebugCoreNls.test.ts new file mode 100644 index 00000000..b38c0838 --- /dev/null +++ b/test/chromeDebugCoreNls.test.ts @@ -0,0 +1,157 @@ +/** @jest-environment node */ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import * as fs from 'fs'; +import * as path from 'path'; +import type { Configuration } from 'webpack'; + +const extensionRoot = path.resolve(__dirname, '..'); +const bundleRoot = path.resolve(path.dirname(require.resolve('vscode-chrome-debug-core/package.json')), 'out'); +const createWebpackConfig = require('../webpack.config') as (env: Record) => Configuration[]; + +describe('external debug-core localization', () => { + let nls: typeof import('vscode-nls'); + let consoleError: jest.SpyInstance; + let consoleWarn: jest.SpyInstance; + const originalNlsConfig = process.env.VSCODE_NLS_CONFIG; + + beforeAll(() => { + process.env.VSCODE_NLS_CONFIG = '{}'; + nls = jest.requireActual('vscode-nls'); + }); + + beforeEach(() => { + nls.config({ locale: 'en', bundleFormat: nls.BundleFormat.standalone }); + consoleError = jest.spyOn(console, 'error'); + consoleWarn = jest.spyOn(console, 'warn'); + }); + + afterEach(() => { + try { + expect(consoleError).not.toHaveBeenCalled(); + expect(consoleWarn).not.toHaveBeenCalled(); + } finally { + consoleError.mockRestore(); + consoleWarn.mockRestore(); + } + }); + + afterAll(() => { + if (originalNlsConfig === undefined) { + delete process.env.VSCODE_NLS_CONFIG; + } else { + process.env.VSCODE_NLS_CONFIG = originalNlsConfig; + } + }); + + function localize(modulePath: string, key: number, ...args: string[]): string { + const messages = nls.loadMessageBundle(path.join(bundleRoot, modulePath)); + // The published dependency uses numeric indexes, which its NLS declarations do not expose. + return Reflect.apply(messages, undefined, [key, null, ...args]) as string; + } + + it('keeps debug-core and its subpath imports external without matching other packages', () => { + const config = createWebpackConfig({}).find(config => config.name === 'extension'); + expect(config?.externalsType).toBe('commonjs'); + const externals = config?.externals; + if (!Array.isArray(externals)) { + throw new Error('Expected extension webpack externals to include the debug-core package matcher.'); + } + for (const request of [ + 'vscode-chrome-debug-core', + 'vscode-chrome-debug-core/out/src/utils', + 'vscode-chrome-debug-core/out/src/chrome/chromeUtils', + 'vscode-chrome-debug-core/out/src/transformers/urlPathTransformer', + ]) { + expect(externals.some(external => external instanceof RegExp && external.test(request))).toBe(true); + } + expect(externals.some(external => external instanceof RegExp && external.test('vscode-chrome-debug-core-other'))).toBe(false); + }); + + it('keeps overlapping message indexes separate for each original module', () => { + expect(localize('src/errors.js', 0)).toBe('not available'); + expect(localize('src/chrome/stoppedEvent.js', 0)).toBe('Paused on step'); + }); + + it('loads the real errors module without losing its messages', () => { + const errors = jest.requireActual( + 'vscode-chrome-debug-core/out/src/errors', + ); + expect(errors.evalNotAvailableMsg).toBe('not available'); + expect(errors.runtimeNotConnectedMsg).toBe('not connected to runtime'); + expect(errors.noRestartFrame).toBe("Can't restart frame"); + }); + + it('preserves message argument substitution', () => { + expect(localize('src/errors.js', 3, 'webRoot', 'missing')) + .toBe("Attribute 'webRoot' does not exist ('missing')."); + }); + + it('uses the existing translation and falls back from a regional locale', () => { + nls.config({ locale: 'de-de' }); + const messages = JSON.parse(fs.readFileSync(path.join(bundleRoot, 'nls.bundle.de.json'), 'utf8')) as Record; + expect(localize('src/errors.js', 0)).toBe(messages['src/errors'][0]); + expect(localize('src/chrome/stoppedEvent.js', 0)).toBe(messages['src/chrome/stoppedEvent'][0]); + expect(messages['src/errors'][0]).not.toBe('not available'); + }); + + it('falls back to the default messages for an unsupported locale', () => { + nls.config({ locale: 'unsupported-locale' }); + expect(localize('src/errors.js', 0)).toBe('not available'); + }); + + it('includes the original modules, NLS resources, runtime dependencies, and codicons in the VSIX file list', async () => { + const { listFiles } = jest.requireActual('@vscode/vsce'); + const files = await listFiles({ cwd: extensionRoot }); + const packagedPath = (filename: string): string => path.relative(extensionRoot, filename).split(path.sep).join('/'); + for (const request of [ + 'vscode-chrome-debug-core/out/src/utils', + 'vscode-chrome-debug-core/out/src/chrome/chromeUtils', + 'vscode-chrome-debug-core/out/src/transformers/urlPathTransformer', + 'vscode-chrome-debug-core/out/src/errors', + 'vscode-nls', + 'vscode-debugadapter', + 'ws', + ]) { + expect(files).toContain(packagedPath(require.resolve(request, { paths: [bundleRoot] }))); + } + for (const name of fs.readdirSync(bundleRoot).filter(name => /^nls.*\.json$/.test(name))) { + expect(files).toContain(packagedPath(path.join(bundleRoot, name))); + } + const visited = new Set(); + function expectDependencyTree(name: string, from: string): void { + const manifestPath = require.resolve(`${name}/package.json`, { paths: [from] }); + if (visited.has(manifestPath)) { + return; + } + visited.add(manifestPath); + expect(files).toContain(packagedPath(manifestPath)); + const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as { + dependencies?: Record; + }; + for (const dependency of Object.keys(manifest.dependencies ?? {})) { + expectDependencyTree(dependency, path.dirname(manifestPath)); + } + } + expectDependencyTree('vscode-chrome-debug-core', extensionRoot); + expect(files.filter(file => file.startsWith('node_modules/@vscode/codicons/')).sort()).toEqual([ + 'node_modules/@vscode/codicons/dist/codicon.css', + 'node_modules/@vscode/codicons/dist/codicon.ttf', + ]); + for (const dependency of [ + 'puppeteer-core', + '@puppeteer', + '@vscode/extension-telemetry', + '@microsoft', + '@opentelemetry', + 'applicationinsights', + 'bufferutil', + 'lit-html', + 'utf-8-validate', + 'xmlhttprequest', + ]) { + expect(files.some(file => file.startsWith(`node_modules/${dependency}/`))).toBe(false); + } + }, 30000); +}); diff --git a/test/devtoolsPanel.test.ts b/test/devtoolsPanel.test.ts index 06f0596f..a8bfb8cb 100644 --- a/test/devtoolsPanel.test.ts +++ b/test/devtoolsPanel.test.ts @@ -535,7 +535,7 @@ describe("devtoolsPanel", () => { isHeadlessEnabled: jest.fn(), }; jest.doMock("../src/utils", () => mockUtils); - jest.mock("vscode-chrome-debug-core", () => mockDebugCore); + jest.mock("vscode-chrome-debug-core/out/src/transformers/urlPathTransformer", () => mockDebugCore); const mockVsCode = jest.requireMock("vscode"); mockVsCode.Uri.file = jest.fn(); @@ -570,7 +570,7 @@ describe("devtoolsPanel", () => { isHeadlessEnabled: jest.fn(), }; jest.doMock("../src/utils", () => mockUtils); - jest.mock("vscode-chrome-debug-core", () => mockDebugCore); + jest.mock("vscode-chrome-debug-core/out/src/transformers/urlPathTransformer", () => mockDebugCore); const mockVsCode = jest.requireMock("vscode"); mockVsCode.Uri.file = jest.fn(); @@ -605,7 +605,7 @@ describe("devtoolsPanel", () => { isHeadlessEnabled: jest.fn(), }; jest.doMock("../src/utils", () => mockUtils); - jest.mock("vscode-chrome-debug-core", () => mockDebugCore); + jest.mock("vscode-chrome-debug-core/out/src/transformers/urlPathTransformer", () => mockDebugCore); const mockVsCode = jest.requireMock("vscode"); const dtp = await import("../src/devtoolsPanel"); @@ -638,7 +638,7 @@ describe("devtoolsPanel", () => { isHeadlessEnabled: jest.fn(), }; jest.doMock("../src/utils", () => mockUtils); - jest.mock("vscode-chrome-debug-core", () => mockDebugCore); + jest.mock("vscode-chrome-debug-core/out/src/transformers/urlPathTransformer", () => mockDebugCore); const mockVsCode = jest.requireMock("vscode"); mockVsCode.Uri.file = jest.fn(); diff --git a/tsconfig.json b/tsconfig.json index 24d98d54..53057604 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,12 @@ "esModuleInterop": true, "noImplicitAny": true, "moduleResolution": "bundler", + // The dependency publishes JavaScript under out/src and declarations under lib/src. + "paths": { + "vscode-chrome-debug-core/out/src/*": [ + "./node_modules/vscode-chrome-debug-core/lib/src/*" + ] + }, // TypeScript 6 no longer includes every node_modules/@types package // automatically, so the ambient globals used here must be listed. "types": [ diff --git a/webpack.config.js b/webpack.config.js index f0ca1f72..f9362da5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -56,10 +56,15 @@ module.exports = env => { entry: { extension: './src/extension.ts', }, - externals: { - vscode: 'commonjs vscode', - 'applicationinsights-native-metrics': 'commonjs applicationinsights-native-metrics', // We're not native - }, + externalsType: 'commonjs', + externals: [ + { + vscode: 'commonjs vscode', + 'applicationinsights-native-metrics': 'commonjs applicationinsights-native-metrics', // We're not native + }, + // Keep debug-core's original filenames so its adjacent NLS resources resolve normally. + /^vscode-chrome-debug-core(?:\/.*)?$/, + ], name: 'extension', target: 'node', resolve: {