-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add method host.createCustomSourceFile for custom file extensions #52983
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
Comments
@sheetalkamat any thoughts on this? |
I'm almost sure without such a method, builders and language servers will be forced to redefine the internal interfaces of the TS, even in version 5.x where they made getters on all properties of the TS object, this is a really necessary functionality. |
I am not sure I understand the concern here, By default, this is how the trace for resolving say ".css" extension looks like from "a.ts" where only "b.css" exists next to it.
So we would never resolve module to file |
@sheetalkamat How do you evaluate the design of such a solution, redefining |
About performance, I assumed that checking for the presence of the |
@uasan this is very unconstructive. Of course we don't want to do bad things. The question is whether the proposal is bad or good (or bad or good relative to other options). Everyone agrees we should do better things once we agree on what the better thing is (and why). Framing it like "why not do better?" is begging the question. |
The fileExists overrride on const originalFileExists = host.fileExists.bind(host);
host.fileExists = fileName => {
if (fileName.endsWith(".d.css.ts") fileName = fileName.substring(0, ".d.css.ts".length);
return originalFileExists(fileName);
} |
Ok, I understand your answer that you think this is a normal solution. Is my feedback from the developer of build systems, I sincerely don’t understand why in order to integrate with the compiler I have to override filesystem methods, why there are no special methods for integrations, I can close this ticket. |
I will also describe the reasons why we and many others do not create When a scan finds a CSS file, its contents are sent to the CSS parser get AST(CSS), then generate |
@sheetalkamat I did as you suggested, overridden I had to add all custom extensions to |
Suggestion
Hello, I like the new option
--allowArbitraryExtensions
in 5 TS, but this only works for created files on the file system or overriding a set offs
methods (readDirectory , readFile , etc).Generating files on real time is not very efficient, so we have to override different methods so that the TS receives the created instance
SourceFile
without creating a file on filesystem.I propose to add a new method
createCustomSourceFile
to thehost
, which is undefined by default, if the user has defined this method in the host, then the TS should call it for all files with extensions that the TS does not support (.css, .svg, .vue, etc).📃 Motivating Example
💻 Use Cases
The text was updated successfully, but these errors were encountered: