Skip to content

Commit 8042c1c

Browse files
authored
build: migrate JavaScript tooling to pnpm 11 (#1792)
Part of #1732. I used https://github.com/oxc-project/oxc-vscode as a reference. ## Why Before updating the dependency backlog, we need a safer baseline for installing and running JavaScript tools. pnpm 11 denies dependency build scripts unless they are explicitly reviewed, applies a default cooldown to newly published packages, and exposes undeclared dependency assumptions through its isolated node_modules layout. This PR keeps those protections enabled. The value here is combining an exact package-manager pin, pnpm's installation safeguards, and project-declared CLI tools. Release jobs should not fetch executables through npx at execution time. ## Changes - Pin pnpm exactly to 11.27.1 in package.json and replace package-lock.json with pnpm-lock.yaml. - Use pnpm and explicit frozen-lockfile installs in the main, pre-release, and release workflows. - Declare `@vscode/vsce` and `ovsx` as devDependencies; use project-local binaries for them and `git-cliff`. - Allow only `esbuild`'s dependency build script, which prepares its platform-specific binary. Explicitly deny vsce-sign and keytar because these workflows do not sign VSIX files or use vsce's credential store. - Package the bundled extension with `vsce --no-dependencies`, and include only required files in the VSIX. - Update VS Code tasks, launch configuration, and contributor commands.
1 parent 56e9c8b commit 8042c1c

12 files changed

Lines changed: 5337 additions & 6180 deletions

‎.github/workflows/main.yml‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,39 @@ jobs:
2323
- uses: r-lib/actions/setup-r@f9a764fea8d5c63df6ef9a5c7795bf7deb5d7e05 # v2
2424
with:
2525
use-public-rspm: true
26+
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
2627
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
2728
with:
2829
node-version: 24
29-
cache: 'npm'
30-
- run: npm install
30+
cache: 'pnpm'
31+
- run: pnpm install --frozen-lockfile
3132
- name: Install remotes
3233
run: install.packages("remotes")
3334
shell: Rscript {0}
34-
- run: npm run build
35+
- run: pnpm run build
3536
- name: Run sess tests
3637
run: tinytest::test_package("sess")
3738
shell: Rscript {0}
3839
- name: Run tests (Linux)
3940
if: runner.os == 'Linux'
40-
run: xvfb-run -a npm run test
41+
run: xvfb-run -a pnpm run test
4142
- name: Run tests
4243
if: runner.os != 'Linux'
43-
run: npm run test
44+
run: pnpm run test
4445
build:
4546
runs-on: ubuntu-latest
4647
env:
4748
VSIX_FILE: vscode-R.vsix
4849
steps:
4950
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
51+
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
5052
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
5153
with:
5254
node-version: 24
53-
cache: 'npm'
54-
- run: npm install
55+
cache: 'pnpm'
56+
- run: pnpm install --frozen-lockfile
5557
- name: Package extension
56-
run: npx @vscode/vsce package -o $VSIX_FILE
58+
run: pnpm exec vsce package --no-dependencies -o $VSIX_FILE
5759
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
5860
with:
5961
name: ${{ env.VSIX_FILE }}
@@ -71,14 +73,15 @@ jobs:
7173
run: install.packages("lintr")
7274
shell: Rscript {0}
7375

76+
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
7477
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
7578
with:
7679
node-version: 24
77-
cache: 'npm'
80+
cache: 'pnpm'
7881

79-
- run: npm install
82+
- run: pnpm install --frozen-lockfile
8083
- name: eslint
81-
run: npx eslint src --ext ts
84+
run: pnpm exec eslint src --ext ts
8285

8386
- name: Lint R directory
8487
run: lintr::lint_dir("./R")

‎.github/workflows/pre-release.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ jobs:
1818
VSIX_FILE: vscode-R.vsix
1919
steps:
2020
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
21+
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
2122
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
2223
with:
2324
node-version: 24
24-
cache: 'npm'
25-
- run: npm install
25+
cache: 'pnpm'
26+
- run: pnpm install --frozen-lockfile
2627
- name: Package extension
27-
run: npx @vscode/vsce package -o $VSIX_FILE
28+
run: pnpm exec vsce package --no-dependencies -o $VSIX_FILE
2829
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
2930
with:
3031
name: "${{ env.VSIX_FILE }}"

‎.github/workflows/release.yml‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
18+
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
1819
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
1920
with:
2021
node-version: 24
21-
cache: 'npm'
22-
- run: npm install
22+
cache: 'pnpm'
23+
- run: pnpm install --frozen-lockfile
2324
- name: Package extension
2425
id: package
2526
run: |
26-
npx @vscode/vsce package
27+
pnpm exec vsce package --no-dependencies
2728
echo "VSIX_FILE=$(ls *.vsix)" >> $GITHUB_OUTPUT
2829
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
2930
with:
@@ -59,17 +60,18 @@ jobs:
5960
needs: build
6061
steps:
6162
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
63+
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
6264
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
6365
with:
6466
node-version: 24
65-
cache: 'npm'
66-
- run: npm install
67+
cache: 'pnpm'
68+
- run: pnpm install --frozen-lockfile
6769
- name: Download artifacts
6870
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
6971
with:
7072
name: vsix-artifact
7173
path: artifacts/
7274
- name: Publish to Visual Studio Marketplace
73-
run: npx @vscode/vsce publish -p ${{ secrets.VSCE_TOKEN }} --packagePath artifacts/*.vsix
75+
run: pnpm exec vsce publish -p ${{ secrets.VSCE_TOKEN }} --packagePath artifacts/*.vsix
7476
- name: Publish to Open VSX Registry
75-
run: npx ovsx publish -p ${{ secrets.OPEN_VSX_TOKEN }} --packagePath artifacts/*.vsix
77+
run: pnpm exec ovsx publish -p ${{ secrets.OPEN_VSX_TOKEN }} --packagePath artifacts/*.vsix

‎.vscode/launch.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"${workspaceFolder}/dist/**/*.js"
1818
],
1919
"sourceMaps": true,
20-
"preLaunchTask": "npm: compile"
20+
"preLaunchTask": "compile"
2121
},
2222
{
2323
"name": "Launch Extension (--disable-extensions)",
@@ -32,7 +32,7 @@
3232
"${workspaceFolder}/dist/**/*.js"
3333
],
3434
"sourceMaps": true,
35-
"preLaunchTask": "npm: compile"
35+
"preLaunchTask": "compile"
3636
},
3737
{
3838
"name": "Extension Tests",
@@ -47,7 +47,7 @@
4747
"${workspaceFolder}/dist/**/*.js",
4848
"${workspaceFolder}/out/**/*.js"
4949
],
50-
"preLaunchTask": "npm: pretest"
50+
"preLaunchTask": "pretest"
5151
}
5252
]
5353
}

