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

Still getting issue "TS18003: No inputs were found in config file 'tsconfig.json'" #732

Closed
apfelbox opened this issue Feb 27, 2018 · 9 comments · Fixed by #733
Closed

Still getting issue "TS18003: No inputs were found in config file 'tsconfig.json'" #732

apfelbox opened this issue Feb 27, 2018 · 9 comments · Fixed by #733

Comments

@apfelbox
Copy link
Contributor

Hi,

I am currently building a more-or-less zero config bundler for our company's internal usage.
For this I want to add TypeScript support using ts-loader without needing any of our dozens of projects to add a tsconfig.json.

Expected Behaviour

It should just work, as there is an option in the plugin to set a custom path for the tsconfig.json.

Actual Behaviour

It doesn't work and errors out with

TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '[]'.

Steps to Reproduce the Problem

I installed your vanilla example and did the following adjustments:

  • move tsconfig.json to example/tsconfig.json

  • change the webpack config to point to the new config file:

     module: {
         rules: [
             {
                 test: /\.tsx?$/,
                 loader: 'ts-loader',
                 options: {
                     configFile: __dirname + "/test/tsconfig.json" // <- this is new
                 }
             }
         ]
     },
    

Location of a Minimal Repository that Demonstrates the Issue.

@apfelbox
Copy link
Contributor Author

Please note: moving the tsconfig.json back to the top level (= a parent directory of the *.ts files) and letting it get autodiscovered works however.

@johnnyreilly
Copy link
Member

Does this context option help? https://github.com/TypeStrong/ts-loader/blob/master/README.md#context-string-defaultundefined

If not and you'd like to investigate this I'd appreciate that; I don't have much time to spare right now

@theironcook
Copy link

Just tried to use the context option you described like this

{ test: /\.ts?$/, use: 'ts-loader', exclude: /node_modules/, options: { context: __dirname, configFile: 'tsconfig.client.json' } }

Got the same error :(

Error: options/query provided without loader (use loader + options) in {
"test": {},
"use": "ts-loader",
"exclude": {},
"options": {
"context": "/Users/TheUser/projects/TheProject/config",
"configFile": "tsconfig.client.json"
}
}

The file tsconfig.client.json is in the specified directory. It exists etc. - just not working

@johnnyreilly
Copy link
Member

@christiantinauer do you have any inights? I seem to recall you were trying to solve a similar problem with context?

@apfelbox
Copy link
Contributor Author

apfelbox commented Feb 28, 2018

@johnnyreilly it actually worked using context, thank you! I was already desparate, as nothing seemed to work. Thank you very much for the fast answer!
I will send a PR though, to suggest an improvement in the docs.

@theironcook I think you have an other issue, I think you are using invalid babel loader syntax.
There are two variations (there are actually more, but two that matter):

  1. with a single loader
{
    test: /\.ts?$/, 
    loader: 'ts-loader', 
    exclude: /node_modules/, 
    options: { 
        context: __dirname, 
        configFile: 'tsconfig.client.json' 
    },
}

or 2) with a list of loaders:

{
    test: /\.ts?$/, 
    exclude: /node_modules/, 
    use: [
        {
            loader: 'ts-loader', 
            options: { 
                context: __dirname, 
                configFile: 'tsconfig.client.json' 
            },
        }
    ]
}

You have a mix of both, but need to use loader as key. That is what the error message is trying to tell you, they literally mean the object key loader in

options / query provided without loader

@christiantinauer
Copy link
Contributor

@apfelbox happy that the option solves your problem. How can the docs be improved?

@apfelbox
Copy link
Contributor Author

I would add a note here, that you may need to set the context option, if the configFile is outside your project (root).

2018-02-28 at 09 31

What do you think?

@christiantinauer
Copy link
Contributor

That is a good idea as I think there will be others who try to change the path to an outside tsconfig file and will run into the same problems.

I guess @johnnyreilly will be happy to accept a pull request from you.

@apfelbox
Copy link
Contributor Author

I will close this issue, as we now have an open PR to keep the discussion going in #733

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants