unjs / unplugin

Unified plugin system for Vite, Rollup, Webpack, esbuild, Rolldown, and more

Home Page:https://unplugin.unjs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transform failed in Webpack 5 production mode with vue-loader and babel-loader

sxzz opened this issue · comments

When working with vue-loader and babel-loader, the transforms fail. And only in production mode.
Related issue: vue-macros/vue-macros#23

this._compiler? $unpluginContext is undefined, it seems there is no inject to compiler?
image

Since I am in unfamiliar with webpack plugin development, I guess it might be a problem with the inject here.
image

Here is reproduction: https://github.com/sxzz/unplugin-issue
Please run nr build && nr preview

https://github.com/sxzz/unplugin-issue/blob/3ab41951cb179cd11bef2473a77f3686c4ca4744/vue.config.js#L8
Removes babel-loader and then unplugin works

sxzz/unplugin-vue-macros#23 (comment)

I met this issue too, and for me there is nothing to do with thread-loader, I turned it off and the error still.

After some investigation, found a local file which contains only constant definitions lead to this error, so weird.

It turns out to be worker-loader, replace it with new Worker() upon Webpack5 solve this issue.