-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Webpack v4.0.0-alpha support #823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/compiler.js
Outdated
hash: childCompilation.hash, | ||
chunk: entries[0] | ||
}) | ||
: compilation.mainTemplate.hooks.assetPath.call(outputOptions.filename, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use compilation.mainTemplate.getAssetPath
instead
index.js
Outdated
@@ -71,7 +85,12 @@ HtmlWebpackPlugin.prototype.apply = function (compiler) { | |||
// Sort chunks | |||
chunks = self.sortChunks(chunks, self.options.chunksSortMode); | |||
// Let plugins alter the chunks and the chunk sorting | |||
chunks = compilation.applyPluginsWaterfall('html-webpack-plugin-alter-chunks', chunks, { plugin: self }); | |||
if (compilation.applyPluginsWaterfall) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverse the order here: Try new API first, fallback to old API
index.js
Outdated
@@ -313,7 +332,12 @@ HtmlWebpackPlugin.prototype.addFileToAssets = function (filename, compilation) { | |||
}) | |||
.then(function (results) { | |||
var basename = path.basename(filename); | |||
compilation.fileDependencies.push(filename); | |||
if (compilation.fileDependencies.push) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverse the order here: Try new API first, fallback to old API
index.js
Outdated
return _.extend(pluginArgs, result); | ||
}); | ||
}; | ||
if (compilation.applyPluginsAsyncWaterfall) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverse the order here: Try new API first, fallback to old API
going to see if there's a better way to view the diffs for fixture tests. the current output is not easy to tell what's wrong. 😕 All of the tests now pass on my machine, but there's a couple still failing in travis. |
But don't test webpack 4 on old node versions since it now requires 6 or later.
webpack 4 drops the 'loaders' key on the config
webpack has a completely new plugin interface. See changes to wepack/tapable for in-depth.
In the future the file-loader should move away from loadContext.options and this would not be needed.
Webpack 4 now requires either 'production', 'development', or 'none'.
The new method with AsyncSeriesWaterfallHook already merges the initial value with the result so there's no need to worry about the result not being defined.
Recompiling and caching only really makes sense for development builds.
toposort is non-deterministic when there's a tie. Needed to allow for either result in the test. This happens when A and B both depend on C, dependency graph looks like: A / C \ B Ideally we could pass a tie breaker sort function to toposort to fix this.
Previously was just doing a strait string compare which was very hard to tell what the differences causing the failing were.
Rebased to clean up the commits. Included the changes suggested from @sokra, thanks for the review. Tests all pass now 🎉 , However I've made some assumptions which I'd like feedback on. I think the caching tests only make sense for I think The basic tests I think should be run for both modes but I'm not sure. |
Thank you for the PR. I just tried it against the webpack v4 alpha in a small example and it worked without problems. ✌️ Just got one deprecation warning:
|
minification is now on by default for production mode.
This good to go. The deprecation warnings can be fixed in a separate PR. As it is this PR as it is enables compatibility with webpack-4.0.0-alpha.4. cc @jantimon @TheLarkInn |
Travis is timing out on network requests, going to push again to trigger build |
So... merge? |
Are there any ETAs on this getting released as an alpha/next/beta? |
Note that this plugin breaks with Not sure when I'll have a chance to look at that, but if someone else wants to work on it, could probably build on top of this branch. |
Update: currently jantimon is in Asia for work right now until first week of March. We've forked html-webpack-plugin for now to have the PR sent against there just to ensure people can actually have a chance to test and use this package prior to v4 Would someone like to take the PR and revase against webpack-contrib/html-webpack-plugin ? |
Some of the tests also are checking for commonschunk, which no longer exists. |
Continuing this PR over at https://github.com/webpack-contrib/html-webpack-plugin/pull/3 |
webpack-4.0.0-alpha.5 introduced a large refactor to chunks. This is a corresponding update to handle the new structure. This change introduces an API change to `chunksorter.dependency`. It now requires an additional parameter `chunkGroups` that is available from the compilation object. To read more about the CommonsChunkPlugin changes see: - webpack/webpack#6357 - https://gist.github.com/sokra/1522d586b8e5c0f5072d7565c2bee693
Tests were green before this so can have higher confidence in this change.
Wanted to update the test fixtures to not use minification, but needed to go back to a stable state to do that.
Appear to all be internal webpack changes. It is a bit painful to review. Certain parts may be easier to see the changes by using the --word-diff-regex flag. Example: git diff --word-diff-regex=[^[:space:]\"\)]+
Need a webpack 4 compatible version.
Perf improvement. Using getParents() causes a full iteration over the parents Set to get an array. Then using map() is a second iteration over the resulting array. By using Array.from(iterable, mapFn) we only iterate once over the internal data structure of parents.
After installing the changes from
I still get the following error
Manage to resolve this error by installing the latest tapable v1.0.0 |
Any updates on this? |
via: https://medium.com/webpack/webpack-4-released-today-6cdb994702d4 |
@niemyjski This PR works I tried & you can install it like that on the Medium article or like this |
Merged - ty so much @Graham42 |
realeasing something? |
Just do Its been released on npm |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This is
a rough go atthe code to make tests pass for supporting [email protected].I'm not sure that this can be merged with out major version bump since webpack now requires node version >=6 and html-webpack-plugin currently still supports 4 and 5.Edit: This is actually probably fine, if people are using webpack the intersection of supported node versions is >=6, I don't see a need to change the required node version for this plugin.
Status as of
[email protected]
: