I'm trying to use @typescript-eslint/parser + eslint for linting code in an online editor. Right now I've got the eslint import to work using the officially supported built product for browser. But there doesn't seem to be an official way to use @typescript-eslint/parser in the browser, while it's definitely possible and is used in their own demo site and astexplorer. Attempt to import it directly led to the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'dirname')
at ../node_modules/.pnpm/glob-parent@5.1.2/node_modules/glob-parent/index.js (index.js:4:46)
at __require2 (chunk-IEEDF65T.js?v=2b1fa2fc:35:50)
at ../node_modules/.pnpm/fast-glob@3.2.11/node_modules/fast-glob/out/utils/pattern.js (pattern.js:5:20)
at __require2 (chunk-IEEDF65T.js?v=2b1fa2fc:35:50)
at ../node_modules/.pnpm/fast-glob@3.2.11/node_modules/fast-glob/out/utils/index.js (index.js:12:17)
at __require2 (chunk-IEEDF65T.js?v=2b1fa2fc:35:50)
at ../node_modules/.pnpm/fast-glob@3.2.11/node_modules/fast-glob/out/managers/tasks.js (tasks.js:4:15)
at __require2 (chunk-IEEDF65T.js?v=2b1fa2fc:35:50)
at ../node_modules/.pnpm/fast-glob@3.2.11/node_modules/fast-glob/out/index.js (index.js:2:21)
at __require2 (chunk-IEEDF65T.js?v=2b1fa2fc:35:50)
// doesn't work
import * as parser from '@typescript-eslint/parser'
const linter = new eslint.Linter()
linter.defineParser('@typescript-eslint/parser', parser)
linter.verify('someTSCode', someConfig)
"vite": "^2.9.1",
"vue": "^3.2.33",
"eslint": "^8.13.0",
"@typescript-eslint/parser": "^5.22.0",