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

configFileName can only be in root? #115

Closed
flahertyb opened this issue Dec 4, 2015 · 10 comments
Closed

configFileName can only be in root? #115

flahertyb opened this issue Dec 4, 2015 · 10 comments
Labels

Comments

@flahertyb
Copy link

My use case for configFileName is that I have many Webpack apps, some may want to use various typescript files, so I need different tsconfigs for each Webpack app to avoid compiling every .ts file for each. So I was psyched to find this as an option for ts-loader! But this property seems to not accept a path, and seems to not search in child directories for the given filename either. Having a variety of appname_tsconfig.json files in the root of the repo is not great. The typescript certainly accepts a path for config on the command line - is there a plan to support this in ts-loader?

@jbrantly
Copy link
Member

jbrantly commented Dec 7, 2015

The property doesn't accept paths, that's true. However, the search for a tsconfig file starts at the entrypoint. You can use this to segregate your apps by using directories.

  • app1
    • main.ts
    • tsconfig.json
  • app2
    • main.ts
    • tsconfig.json

You may also need to use the "instance" option so that each app is separated into its own TypeScript instance, but you may not need to depending on your webpack configuration.

All of that said, ts-loader should have feature parity with tsc so we should probably accept a path. There's also a related discussion in TypeStrong/discussions#1

@flahertyb
Copy link
Author

What are your thoughts on being able to specify files or filesGlob directly in the webpack config? It seems like the most low-friction way for an existing Webpack app to casually start using/depending on a couple ts modules that themselves depend, say, on React or jQuery typings.

@jbrantly
Copy link
Member

jbrantly commented Dec 8, 2015

In an earlier version of ts-loader you could do just that. However, once tsconfig.json was released I removed support for it. tsconfig.json is a much better place for that file list because all of your TS tooling knows how to read it, not just webpack.

@flahertyb
Copy link
Author

Ah, I see. Well, for sure, tsconfig.json absolutely makes a lot of sense for me and the typescript app I'm writing. atom-typescript, tsc, ts-loader can all use the same thing.

I would just point out that, to someone else who maintains an es6 webpack app, who knows nothing about typescript, but may want to make use of a library React/Typescript component that I've written - to them, it may seem pretty unhelpful that they need an addition json config file just to tell TypeScript where to find the typings for React. For them, a files array in the webpack config is probably easiest.

Course, I understand the absolute easiest way to start importing ts files, for people who don't know or care about typescript, may not be the goal here. Just pointing out this one perspective.

Thank you for help with everything!

@Delagen
Copy link

Delagen commented Apr 27, 2016

I think it must be rewritten. If all config params are supplied through loader query and config file not found in search path, error occured due path.dirname does not accept undefined

I think it must be as

if (typeof compiler.parseJsonConfigFileContent === 'function') {
        // parseConfigFile was renamed between 1.6.2 and 1.7
        configParseResult = compiler.parseJsonConfigFileContent(configFile.config, compiler.sys,configFilePath&& path.dirname(configFilePath));
    }

@fmflame
Copy link

fmflame commented Jun 1, 2017

Guys, this is so old and this is not yet added as an option. WHY? Currently I have such a setup that I am generating a webpack build with a script that is installed as NPM package but it takes as input typescript files in a folder located in the root of the project. The tsconfig the webpack is using though is located in the npm package of the script not in the project root.

When I start the webpack build it tries to load the tsconfig file from the project root and not from the package where the tsconfig actually is. WHY? My currently active directory is that of the package not the project root. So why does the ts-loaded tries to load the tsconfig file from the project root then? I am not sure but it's possible that there is also a bug here.

And now the only workaround for me is to copy the tsconfig from the package to the typescript source folder in the project root (or in the project root itself) so this damn loader would find it. As you can guess I don't want to spam the project folder with additional or generated files so NOT having the option to specify path to the tsconfig file for ts-loader is a HUGE inconvenience for us. And it doesn't really seem like a big thing to fix or add as a feature.

Please let me know when are you planning to fix this?

@johnnyreilly
Copy link
Member

We accept pull requests! Go to it 😄

@fmflame
Copy link

fmflame commented Jun 1, 2017

Will definitely do it when I find the time and it's not yet added.

@stale
Copy link

stale bot commented Jan 19, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 19, 2019
@stale
Copy link

stale bot commented Jan 26, 2019

Closing as stale. Please reopen if you'd like to work on this further.

@stale stale bot closed this as completed Jan 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants