Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolution of JS files is not working as expected when using API #23564

Closed
alan-agius4 opened this issue Apr 20, 2018 · 2 comments
Closed

Resolution of JS files is not working as expected when using API #23564

alan-agius4 opened this issue Apr 20, 2018 · 2 comments

Comments

@alan-agius4
Copy link
Contributor

alan-agius4 commented Apr 20, 2018

TypeScript Version: 2.8.3

Search Terms:
index resolution
resolution

Code

index.js

export * from "./test"

test/index.js

export const x = "hello";

Transpile code;

const ts = require("typescript");

const options = { module: ts.ModuleKind.AMD, target: ts.ScriptTarget.ES5, allowJs: true, outDir: "out" };
const host = ts.createCompilerHost(options);
const program = ts.createProgram(["index.js"], options, host);
program.emit();

Expected behavior:
both files get emitted and downleveled

Actual behavior:
test/index.js is not resolved and only the root index.js is being transpiled, when using the API to downlevel some JS files. If I change the export to export * from "./test/index" all files are being transpiled.

Related Issues:
ng-packagr/ng-packagr#784

@ajafff
Copy link
Contributor

ajafff commented Apr 20, 2018

you can use --traceResolution to get detailed output about the module resolution.

You probably want to use --moduleResolution node.

option type default
--moduleResolution string module === "AMD" or "System" or "ES6" ? "Classic" : "Node"

@alan-agius4
Copy link
Contributor Author

alan-agius4 commented Apr 20, 2018

You are right, I was having an exception Debug Failure. Unexpected moduleResolution: node but now I realised that it should be used as enumeration moduleResolution: ModuleResolutionKind.NodeJs when using the API.

Silly me!

@microsoft microsoft locked and limited conversation to collaborators Jul 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants