Commit 54e1418
fix: use createRequire for node_modules resolution in VSCode extension (#1171)
* fix: use createRequire for node_modules resolution in VSCode extension
The VSCode extension server is bundled with webpack, which replaces
`require` with its own module system. webpack's `require.resolve` does
not support the `paths` option and returns a numeric module ID rather
than a file path, causing "Cannot find module" errors for custom check
packages (e.g. `@grafikr/theme-check-extension/recommended.yml`).
Replace `require.resolve(pathLike, { paths: getAncestorNodeModules(root) })`
with `createRequire` from `node:module`, which creates a real Node.js
require function that bypasses webpack's substitution. Node.js's native
module resolution already traverses ancestor node_modules directories
automatically, so `getAncestorNodeModules` is no longer needed.
Fixes #1170
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: add changeset for node_modules resolution fix
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Update packages/theme-check-node/src/config/resolve/read-yaml.ts
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 6fe8023 commit 54e1418
2 files changed
Lines changed: 14 additions & 13 deletions
File tree
- .changeset
- packages/theme-check-node/src/config/resolve
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 9 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
175 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
176 | 184 | | |
177 | 185 | | |
178 | 186 | | |
| |||
237 | 245 | | |
238 | 246 | | |
239 | 247 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
0 commit comments