All jobs

Fix "vue-loader was used without the corresponding plugin" After Upgrading to vue-loader 15

Yes. An agent reproduces the vue-loader 15 error on your webpack 4 config, adds VueLoaderPlugin, checks the compiler pin and rebuilds until the bundle is emitted.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

vue-loader 15 needs a plugin that 14 did not. The loader still handles .vue files, but it now splits each file into a template, script and style request and relies on VueLoaderPlugin to route those requests back through the config's own rules. Without it the build prints Module Error (from ./node_modules/vue-loader/lib/index.js): vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config. for the first component, and then one Module parse failed: Unexpected token (2:0) per component for requests like App.vue?vue&type=template&id=7d9c756f, because the template HTML reached webpack with no loader to turn it into a render function.

In a Vue 2 app like cornflourblue/vue-vuex-registration-login-example, package.json asks for vue ^2.6.10, vue-router ^3.1.3, vuex ^3.1.2 and vee-validate ^2.2.8, with vue-loader ^14.2.3, vue-template-compiler ^2.6.10, webpack ^4.41.2, webpack-cli ^3.3.10, babel-loader ^7.1.5 on Babel 6 and html-webpack-plugin ^3.2.0 as dev dependencies, and npm run build is webpack --mode production. webpack.config.js has two rules, /\.vue?$/ to vue-loader and /\.js?$/ to babel-loader, one plugin, HtmlWebpackPlugin on src/index.html, and an externals entry that inlines the API URL. The components are src/app/App.vue, src/home/HomePage.vue and the login and register pages, backed by a fake backend in src/_helpers.

The agent builds the project as it stands first, which on a current Node needs NODE_OPTIONS=--openssl-legacy-provider for webpack 4; with vue-loader 14 the build emits main.js and the HTML plugin's child compilation. Then it installs vue-loader@15 and runs the same command: webpack 4.41.2 reports the plugin error on App.vue, imported from src/index.js at line 15, and the parse failures for the template requests of App.vue and HomePage.vue. It also checks the compiler pair, since vue-loader 15 refuses a vue-template-compiler whose version differs from vue; here both resolve to 2.6.11, so that check passes and is noted rather than fixed.

The change is two lines in the config: const { VueLoaderPlugin } = require('vue-loader') beside the existing HtmlWebpackPlugin require, and new VueLoaderPlugin() in the plugins array. The rebuilt output emits main.js at about 249 KiB with the HTML plugin's child compilation and no errors. The agent keeps the dev dependency at ^15 in package.json, since 15 is the last line for Vue 2, and writes the pull request with both build outputs, the compiler pair it checked, and a note on what the ?vue&type=template requests in the error mean, because the parse failures are the part people search for after fixing the first message.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "This Vue 2 project's build fails with vue-loader was used without the corresponding plugin, after vue-loader was upgraded to 15. Install the dependencies as declared and build once; if webpack 4 needs NODE_OPTIONS=--openssl-legacy-provider on the current Node, say so and use it for every build. Install vue-loader 15, build again and capture the plugin error and every Module parse failed line with the request it names. Check that vue and vue-template-compiler resolve to the same version and report both. Add VueLoaderPlugin from vue-loader to the plugins array in webpack.config.js, changing nothing else in the config, and rebuild until the bundle is emitted with no errors. Keep the vue-loader range at 15, since this is a Vue 2 app. Open a pull request with the config change, both build outputs and the compiler versions.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

A pull request that changes webpack.config.js and, if the range was not already on 15, package.json with its lockfile. The description opens with the failing build: the plugin error naming the first component and the parse failures with the ?vue&type=template requests they came from, so a reader who only saw the second message recognises it. The passing build follows, with the emitted asset and its size.

The session's record keeps both npm install runs with their resolved versions, each build command with its environment variable, and the npm ls output for vue and vue-template-compiler. A reviewer who wants to see the bundle reads the emitted asset list from the transcript.

Before merging, a reviewer checks that the dev server config in the same file still works with the plugin added, that CI sets the same NODE_OPTIONS if it runs webpack 4 on Node 17 or later, and whether vue-template-compiler should be pinned to the exact vue version so the pair cannot drift apart on the next install.

Run it on every Dependabot pull request for vue-loader

The break comes with a dependency bump, so the useful moment is the bump itself. A bot sender never fires an automation's github trigger, so give the automation a webhook trigger and add a workflow step on the bump that runs when its title names vue-loader and posts the pull request number to the trigger's URL with Authorization: Bearer and the trigger's secret; the event lands after the prompt, and the run adds the plugin against the release in that pull request's lockfile and pushes the fix onto the same branch or opens its own.

From your own server the same request goes to POST /o/{org}/sessions with the repository in resources. Give it a request_id that is a UUID v5 of the pull request number, so a retried delivery returns the run that already started instead of opening a second pull request.

The use case this job follows, with its automation and trigger: Fix a bug from an alert.

Why run it on Rush?

The fix is two lines and the confidence comes from the builds around it: one on the old loader, one failing on the new, one passing after the plugin, each on a Node release webpack 4 predates, plus the compiler-pair check that would otherwise fail next. In a Rush sandbox the agent runs all four on its own disk and keeps the output, and the machine is gone when the run ends.

What comes back is checkable rather than claimed: the transcript holds the error with its component and request names, the resolved versions and the emitted bundle. A team with several Vue 2 apps on the same template starts one run per repository with the same request, up to the key's max_concurrent limit at once, and the rest queue.

Frequently asked questions

I added the plugin and still see Module parse failed. Why?

The parse failures are the same problem seen from the other side: without the plugin, the ?vue&type=template requests that vue-loader 15 creates have no loader, so webpack reads raw HTML and stops at the first tag. Once VueLoaderPlugin is in plugins those requests go through the .vue rule again and the failures disappear with the first error; if they persist, the plugin was added to the wrong config file or the dev server uses a different one.

Do I need to change the loader rule itself?

No. The test: /\.vue?$/ rule with use: 'vue-loader' stays as it is. The plugin clones the config's other rules, which is how the template and script blocks reach the HTML and Babel loaders without new rules.

What does the vue-template-compiler check mean?

vue-loader 15 compiles templates with vue-template-compiler and refuses to run when its version differs from vue, since the runtime and the compiler must match. The agent prints both versions; in the example both are 2.6.11. If they differ, pinning the compiler to the exact Vue version is the fix.

Why keep vue-loader on 15 rather than the newest release?

Because this is a Vue 2 project. vue-loader 15 is the line that serves Vue 2 with vue-template-compiler; later majors target Vue 3. The pull request keeps the ^15 range and says so, so the next dependency bump does not pull a loader the app cannot use.

More jobs like this: Fix a bug from an alert

Keep reading