Skip to content

custom loader in chain with ts-loader consumes ts files #1271

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

Closed
roman0x58 opened this issue Mar 21, 2021 · 4 comments
Closed

custom loader in chain with ts-loader consumes ts files #1271

roman0x58 opened this issue Mar 21, 2021 · 4 comments
Labels

Comments

@roman0x58
Copy link

roman0x58 commented Mar 21, 2021

Expected Behaviour

Custom loader chained with ts-loader handles files that matches by webpack rule test configuration property

Actual Behaviour

Custom loader gets contents from .ts files, that doesn't match by webpack rule test configuration property

Steps to Reproduce the Problem

  1. clone https://github.com/roman0x58/webpack-chaining-issue
  2. npm install
  3. npm run dev
  4. Trigger the change of index.ts file
  5. Custom loader prints contents from.ts files, but actually the loader should work only with .gql files

Location of a Minimal Repository that Demonstrates the Issue.

https://github.com/roman0x58/webpack-chaining-issue

btw I'm not sure that is webpack or ts-loader issue.

@appzuka
Copy link
Member

appzuka commented Mar 22, 2021

I took a look at your repo and observed the same as you. I observed that if you include the transpileOnly option for ts-loader the problem goes away:

      {
          loader: 'ts-loader',
          options: {
              transpileOnly: true,
          }
      },

You may not be able to use transpileOnly but if I assume your loader converts the gql file to TypeScript then you may be OK for ts-loader to transpile the output to JavaScript without referencing the other files in the project. I don't think you need the appendTsSuffixTo either, at least not for simple cases.

I don't fully understand why this is happening. Perhaps if you don't include transpileOnly then ts-loader checks all ts files in scope, although it is surprising that it processes them through the loader. This issue discusses problems chaining loaders with transpileOnly as a solution: #223 (comment). Hopefully transpileOnly will solve your issue here.

@roman0x58
Copy link
Author

@appzuka yep, probably this is solution, but I would like to generate declaration files automatically, and when I was dealing with it, I found that ts-loader with transpileOnly can't do this

@stale
Copy link

stale bot commented Apr 17, 2022

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 Apr 17, 2022
@stale
Copy link

stale bot commented Apr 28, 2022

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

@stale stale bot closed this as completed Apr 28, 2022
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

2 participants