feat(compiler): support paths in compiler options#1584
Merged
adamdbradley merged 7 commits intomasterfrom Aug 14, 2019
Merged
Conversation
|
Just a bump on this.. spent a lot more that I care to admit trying to see if was an issue on my end or not. |
|
Bump for sure, awesome of you to implement a solution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Someone was asking about why path aliases in the
compilerOptionssection of tsconfig didn't work in Stencil, and I ended up trying to solve it.First, I created rollup-plugin-typescript-paths, which uses
nodeModuleNameResolverfrom the typescript api to resolve imports using the path aliases (it returns the transpiled.jscounterpart of the.tsfile).Then I realized that I had an issue with const enums: Stencil removes the
pathsfield from the compiler options entirely (intranspile-service.ts), which causes the import statements of any const enums to remain in the file even though they have disappeared during transpilation (like interfaces).To solve this I decided to implement the resolving of path aliases in Stencil itself, because it's relatively simple and the only reason I wrote my plugin was for use with Stencil (though it should theoretically work in other contexts).
To try it out:
npm linkin stencilnpm init stencil app foobarcd foobar,npm link @stencil/coreBTW I tried writing a test but didn't have enough time to figure out how to change the compiler options within the test.