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, '');
|
||||
}
|
||||
|
||||
function isAbsoluteOrExplicitlyRelative(p: string) {
|
||||
return p[0] === '.' || p[0] === '/';
|
||||
}
|
||||
|
||||
export function runOnce(options: CommandLineArguments): CompilationResult {
|
||||
const { base, failures, inputFiles: inputFiles0 } =
|
||||
expandInputGlob(options.inputs, options.base);
|
||||
|
@ -106,7 +110,9 @@ export function runOnce(options: CommandLineArguments): CompilationResult {
|
|||
inputFiles.forEach(c => {
|
||||
const env: M.Environment = [
|
||||
... 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 [];
|
||||
return [{... e, typescriptModulePath: p}];
|
||||
}),
|
||||
|
|
Loading…
Reference in New Issue