Support references to node_modules modules on command line
This commit is contained in:
parent
874303186d
commit
282d3f798f
|
@ -80,6 +80,10 @@ export function modulePathTo(file1: string, file2: string): string {
|
||||||
return changeExt(naive, '');
|
return changeExt(naive, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAbsoluteOrExplicitlyRelative(p: string) {
|
||||||
|
return p[0] === '.' || p[0] === '/';
|
||||||
|
}
|
||||||
|
|
||||||
export function runOnce(options: CommandLineArguments): CompilationResult {
|
export function runOnce(options: CommandLineArguments): CompilationResult {
|
||||||
const { base, failures, inputFiles: inputFiles0 } =
|
const { base, failures, inputFiles: inputFiles0 } =
|
||||||
expandInputGlob(options.inputs, options.base);
|
expandInputGlob(options.inputs, options.base);
|
||||||
|
@ -106,7 +110,9 @@ export function runOnce(options: CommandLineArguments): CompilationResult {
|
||||||
inputFiles.forEach(c => {
|
inputFiles.forEach(c => {
|
||||||
const env: M.Environment = [
|
const env: M.Environment = [
|
||||||
... extensionEnv.flatMap(e => {
|
... extensionEnv.flatMap(e => {
|
||||||
const p = modulePathTo(c.outputFilePath, e.typescriptModulePath);
|
const p = isAbsoluteOrExplicitlyRelative(e.typescriptModulePath)
|
||||||
|
? modulePathTo(c.outputFilePath, e.typescriptModulePath)
|
||||||
|
: e.typescriptModulePath /* assuming it names something in node_modules */;
|
||||||
if (p === null) return [];
|
if (p === null) return [];
|
||||||
return [{... e, typescriptModulePath: p}];
|
return [{... e, typescriptModulePath: p}];
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue