styleguidist / mini-html-webpack-plugin

A miniature version of html-webpack-plugin with only necessary features
https://www.npmjs.com/package/mini-html-webpack-plugin
MIT License
57 stars 3 forks source link

Use webpack 5 API #40

Closed bebraw closed 4 years ago

bebraw commented 4 years ago

It looks like we're getting the following warning against webpack 5:

(node:52989) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
    Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
    Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.

Here's a related comment: https://github.com/webpack/webpack/issues/11425#issuecomment-686606318 .

sapegin commented 4 years ago

Will this be compatible with webpack 4?

bebraw commented 4 years ago

@sapegin I think we'll have to do a check against webpack version and do another code path for this as likely the APIs haven't been backported to 4. I can give it a quick go.

sapegin commented 4 years ago

Ah, that's fine too!

bebraw commented 4 years ago

Since we're using TypeScript, it looks more complex than that as the newest typings don't support webpack 4 APIs anymore and we would have to find some way to remedy that.

Perhaps the best thing to do is to refactor the package to use webpack 5 and the publish that as a new major version? That would avoid complications.

sapegin commented 4 years ago

That wouldn't work, in Styleguidist we need to support several versions of webpack if it's possible.

We could disable type checking for the webpack 4 branch. It's a hack but what we're doing here is a hack ;-)

bebraw commented 4 years ago

Yeah, I see. There's a potential solution. If we maintain webpack 4/5 versions side by side and resolve at package index.js, that could work while having specific types. It takes a bit of thinking on the TS config but likely it's doable.

sapegin commented 4 years ago

Are changes that big to actually worry about it? ;-)

bebraw commented 4 years ago

The API changes in webpack 5 are massive and it seems to have a big impact on the code although there fortunately isn't a lot of it.

sapegin commented 4 years ago

Then splitting into separate files might be a good idea!

bebraw commented 4 years ago

I've made a bit more progress - it looks like we might get away with a @tsignore.