I am working on a vscode extension and am using esbuild to do the bundling/minification. I want to use the jsonc-parser NPM module. When I do this, esbuild runs OK but the extension won't load, giving an error "Activating extension failed: Cannot find module './impl/format'".
I can reproduce this in a smaller example than the whole vscode extension, see the following:
Main file
import * as jsonc from 'jsonc-parser'
const example = '// Some comment\n{"a":1,"b":2}'
console.log(`Parsing ${example}`)
const errors = []
const mexample = jsonc.parse(example, errors)
console.log(`Result: ${JSON.stringify(mexample, null, 2)}`)
console.log(`Errors: ${JSON.stringify(errors)}`)
Relevant bits of package.json
"scripts": {
"run-bundle": "node out.js",
"bundle": "esbuild index.ts --bundle --platform=node --outfile=out.js"
},
"dependencies": {
"jsonc-parser": "^3.0.0"
},
"devDependencies": {
"esbuild": "^0.12.28"
}
In the bundled out.js I can see
var formatter = require2("./impl/format");
var edit = require2("./impl/edit");
var scanner = require2("./impl/scanner");
var parser = require2("./impl/parser");
So it looks like esbuild hasn't picked these 'internal dependencies' up for bundling.
I've tried some options in tsconfig.json and package.json with no success.