node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org »

@ckeditor/ckeditor5-dev-compiler

CKEditor 5 Compiler

npm version Build Status Test Coverage Code Climate Dependency Status devDependency Status

Tasks used to compile CKEditor 5. More information about the project can be found at the following URL: https://github.com/ckeditor/ckeditor5-dev-compiler.

Usage

npm i --save-dev @ckeditor/ckeditor5-dev-compiler

There are two ways to use the compiler. Either through Gulp:

gulpfile.js:

const path = require( 'path' );
const gulp = require( 'gulp' );
const compiler = require( '@ckeditor/ckeditor5-dev-compiler' );
 
// Options for compiler.tasks.compile() are desrcibed in lib/compiler/index.js. 
gulp.task( 'compile', () => {
    // Use an util to get all paths to CKEditor 5 dependencies. Returns an array. 
    let packagePaths = compiler.utils.getPackages( '.' );
 
    // Add custom packages. 
    packagePaths.push( '../some/dir/ckeditor5-my-package' );
    packagePaths.push( '/home/user/ckeditor5-my-other-package' );
 
    // Or define all paths manually. 
    // Note: package directory name must start with `ckeditor5-*`. 
    packagePaths = [
        './node_modules/ckeditor5-typing',
        '../some/dir/ckeditor5-my-package',
        '/home/user/ckeditor5-my-other-package'
    ];
 
    // Compiler.compile returns a Promise. 
    return compiler.tasks.compile( {
            formats: {
                amd: './build/amd',
                cjs: './build/cjs',
                esnext: './esnext'
            },
            packages: packagePaths,
            watch: true, // Whether to watch the files. 
            es5: false,  // Whether to transpile code to ES5 format. 
            ignoreDuplicates: false, // Whether to throw an error when packages are duplicated. 
            verbosity: 'info' // A level of the verbosity for logger. 
        } );
} );

or, use the script:

$ node_modules/.bin/ckeditor5-dev-compiler \
    --config=path/to/config.json \
    --watch \
    --es5 \
    --formats=esnext,amd,cjs

The --config option is required and it should be a path to the config file which contains the following fields:

  • formats – An object containing output paths for each supported format,
  • packages – An array containing paths to CKEditor 5 packages.

Example configuration:

{
    "formats": {
        "amd": "./build/amd",
        "cjs": "./build/cjs",
        "esnext": "./build/esnext"
    },
    "packages": [
        "./node_modules/ckeditor5-typing",
        "../some/dir/ckeditor5-my-package",
        "/home/user/ckeditor5-my-other-package"
    ]
}

By default compiler throws an error when there are duplicates in the given package list. You can ignore this error using the --ignore-duplicates option. Duplicated packages may occur if there are conflicts in requested versions of a single package (so npm installed it more than once) or when one of the packages is installed in the development mode (as a cloned repository). Note: package names are read based on the directory names, so they must end with ckeditor5-*.

License

Licensed under the GPL, LGPL and MPL licenses, at your choice. For full details about the license, please check the LICENSE.md file.