-
-
Notifications
You must be signed in to change notification settings - Fork 431
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
Allow the loading of files through loader configuration #385
Conversation
It's an interesting idea. However, I rather think having a I'm open to being convinced but I'm not yet sold that getting going without a |
I agree that if the point is "I can stick all config in webpack config and forego tsconfig" then I don't think this is necessary. You should be using tsconfig instead. However, if changed to "is it possible to add/remove files for the webpack-specific build" I think that's maybe a little more interesting. I think it would be nice to have a concrete scenario for that before adding though. |
Wow, that was fast, sure I can explain. In the company I work for, we have a tool that is like The goal of this tool is to manage everything through a single configuration file that hides all the complexity of the tools used below. but still allows to create tool-specific configurations that will be taken in account ( For example a configuration like this: module.exports = {
jsProvidedLibraries: ["react", "react-dom"],
js: {
reactTypeScript: {
webpack: true,
react: true,
source: "js/index.ts"
},
}
}; Will use webpack with ts-loader to compile the file with all of its dependencies, including css, treat We also use {
"files": [
"./typings/index.d.ts"
]
} I hope this clarifies a bit the reason of this pull request. |
I guess I don't understand why your scenario requires files to be specified in |
That's also what I was thinking... |
Sorry if I explained myself incorrectly, But writing things in My goal is to be able to give a full configuration to webpack and ts-loader without adding a single webpack or typescript specific configuration file. |
I kind of think this is a bad idea.... Isn't this feature is only useful for "hello world" scenarios? I don't really see it being used for anything else. Have I missed something? I might be being a bit dense (totally possible!) but I can't really see an advantage to this at the moment... |
No, it also works for full applications. I think that when you defined your The only things you do are:
None of these requires you to change your That's why I want to hide this complexity from the "final developer". I write the build tool wrapper, he writes his application. |
Presumably this developer might want to use a TypeScript-aware IDE. How do you plan on configuring that IDE with TypeScript options without a tsconfig.json? I'm starting to see what your goal is. I didn't realize |
Actually, purely speaking for myself, no. Both as TypeScript changes and as I reach different points of a project I do find myself tweaking the settings. It's not a daily task but it is pretty regular as I try to move to using the most beneficial setup that I can find at a given time. |
It depends on the IDE, in my case, we all use IntelliJ/WebStorm which is able to automatically find all definition files. Which allows it to detect problems in my code with it's own engine. I have to admit I didn't consider this part for other IDE's for the moment.
It's both actually, by default it hides the configuration away and with
I totally agree with you, it's exactly my way of working as well, but sadly it's not the case for everybody, many think of these tools as "configure once and forget". |
A better choice is awaiting 2.1.3 for configuration inheritance.
This is fairly impossible unless you can patch out every thing you need. For a simple app it's possible but for a project with enough dependencies that's virtually impossible given the blooming ecosystem of JavaScript.
This will quickly fail when you want some specific customization or you want to ignore some definition. For example #381
ts-loader will load typing files by default if tsconfig.json exists in the directory, well, if tsconfig.json exists. After all, given you are building a |
It is possible, I did it :D I would love to show you, but sadly I can't open source it. We create online banking applications with it, not just "hello world" apps.
My case is not like this one, you don't have one installation and all packages are symlinked from there, in my case, you have let's say 20 independent projects, each has the same stack (TS/Babel/Webpack/Postcss) and we don't want to maintain the configuration 20 times. We want to take a "convention over configuration" approach.
Yes, exactly, but I never said you should never have a
Some parts are handled by IntelliJ, but you are right, some configurations are not inferred automatically.
How ? I didn't see that feature in the code.
Agreed, the number of configuration files doesn't matter. But the scaffolding for their project is theirs, I just provide a package to install with a single configuration file to get started (same idea as gulp : |
In the end, I think it's everybody has a different way to work, and when trying to configure ts-loader, that you are able to override ( Something like this :D )
|
It's not in the ts-loader code; it's how TypeScript itself behaves. Where a {
"compilerOptions": {
}
} TBH I think it's totally valid for them to be {
} So given there are already sensible defaults in place it seems fairly reasonable to create an empty Which reminds me; we should probably update the readme to simplify what's there. It hasn't been updated in ages. |
I think what you've done here is super cool @onigoetz - I'm really impressed you implemented this, provided such a thorough PR and made your case really well. But I don't think we want to merge this for the reasons that have been discussed in the thread so far. I'm really sorry; I've thought long and hard about this. In the end I think the extra complexity that is introduced to support his simply isn't worth it given that the alternative is having an essentially empty I hope this doesn't put you off contributing to ts-loader in the future. |
Thanks for your answer, @johnnyreilly. I understand completely your point, in the end, you would have to maintain it and it's completely fair to refuse a contribution :D Of course I would have loved to see this merged, but we'll do it the way you described, it's not dramatic. Don't worry, I will contribute if I have something to share ;-) |
Thanks @onigoetz - I appreciate that. 👍 |
Just present a different use case for this feature that my team is having: We have multiple webpack projects which share some common libraries and node_modules. We have no problem putting a single tsconfig to rule them all. But without the ability to specify what files to include in webpack config, building one of these webpack projects requires compiling all files of all the projects as specified in the tsconfig. So it would be really nice if we could somehow override the files/include field in webpack just to optimize the build time. Probably the feature to support our use case is less intrusive since we still keep the tsconfig.json. |
We always welcome PRs! |
Hi,
I had the need to provide a default configuration for TypeScript through the loader so a user doesn't have to create a
tsconfig.json
at all for basic usage of webpack with ts-loader.I was able to do it for
compilerOptions
but files are skipped from this configuration.This pull request adds this feature and does it through the TypeScript API the same way as for normal files.
I also added two tests that ensure this works as expected.