Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.

Conversation

@lobsterkatie
Copy link
Member

Two years ago, we modified the errorHandler option to take a third argument, of the type Compilation. Though the contents of the type exists in similar forms in webpack 4 and 5, in webpack 4 it's exported as compilation.Compilation, where as in webpack 5, it's exported at the top-level.

This didn't matter much until about a month ago, when #308 updated the overall options type to reflect the addition of the third argument for errorHandler. That change was released three days ago, in v 1.17.2. Because that PR used Compilation in its webpack 5/top-level form, anyone using this plugin together with webpack 4 and TS will receive the following error when they import the plugin (assuming they have skipLibCheck set to false in their TS config):

image

This fixes that by using unknown as the type instead, and updates the docstring with a note about the above. It also changes the dev dependencies for webpack and @types/webpack. Even though the new version requirements will always result in 5.x getting installed, keeping the 4.41.31 entry is a reminder to anyone reading the file that a) we should preserve compatibility with 4.x, and b) that that's the minimum 4.x version we need to worry about (see here).

Fixes #321.

@kamilogorek kamilogorek changed the title fix(types): Wwitch compilation type in error handler to unknown fix(types): Switch compilation type in error handler to unknown Oct 7, 2021
@kamilogorek kamilogorek self-requested a review October 7, 2021 13:50
@lobsterkatie lobsterkatie merged commit 5141860 into master Oct 7, 2021
@lobsterkatie lobsterkatie deleted the kmclb-use-unknown-type-for-compilation branch October 7, 2021 13:54
@rchl
Copy link
Contributor

rchl commented Oct 8, 2021

Do we actually need 4.41.31 to be set as a minimum version?
Nuxt 3 uses 4.41.30 (the latest released version even older 4.41.28) currently so that would result in two different versions and potentially issues.
https://github.com/nuxt/nuxt.js/blob/034b9901df8a304c6a97cf649a07cba7fbc55446/packages/types/package.json#L28

@kamilogorek
Copy link
Contributor

Yes, please see: #296 (comment)

@rchl
Copy link
Contributor

rchl commented Oct 8, 2021

That one only mentions 4.41.23 as a required minimum but this PR sets the minimum to 4.41.31.

@kamilogorek
Copy link
Contributor

Oh, I think we could stick with 4.41.23 then, but I see that webpack team is scraping old versions or something, as I cannot event find then anymore:
https://www.npmjs.com/package/webpack/v/4.41.23
https://www.npmjs.com/package/webpack/v/4.41.31

cc @lobsterkatie

@rchl
Copy link
Contributor

rchl commented Oct 8, 2021

It's the @types/webpack we are talking about - https://www.npmjs.com/package/@types/webpack/v/4.41.23

EDIT: Well, I guess we are talking about both but probably those don't have to be entirely in sync.
As far as Nuxt, it uses webpack ^4.46.0:
https://github.com/nuxt/nuxt.js/blob/034b9901df8a304c6a97cf649a07cba7fbc55446/packages/webpack/package.json#L51-L51

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[types] Use of webpack-5-only type breaks builds

4 participants