Giter VIP home page Giter VIP logo

Comments (11)

dons20 avatar dons20 commented on June 6, 2024 2

So after much testing, I think I understand a little bit more of how this is happening.

If esbuild-loader is involved in transpilation of a file that happens to import something that your tsconfig.json did not include in its options, it will throw this warning.

E.g. If you have a .tsx file that imports an svg that you are later processing with another loader (@svgr/webpack for example), it will read and process that svg import and will try to apply the tsconfig.json in your project to that particular file as well.

This may be a good warning for the sake of clarity, but it's also a little bit unexpected in my opinion. This was added in V4. https://github.com/privatenumber/esbuild-loader/releases/tag/v4.0.0

To immediately fix this, you can add the tsConfigRaw: {} to the loader options though be careful if you need specific TS options added. Here's an example following my situation

// Checks for SVG imports inside js(x) files
{
  test: /\.svg$/,
  exclude: /node_modules/,
  issuer: {
    test: /\.tsx?$/,
  },
  use: [
    {
      loader: 'esbuild-loader',
      options: {
        loader: 'tsx',
        tsconfigRaw: {},
      },
    },
    {
      loader: '@svgr/webpack',
      options: { ... },
    },
    {
      loader: 'url-loader',
      options: { ... },
    },
  ],
},

Also here are two suggestions I'd propose. If @privatenumber agrees, I wouldn't mind contributing a PR to modify some things too.

  1. Adding a separate config flag to hide these warnings. This warning can break builds / pipelines that don't allow warnings.
  2. If the v4 functionality was added to handle cases of multiple tsconfigs, perhaps the newer logic could apply when there are multiple tsConfigs? Perhaps this is something that can be changed via a flag as well?

from esbuild-loader.

privatenumber avatar privatenumber commented on June 6, 2024

from esbuild-loader.

vritant24 avatar vritant24 commented on June 6, 2024

Thanks for the quick reply!

Apologies I accidentally made private repo. Fixed that. I hope the repo elaborates my issue better

  • the tsconfig is included, and the files are included as part of referenced tsconfigs
  • There is a Warning, but it also comes as an error underneath, which fails our build:
WARNING in ./src/desktop/main.ts
  Module Warning (from ./node_modules/esbuild-loader/dist/index.cjs):
  [esbuild-loader] The specified tsconfig at "C:\repos\webpack-esbuild-loader-4-repro\tsconfig.json" was applied to the file "C:\repos\webpack-esbuild-loader-4-repro\src\desktop\main.ts" but does not match its "include" patterns
  Error: [esbuild-loader] The specified tsconfig at "C:\repos\webpack-esbuild-loader-4-repro\tsconfig.json" was applied to the file "C:\repos\webpack-esbuild-loader-4-repro\src\desktop\main.ts" but does not match its "include" patterns
      at Object.ESBuildLoader (C:\repos\webpack-esbuild-loader-4-repro\node_modules\esbuild-loader\dist\index.cjs:60:11)

from esbuild-loader.

balasphilip avatar balasphilip commented on June 6, 2024

I was migrating a Typescript+Webpack+Babel loader monorepo with the references section in a tsconfig of the application host file and faced exactly same issue. The sub-packages I have under the references section are compiled with the same error.

from esbuild-loader.

davidmurdoch avatar davidmurdoch commented on June 6, 2024

The warning reads like esbuild knows what to do (don't apply the tsconfig to the file) but is just letting you know it is going to do it anyway.

I thought I needed to figure out how to configure things so that the tsconfig isn't applied to the file (mine is in node_modules), but @privatenumber seems to be suggesting that the opposite is what is required.

from esbuild-loader.

privatenumber avatar privatenumber commented on June 6, 2024

Feel free to open a PR

from esbuild-loader.

davidmurdoch avatar davidmurdoch commented on June 6, 2024

Feel free to open a PR

Maybe once I figure out what the warning is trying to tell me.

from esbuild-loader.

privatenumber avatar privatenumber commented on June 6, 2024

If you need help, you'll have to provide a minimal reproduction at the least. Otherwise, there's nothing for anyone to debug.

from esbuild-loader.

privatenumber avatar privatenumber commented on June 6, 2024

@dons20

I appreciate you contributing constructively!

Here are the problems I see:

I'm open to the following PRs:

  • Test that emits this warning and shows that it fails. And another test that confirms Webpack configuration can suppress this warning.
  • Fix for the tsconfig.json matching bug and test

from esbuild-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.