2

I'm looking to switch from ts-loader to esbuild-loader in webpack to improve build times / watch compile times.

In our project, we use various type delceration files .d.ts to load types/interfaces etc. However running the esbuild-loader get a bunch of errors around them like....

Module not found: Error: Can't resolve '../../../../../../interfaces/some-d-ts-file' in 'some-tsx-file.tsx'

Specifically in the code complaining about this...

import { SomeInterfaces } from "../../../../../../../modules/something/interfaces";

Which is an interface.d.ts file

I believe it is due to this caveat in ESBuild ? https://esbuild.github.io/content-types/#no-type-system

Is there anyway to get around this? Does it require just removing all references to these .d.ts files ? Is there some task/compiling I can do with TS prior to esbuild-loader to fix it or some options to avoid this?

In my webpack.config.js I am loading the esbuild-loader like such...

  {
    test: /\.(ts|tsx)$/,
    loader: "esbuild-loader",
    exclude: /node_modules/,
    options: {
      target: "es6",
      loader: "tsx"
    }
  },
Carson Wood
  • 1,174
  • 3
  • 14
  • 23
  • I had same issue today, I used declarationDir field in tsconfig. I thought the problem is related to it, but it seems not. Thanks for the link, I did not know about it! – Sh Svyatoslav Nov 18 '22 at 18:02

0 Answers0