nuxt-esbuild-module icon indicating copy to clipboard operation
nuxt-esbuild-module copied to clipboard

Mistake in loaders order

Open Standoffru opened this issue 1 year ago • 0 comments

According to the documentation https://webpack.js.org/concepts/loaders/#configuration:

Loaders are evaluated/executed from right to left

We need to change the loaders applying order for production build by first using esbuild-loader and then babel-loader, using the unshift method instead of push. Here's an example of the code:

if (!this.options.dev && options.loader === 'ts') {
  config.module.rules[jsxRuleIndex].use.unshift(...originalUse)
}

If ts-loader and typescript-build package is not used in the nuxt build, babel-loader is executed first, and then esbuild-loader, and ts transpilation does not occur.

Standoffru avatar May 24 '23 06:05 Standoffru