‎.vscode/tasks.json‎

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
"label": "Package Extension",
88
"type": "shell",
99
"problemMatcher": [],
10-
"command": "vsce",
10+
"command": "pnpm",
1111
"args": [
12+
"exec",
13+
"vsce",
1214
"package",
15+
"--no-dependencies",
1316
"-o",
1417
"${workspaceFolderBasename}.vsix"
1518
]
@@ -31,49 +34,41 @@
3134
}
3235
},
3336
{
34-
"type": "npm",
35-
"script": "compile",
37+
"label": "compile",
38+
"type": "shell",
39+
"command": "pnpm",
40+
"args": ["run", "compile"],
3641
"problemMatcher": []
3742
},
3843
{
39-
"type": "npm",
40-
"script": "build",
44+
"label": "build",
45+
"type": "shell",
46+
"command": "pnpm",
47+
"args": ["run", "build"],
4148
"problemMatcher": "$tsc"
4249
},
4350
{
44-
"type": "npm",
45-
"script": "watch",
51+
"label": "watch",
52+
"type": "shell",
53+
"command": "pnpm",
54+
"args": ["run", "watch"],
4655
"group": "build",
4756
// install https://marketplace.visualstudio.com/items?itemName=eamodio.tsl-problem-matcher
4857
"problemMatcher": ["$ts-webpack-watch"],
4958
"isBackground": true
5059
},
51-
{
52-
"type": "npm",
53-
"script": "watchHelp",
54-
"group": "build",
55-
"problemMatcher": "$tsc-watch",
56-
"isBackground": true
57-
},
58-
{
59-
"type": "npm",
60-
"script": "watchHttpgd",
61-
"group": "build",
62-
"problemMatcher": "$tsc-watch",
63-
"isBackground": true
64-
},
6560
{
6661
"label": "watchAll",
6762
"dependsOn": [
68-
"npm: watch",
69-
"npm: watchHelp",
70-
"npm: watchHttpgd"
63+
"watch"
7164
],
7265
"problemMatcher": []
7366
},
7467
{
75-
"type": "npm",
76-
"script": "pretest",
68+
"label": "pretest",
69+
"type": "shell",
70+
"command": "pnpm",
71+
"args": ["run", "pretest"],
7772
"problemMatcher": "$tsc",
7873
"presentation": {
7974
"reveal": "never"

‎.vscodeignore‎

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
.csv
2-
.github/**
3-
.gitignore
4-
.vscode
5-
.vscode-test/**
6-
.vscode/**
7-
.xls
8-
.xlsx
9-
cliff.toml
10-
**/*.map
11-
html/**/*.ts
12-
out/test/**
13-
src/
14-
src/**
15-
test/**
16-
**/tsconfig.json
17-
esbuild.js
18-
.markdownlint.json
19-
.eslintignore
20-
node_modules
21-
out/
1+
**
2+
!package.json
3+
!README.md
4+
!CHANGELOG.md
5+
!LICENSE
6+
!R/**
7+
!sess/**
8+
!html/**/*.ejs
9+
!html/**/*.css
10+
!html/**/*.js
11+
!images/**
12+
!language-configuration/**
13+
!snippets/**
14+
!syntaxes/**
15+
!dist/**/*.js
16+
!dist/**/*.css
17+
!dist/**/*.ejs

‎CONTRIBUTING.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ If you are interested in writing code to fix issues, please see [How to Contribu
44

55
## Debugging the extension
66

7-
1. Run `npm install` and open this repository in VS Code.
8-
2. Select **Launch Extension** in Run and Debug, then press **F5**. The pre-launch task runs `npm run compile` to build the extension and webviews in `dist`, including source maps for TypeScript breakpoints.
7+
1. Run `pnpm install` and open this repository in VS Code.
8+
2. Select **Launch Extension** in Run and Debug, then press **F5**. The pre-launch task runs `pnpm run compile` to build the extension and webviews in `dist`, including source maps for TypeScript breakpoints.
99
3. Open an R file or run an R command in the Extension Development Host to activate vscode-R. Ensure the **R Syntax** extension (`REditorSupport.r-syntax`) is installed and enabled there.
1010

11-
For continuous rebuilding, run `npm run watch`. `npm run build` additionally installs the bundled `sess` R package; this is not required just to launch the extension debugger. **Extension Tests** builds both the bundle and the TypeScript test files before launching.
11+
For continuous rebuilding, run `pnpm run watch`. `pnpm run build` additionally installs the bundled `sess` R package; this is not required just to launch the extension debugger. **Extension Tests** builds both the bundle and the TypeScript test files before launching.
1212

1313
VS Code 1.139 has a [JavaScript debugger regression](https://github.com/microsoft/vscode-js-debug/issues/2420) that can leave the development host paused before any extension activates. The launching window's extension host log shows `ECONNREFUSED ::1` and `Could not find any debuggable target`. The fix is included in [JavaScript Debugger 1.140](https://github.com/microsoft/vscode-js-debug/releases/tag/v1.140.0). Until your VS Code version includes it, use Microsoft's [JavaScript Debugger Nightly](https://marketplace.visualstudio.com/items?itemName=ms-vscode.js-debug-nightly): disable the built-in **JavaScript Debugger**, install Nightly, and reload VS Code. Switch back to the built-in debugger once VS Code includes the fix.

0 commit comments

Comments
 (0)