Ckeditor5: Configuration of ckeditor5-dev-* packages

Created on 9 Aug 2016  路  4Comments  路  Source: ckeditor/ckeditor5

As @pjasiun pointed out, providing global object to whole package isn't a good practice. There were also contradictory arguments for/against different solutions. This issue hopefully will clear things up.

Example:

const config = {
    ROOT_DIR: '.',
    IGNORED_FILES: [
        'src/lib/**'
    ]
};

const ckeditor5Lint = require( 'ckeditor5-dev-lint' )( config );

Even providing parameters separately to package is still too broad:

const ROOT_DIR = '.';
const IGNORED_FILES = [
    'src/lib/**'
];
const ckeditor5Lint = require( 'ckeditor5-dev-lint' )( ROOT_DIR, IGNORED_FILES);

I would like to discuss idea of tasks with explicit parameters:

const ROOT_DIR = '.';
const IGNORED_FILES = [
    'src/lib/**'
];
const ckeditor5Lint = require( 'ckeditor5-dev-lint' );

gulp.task( 'lint', ckeditor5Lint.lint(ROOT_DIR, IGNORED_FILES ); // Or `.bind()` etc.

Current solution is quite comfortable, but rigid. On the other hand complicating code without good reason isn't good idea. I am for something in the middle:

  • Explicit parameters to tasks, where such flexibility is needed,
  • Explicit parameters to package, where all the package's tasks are tied together logically,
  • No global config object passed blindly to every package.
discussion

Most helpful comment

docs-builder is using a complicated configuration. Do you have any idea how pass the configuration in a proper way?

I see nothing wrong in passing similar configuration to each tool, but separately.

If ckeditor5DevEnv.relink need only WORKSPACE_DIR, passing the whole config to ckeditor5DevEnv seems to be wrong.

In my external project, I use only ckeditor5DevEnv.relink. I should be able to use it, passing to it what it needs. I should not need to create a bigger configuration for the whole ckeditor5DevEnv with options I do not need if I only use ckeditor5DevEnv.relink. Of course, I can pass to ckeditor5DevEnv only options needed by relink and skip other options, but it seems to be hacky.

All 4 comments

Your examples are fine when we have simple strings as a configuration.

docs-builder is using a complicated configuration. Do you have any idea how pass the configuration in a proper way?

Sometimes I need to get a configuration based on a dynamic key. How do you want to resolve it? Perhaps a current solution isn't good, but the solution is unified between all modules which docs-builder requires.

docs-builder is using a complicated configuration. Do you have any idea how pass the configuration in a proper way?

I see nothing wrong in passing similar configuration to each tool, but separately.

If ckeditor5DevEnv.relink need only WORKSPACE_DIR, passing the whole config to ckeditor5DevEnv seems to be wrong.

In my external project, I use only ckeditor5DevEnv.relink. I should be able to use it, passing to it what it needs. I should not need to create a bigger configuration for the whole ckeditor5DevEnv with options I do not need if I only use ckeditor5DevEnv.relink. Of course, I can pass to ckeditor5DevEnv only options needed by relink and skip other options, but it seems to be hacky.

Another thing to consider: tasks like compile can use parameters passed from command line, for example:

gulp compile --formats esnext

These command-line parameters are parsed inside ckeditor5-dev-compiler. I think that this logic should be a part of a gulpfile, not compiler package itself. When some other project will define it's own tasks, it is forced to use the same command-line parameters defined there. In my opinion all information should be passed as method arguments. Decision how these parameters are passed to the gulp task ( or even if that should be possible ) is up to developer integrating our tools.

This issue got resolved somehow naturally.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MansoorJafari picture MansoorJafari  路  3Comments

hamenon picture hamenon  路  3Comments

hybridpicker picture hybridpicker  路  3Comments

oleq picture oleq  路  3Comments

metalelf0 picture metalelf0  路  3Comments