-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Build fails with webpack 4 #7083
Comments
This looks bad as we need some context being shared through loader and plugin. I'll look at |
BTW, if possible, it'd be good if the new version of our plugin worked with Webpack3 and Webpack4. |
@Reinmar while admirable, I'm not sure it's entirely necessary - the new version ts-loader (Typescript loader) is incompatible with webpack 4. I'm not sure how much work you're still doing to this loader (i.e. new features), so maintaining webpack 3 compatibility might not be worth it. I'd release a new major version with webpack 4 compatibility and have people stay on the current version for webpack 3. Just my 2c |
I've found a workaround and maybe an even better solution to pass options directly to the loader, but there are few things to be done to migrate to webpack@4.
|
Let's prioritise this because it sounds like a blocking issue. Could you start from this? Let's at least know why it doesn't work and reporting it may help to learn that.
So, since W4, installing the
Based on what @flipchart and you wrote here, W4 is a pretty big release. We're right now at a point when we can do bigger changes in how our plugins are proposed but this will be harder soon, so I'd rather focus on being up to date and safe. Also, as @flipchart mentioned, backwards compatibility shouldn't be our main goal.
I think this is a really good idea. We should make the experience as smooth as possible which often means sticking to common options. We can, therefore, consider replacing babel-preset-minify with UglifyJs2, and update the configuration in general. |
I'll try to reproduce it on a simple and empty repo and report it.
Yes, W4 provides binaries by the Regarding the rest, I'll try to make these changes after solving the first issue. |
I've managed to port the whole CKEditorWebpackPlugin to Webapack 4. But I hit a problem with the new minifier. It breaks the editor with the image plugin. webpack --mode productionBundle size: 409 KiB Error at
Chrome points at Editor works without the image plugin. webpack --mode development + uglifyjs-webpack-plugin (UglifyJs 3 - ES) pluginBundle size: 594 KiB - long import names, maybe related to name mangling Works. webpack --mode production + Babily pluginBundle size: 407 KiB Works. webpack --mode development + Babily pluginBundle size: 422 KiB Works. |
The bug described above is introduced by UglifyJS' function inlining. It creates Changing the variable name from |
Doh, so we need to stick to babel-minify for the moment. We'll also see if this gets fixed by Uglify's team. BTW, it reminded me about the webpack-sources's issue in Webpack that we've got in the past. It's still not fixed ;/ |
Oh, I forgot to write about it. Changing minifier fixes that issue, so in that case the problem is with the |
So, we go with UglifyJS2 and then we have the inlining issue or with Babel minify and then we have to add the webpack-sources hack? How lovely ;> BTW, did you check with the latest babel-preset-minify (see webpack-contrib/babel-minify-webpack-plugin#68 (comment))? Could you check it and comment under that issue if it's still occuring? |
Yess
I'll check it, but I'm not an optimist in that case 😄 Update: It doesn't work. |
Upstream ticket for UglifyJS2: mishoo/UglifyJS#2842 |
I was able to get it working by replacing optimization: {
minimizer: [
new UglifyJsWebpackPlugin( {
sourceMap: true,
uglifyOptions: {
compress: {
// Prevents inlining functions with arguments and variables.
inline: 2
}
}
} )
]
}, With that optimization, it works with |
There're 3 warnings visible during the building process complaining asset size, entry point size, and potential performance issues (e.g. 244KiB is the maximum size for assets). We can update these sizes to hide warnings, leave these warnings as they are or turn them off. More info: https://webpack.js.org/configuration/performance/ |
I've seen that https://github.com/webpack-contrib/extract-text-webpack-plugin, which is used by the snippet adapter is not production ready at version 4, which supports webpack@4 plugin API. It's now at the beta stage and still has some issues like webpack-contrib/extract-text-webpack-plugin#731 in the production mode. 😞 |
Not only production mode, but also development mode 😞 |
In our case somehow it works in the But it's something I wanted to avoid - having different minifiers and unstable packages. |
Yeah... I'm surprised by the turn of events. Unlike npm for instance, webpack releases were fully functional so far. Now, we're given buggy UglifyJs2 and ecosystem which didn't catch up yet. I'm even ok with and understand the latter, but pushing UglifyJs2 as a default, without testing it thoroughly is an odd choice. I'm afraid that the right thing to do now will be waiting. Let's just stick to webpack 3 and the current setup for the time being and see in ~1 month time. After all, we'll be back on schedule with frequent releases after this beta. |
To clarify things a bit, I've chosen |
https://twitter.com/wSokra/status/970253245733113856
|
I'm not sure about it. It seems to be a different plugin though.
While we want to generate only one CSS file. |
Hey folks 👋 Webpack core-team member here. I’ll be glad to assist you for this migration. Please let me know if you need assistance or advice. |
Hi Florent! We'll get back to this topic soon and let you know if we have any problems. Thanks! |
I was wrong about it. I've just replaced |
For webpack 4, if you want to extract CSS you must use |
And I've added the webpack@4 as a peer dependency for |
Reminder for myself – in order to finalise this task, we'll also have to update these two docs:
I had to update them recently to mention that we don't support w4 yet. |
Could you explain how it helps us? Am I right that if someone installed |
PS. Am I right that we're still waiting for mishoo/UglifyJS#2842? |
Yep.
No, providing option |
I'm trying to understand one thing here... Quote by @alexlamsl:
I thought that webpack 4 uses uglify-es because only this version of uglify supports ES6 (at least that's how I understood it). But you wrote previously, @ma2ciek, that webpack 4's production mode uses UglifyJs2, which, according to https://github.com/mishoo/UglifyJS2, only supports ES5. So, I'm lost here. How does webpack 4 treat CKEditor 5's code (which is ES6) in production mode by default? With which minifier? |
Webpack4 uses https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/package.json, which uses |
So... webpack 4 promotes @ooflorent, is webpack team aware of this? I see that both issues – the specific bug (webpack-contrib/uglifyjs-webpack-plugin#264) and uglify-es not being maintained (webpack-contrib/uglifyjs-webpack-plugin#262) are tracked on your side, but there's no decision yet. |
@Reinmar The webpack team is aware of this situation. Even if In webpack it is possible to choose which minifiers are applied using @evilebottnawi @michael-ciniawsky What are your thoughts about this? |
I left a comment in webpack-contrib/uglifyjs-webpack-plugin#262. I guess, the topic is clear on our side – we'll need to figure out whether to use Thanks! |
@ooflorent I think we should migrate on |
@ma2ciek, there's a patch on review for uglifyjs-webpack-plugin: webpack-contrib/uglifyjs-webpack-plugin#264 (comment) Could you test it? |
After a trouble with Lerna and rebasing old branches, I've cloned the It looks like it's working, I've been able to remove the |
BTW, what do you think about adding webpack as a peerDep of our webpack plugin? Is this common? |
Yes, it is. Look at these examples that came to my mind first:
|
Cool, so let's do that together with an upgrade to w4. |
As I see, the webpack-contrib/uglifyjs-webpack-plugin#308 is merged, I checked our manual tests and they work fine with |
One of the comments I wrote in the PR: After a couple of deep breaths, I'm for extending This way, we'll simplify maintaining configurations. We'll be able to get rid of this: new webpack.BannerPlugin( {
banner: bundler.getLicenseBanner(),
raw: true
} ), And will be able to avoid adding this: new UglifyJsWebpackPlugin( {
sourceMap: true,
uglifyOptions: {
output: {
comments: /^\**!/
}
}
} ) So,
Additionally, we may need to rethink configuration because it will get crowded: new CKEditorWebpackPlugin( {
// Main language that will be built into the main bundle.
language: 'en',
// Additional languages that will be emitted to the `outputDirectory`.
// This option can be set to an array of language codes or `'all'` to build all found languages.
// The bundle is optimized for one language when this option is omitted.
additionalLanguages: 'all',
// Optional directory for emitted translations. Relative to the webpack's output.
// Defaults to `'translations'`.
// outputDirectory: 'ckeditor5-translations',
// Whether the build process should fail if an error occurs.
// Defaults to `false`.
// strict: true,
// Whether to log all warnings to the console.
// Defaults to `false`.
// verbose: true
} ), |
cc @pjasiun |
There's only one complication. Adding custom header we'd have to filter assets and add banner only to the EDIT: I can filter them by checking if an asset has corresponding chunks, so it's not a huge problem. |
I am fine with Also, for the internal usage, I am fine with what we have now ( On the other hand, we should not have such code in the documentation for build CKEditor 5. The question is, if we want to have a baner in the editor build based on the documentation. |
The I'd name the option just |
I rather meant other options. Because a group of them are language-oriented – Anyway, right now I'm having second thoughts about this change. I'm not sure whether it's better to complicate this plugin or the builds' webpack configs. Let's get back to this on Monday... |
I've checked the dedicated
Other than that it works well. |
Other: Updated `CKEditorWebpackPlugin` and related tools to support `webpack@4`. Closes #371. BREAKING CHANGES: This package requires `webpack@4`.
I'm facing exactly the same issue today, however, none of these advices work for me, at last, I try to separate ckeditor from uglify during webpack, here is my solution. Hope it may help someone else: Views/Home/Index.cshtml | 1 +
webpack.config.js | 4 ++++
webpack.config.vendor.js | 7 +++++--
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Views/Home/Index.cshtml b/Views/Home/Index.cshtml
index 3216059..611bd5f 100644
--- a/Views/Home/Index.cshtml
+++ b/Views/Home/Index.cshtml
@@ -39,6 +39,7 @@
GLOBAL_API_BASE_URL = "@ViewBag.ApiBaseUrl";
</script>
<script src="~/dist/vendor.js" asp-append-version="true"></script>
+<script src="~/dist/ckeditor.js" asp-append-version="true"></script>
@section scripts {
<script src="~/dist/main-client.js" asp-append-version="true"></script>
}
diff --git a/webpack.config.js b/webpack.config.js
index b3960c8..4cb1083 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -35,6 +35,10 @@ module.exports = (env) => {
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
+ }),
+ new webpack.DllReferencePlugin({
+ context: __dirname,
+ manifest: require('./wwwroot/dist/ckeditor-manifest.json')
})
].concat(isDevBuild ? [
// Plugins that apply in development builds only
diff --git a/webpack.config.vendor.js b/webpack.config.vendor.js
index e3ea98f..c9f36e4 100644
--- a/webpack.config.vendor.js
+++ b/webpack.config.vendor.js
@@ -50,8 +50,11 @@ module.exports = (env) => {
'font-awesome/css/font-awesome.css',
'angular2-lightbox/lightbox.css',
'angular2-lightbox/index.js',
- '@ckeditor/ckeditor5-build-classic/build/translations/zh-cn.js',
'./src/styles-external.css'
+ ],
+ 'ckeditor': [
+ '@ckeditor/ckeditor5-build-classic/build/translations/zh-cn.js',
+ '@ckeditor/ckeditor5-build-classic/build/ckeditor.js'
]
},
output: {
@@ -81,7 +84,7 @@ module.exports = (env) => {
name: '[name]_[hash]'
})
].concat(isDevBuild ? [] : [
- new webpack.optimize.UglifyJsPlugin()
+ new webpack.optimize.UglifyJsPlugin({ exclude: 'ckeditor' })
])
}); |
Upgraded my (working) project from webpack 3 to webpack 4, and the build now fails with the below error:
Looks like it's due to using the deprecated
this.options
value. See webpack 4 migration guideThe text was updated successfully, but these errors were encountered: