I am working on a Visual Studio Code extension, where I am using non-relative imports in typescript, for example:
import ModuleA from 'modules/ModuleA';
Where the actual folder to ModuleA
is src/modules/ModuleA
and the tsconfig.json
is as follows, where I specify src
as the baseUrl
:
{
"compilerOptions": {
"baseUrl": "./src",
"module": "commonjs",
"target": "es6",
"outDir": "out",
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"lib": [
"es6"
],
"sourceMap": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"moduleResolution": "node"
},
"exclude": [
"node_modules",
".vscode-test"
]
}
Everything compiles and builds just fine, however, when I attempt to launch the extension for testing, I get the error: Activating extension failed: Cannot find module 'modules/ModuleA'
. My .vscode/launch.json
file that I use to launch the extension looks like this:
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/out"],
"preLaunchTask": "build",
"internalConsoleOptions" : "openOnSessionStart"
}
]
}
How do I get non-relative paths working for developing vscode extensions?