nuxt-esbuild-module
nuxt-esbuild-module copied to clipboard
Mistake in loaders order
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.