Description
Version
15.0.0
Reproduction link
https://github.com/killerDJO/vue-loader-minimal
Steps to reproduce
Prererquisites:
- ts-loader is used and has options specified (Important!).
- SFC with referenced TypeScript file is used.
Run webpack build using mentioned configuration. Rules might look like this:
module: {
rules: [
{
test: /\.ts$/,
loader: "ts-loader",
options: {},
exclude: [/node_modules/]
},
{
test: /\.vue$/,
loader: "vue-loader",
}
]
},
resolve: {
extensions: [".ts"],
},
plugins: [
new VueLoaderPlugin()
],
What is expected?
Build is finished successfully.
What is actually happening?
Build failed.
In the current implementation VueLoaderPlugin clones webpack rules and modifies them to run on .vue files. However, this leads to an issues when a file is referenced from .vue component (e. g. <script src="./App.ts" lang="ts"></script>
). In this case the file can be matched by two rules (original and cloned) and ts-loader will be executed two times, with second time executing using output of the first run.
This will happend only if "options" object is specified, because otherwise webpack will use a single loader for two rules (VueLoaderPlugin removes "options" during rules cloning, so only original rule will have options).
Aforementioned behaviour has been observed for ts-loader, but is likely to occur for scss/sass loaders as well.