Skip to content

Conversation

@ShGKme
Copy link
Collaborator

@ShGKme ShGKme commented Oct 25, 2025

Current approach

Currently webpack-vue-config supports both Vue 2 (with vue-loader@15) and Vue 3 (with vue-loader@17) via a postinstall script.

In Vue 2 projects it replaces vue-loader@17 with required vue-loader@15 by installing it with --no-save.

In other words, there might be no vue-loader specified in package.json and an incorrect version specified in package-lock.json while everything magically works.

New approach (breaking change)

No more hidden install. In Vue 2 apps a developer MUST install the required vue-loader manually.

npm i -D vue-loader@legacy

Motivation

This postinstall is a bit hacky. It is intended since there is no other way to have conditional dependencies. For example, popular vue-demi package does something similar.

However, it doesn't work in environments where only explicitly specified in the package-lock.json dependencies are installed. For example, nixpkgs.

cc @provokateurin

Making migration simpler

postinstall script is kept only for the version checking and showing a warning.

Otherwise there is no npm ci error, and the build error might be less obvious.

image

@ShGKme ShGKme self-assigned this Oct 25, 2025
@ShGKme ShGKme added enhancement New feature or request 3. to review 💥 breaking PR that requires a new major version labels Oct 25, 2025
provokateurin
provokateurin previously approved these changes Oct 26, 2025
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
@ShGKme ShGKme force-pushed the feat/require-vue-loader branch from 07cbad2 to c2d1a2b Compare October 27, 2025 12:05
@ShGKme
Copy link
Collaborator Author

ShGKme commented Oct 27, 2025

Changes in the force-push:

  • Rebased onto main
  • Added a test for the Vue 2 + incompatible vue-loader
  • Simplified version checking (only check package.json, do not load entire Vue module)
  • In case of version check error - just skip the check

The last one change is important.

The purpose of the script is to warn in a simple way about an incompatible vue-loader version.
If something goes wrong, just skip the check (for example, nixpkgs or other unusual setups might run postinstall when dependencies are not installed as expected by npm).
In case of incompatibility, an error will be raised when using the package anyway, just less directly - with compilation errors.

cc @provokateurin

Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
@ShGKme ShGKme force-pushed the feat/require-vue-loader branch from c2d1a2b to d760682 Compare October 27, 2025 12:09
@ShGKme
Copy link
Collaborator Author

ShGKme commented Oct 27, 2025

  • Added the new test files to REUSE

@ShGKme ShGKme requested a review from provokateurin October 27, 2025 12:09
@ShGKme ShGKme mentioned this pull request Oct 27, 2025
@ShGKme ShGKme requested a review from DorraJaouad October 31, 2025 16:10
@ShGKme
Copy link
Collaborator Author

ShGKme commented Oct 31, 2025

@DorraJaouad Also adding you as it is kind of a security issue. Currently vue-loader and its dependencies may not be listed in the package-lock file at all. This PR makes it required via a small breaking change.

@ShGKme ShGKme merged commit 672ee12 into main Nov 3, 2025
6 checks passed
@ShGKme ShGKme deleted the feat/require-vue-loader branch November 3, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review 💥 breaking PR that requires a new major version enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants