-
Notifications
You must be signed in to change notification settings - Fork 25
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
T/131: Introduce CKEditor 5 builds #132
Conversation
…5-dev-bundler-rollup". Removed existing util which did it and its related code.
export default class ClassicEditor extends ClassicEditorBase {} | ||
|
||
ClassicEditor.build = { | ||
plugins: [ ArticlePlugin ], |
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.
It's ArticlePreset
.
* @param {Object} config | ||
* @returns {Promise} | ||
*/ | ||
module.exports = function runWebpack( config ) { |
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.
Why do we need this module?
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.
As we talked F2F, we don't need this module. I'll remove it.
"babel-core": "^6.24.0", | ||
"babel-loader": "^6.4.0", | ||
"babel-preset-env": "^1.2.2", | ||
"babel-preset-es2015": "^6.24.0", |
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.
Don't use this (see ckeditor/ckeditor5#415).
"dependencies": { | ||
"babel-core": "^6.24.0", | ||
"babel-loader": "^6.4.0", | ||
"babel-preset-env": "^1.2.2", |
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.
Switch the code to use this preset.
|
||
output: { | ||
path: options.destinationPath, | ||
filename: 'ckeditor.es6.js', |
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.
We redefined a bit the two types of builds: ckeditor/ckeditor5#408 (comment)
* @returns {Object} | ||
*/ | ||
module.exports = function getWebpackConfig( options ) { | ||
const config = getWebpackES6Config( options ); |
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.
I don't like that one config is an extension of the other one because it's not. See that you're overriding the plugins
property, so it's not an inheritance and it shouldn't be implemented here as such.
E.g. what if the ES6 config will require more plugins? You don't know if you need to override just Babili or all of them.
So, let's KISS here and just duplicate the config object twice. After all – "Duplication is easier to fix than broken abstraction"
|
||
resolveLoader: { | ||
modules: [ | ||
path.join( options.cwd, 'node_modules' ) |
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.
I don't think this is needed. Or at least – it should not be needed.
"babel-loader": "^6.4.0", | ||
"babel-preset-env": "^1.2.2", | ||
"babel-preset-es2015": "^6.24.0", | ||
"babili-webpack-plugin": "0.0.11", |
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 ^
.
const plugins = getPlugins( options.plugins ); | ||
|
||
let content = `/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. |
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.
Don't hardcode 2017.
* @param {Object} config | ||
* @returns {String} | ||
*/ | ||
module.exports = function getEditorConfig( config ) { |
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.
What is this function doing?
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.
It makes string from specified config. I understand you are talking about missing JSDoc.
* @param {Array.<String>} pluginPaths | ||
* @returns {Object} | ||
*/ | ||
module.exports = function getPlugins( pluginPaths ) { |
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.
What is this function doing?
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.
Missing JSDoc, right?
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.
I'm afraid it's not only that. But I'll wait for the docs to verify this ;)
… 'dev-webpack-utils'.
Read more: webpack/webpack#3929.
No, it isn't ready. I forgot to implement ckeditor/ckeditor5#408 (comment) (and comments below). |
Ok, should be fine. |
… "ckeditor5-dev-webpack-utils".
} ); | ||
|
||
const expectedEntryFile = `/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. |
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.
Imagine it's January 1, 2018 ;)
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.
Sure :D
Will fix it.
🍆 |
I noticed that you've moved Webpack plugin to the new package. I'd keep it in the old one. It'll be used far more often and by far more developers than the utils, so let's expose it better. |
@Reinmar, ready to review once again. |
…enamed as "dev-webpack-utils". File: packages/ckeditor5-dev-tests/package.json. This reverts commit 6747044.
* @param {Object} config | ||
* @returns {String} | ||
*/ | ||
module.exports = function getEditorConfig( config ) { |
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.
This isn't very safe, unfortunately. E.g. every "
character will be replaced with '
which certainly isn't correct.
Therefore, let's do the simplest possible thing now – output a JSON string to the entry file and parse it there. The entry file should look like this:
const config = JSON.parse( '...' );
Or, to keep the config more readable in the entry file:
const config = JSON.parse(
`{
"foo": "bar"
}`
);
Ooor... we can keep the editor config in a separate file (editor-config.js
) – next to ckeditor.js
and simply import it. Then, we won't need to stringify anything. You could check this option first.
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.
Will check it. Thanks for the idea.
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.
Since the config will be a separate file, the createEntryPoint()
function could get its path as an argument.
|
||
pluginPaths.forEach( ( pathToFile ) => { | ||
const basePluginName = capitalize( path.basename( pathToFile, '.js' ) ); | ||
let pluginName = basePluginName + 'Plugin'; |
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.
Something's seriously wrong in here. Why isn't this a const? Why there's a loop which uses the same variable name in the loop and then assigns a new value to it?
If this code works, then it needs to be refactored to also have any sense ;) I looked at it for 10s and don't get it which means that it's wrong :P
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.
This code has sense and works - it generates a unique name for a plugin.
If given name is already used, the next one will contain a number at the end.
Why isn't this a const?
Because: pluginName = basePluginName + ( ++i ).toString() + 'Plugin';
in the while
loop.
It means, given plugin name is already used. We need to generate new.
OTOH, maybe it is not required because plugins with the same names shouldn't exist.
I looked at it for 10s and don't get it which means that it's wrong :P
Sorry, but does not sound like a metric for me. ;/
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.
And the code is already in use - https://github.com/ckeditor/ckeditor5-dev/blob/master/packages/ckeditor5-dev-bundler-rollup/lib/utils.js#L123-L149.
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.
Sorry, but does not sound like a metric for me. ;/
Well, this is the most important metric of a good code. If it's understandable to other developers.
…function expects a path to an external editor configuration file.
… of being an option.
…ect because it was used incorrectly. Once we really turn it on we also need to add a banner with the license.
I've tried to play a bit with ckeditor5-build-classic and I realised that it's very cumbersome because there are no webpack configs there to play with. So I think that it'll be better to actually keep them in the build repos. This means that they'll be duplicated and a bit harder to maintain but the DX will be better. PS. And the thing I've been trying to check is |
Another thing I noticed is that the way how we run Webpack swallows errors... So, I'm gonna remove or simplify |
Feature: Added a util for creating an entry point for Rollup/Webpack. Introduced a new editor bundler -
ckeditor5-dev-bundler-webpack
. Closes #131.