Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
type: Major breaking change
scope:
- ckeditor5-dev-build-tools
---

Removed output path rewriting from `ckeditor5-dev-build-tools` except for package imports rewritten to `ckeditor5` and `ckeditor5-premium-features` in browser builds.

The `rewrite` JavaScript API option was removed. Imports using `ckeditor5/src/*` and `ckeditor5-collaboration/src/*` are no longer rewritten automatically.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"lint-staged": "^16.4.0",
"listr2": "^8.3.3",
"minimist": "^1.2.8",
"oxc-transform": "^0.112.0",
"semver": "^7.7.4",
"typescript": "5.5.4",
"upath": "^2.0.1",
Expand Down
12 changes: 0 additions & 12 deletions packages/ckeditor5-dev-build-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,6 @@ When using the JavaScript API, the option must be an array.

**Example value:** `external: [ 'lodash', 'moment' ]`

#### `rewrite`

**Type:** `string[]`

**Default value:** `[]`

A list of imports to rewrite in the output file. This option can be used if one of the dependencies provided in `external` has a separate build for the new install methods that should be used instead of the one used in the source code.

This option is only available for the JavaScript API.

**Example value:** `rewrite: [ 'dependency', 'dependency/dist/index.js' ]`

## Changelog

See the [`CHANGELOG.md`](https://github.com/ckeditor/ckeditor5-dev/blob/master/packages/ckeditor5-dev-bump-year/CHANGELOG.md) file.
Expand Down
22 changes: 5 additions & 17 deletions packages/ckeditor5-dev-build-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ckeditor/ckeditor5-dev-build-tools",
"version": "55.5.0",
"description": "Rollup-based tools used to build CKEditor 5 packages.",
"description": "Rolldown-based tools used to build CKEditor 5 packages.",
"keywords": [],
"author": "CKSource (http://cksource.com/)",
"license": "GPL-2.0-or-later",
Expand All @@ -27,47 +27,35 @@
"ckeditor5-dev-build-tools": "bin/build-project.js"
},
"dependencies": {
"@rollup/plugin-commonjs": "^28.0.9",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-swc": "^0.4.0",
"@rollup/plugin-terser": "^1.0.0",
"@rollup/plugin-typescript": "12.3.0",
"@rollup/pluginutils": "^5.3.0",
"@swc/core": "^1.15.24",
"cssnano": "^7.1.4",
"cssnano-preset-lite": "^4.0.4",
"es-toolkit": "^1.45.1",
"estree-walker": "^3.0.3",
"glob": "^13.0.6",
"lightningcss": "^1.32.0",
"magic-string": "^0.30.21",
"pofile": "^1.1.4",
"purgecss": "^8.0.0",
"rollup": "^4.60.1",
"rollup-plugin-svg-import": "^3.0.0",
"rolldown": "^1.0.0",
"source-map": "^0.7.6",
"upath": "^2.0.1"
},
"devDependencies": {
"@types/css": "^0.0.38",
"@types/node": "^22.19.17",
"@vitest/coverage-v8": "^4.1.2",
"rolldown": "^1.0.0",
"type-fest": "^4.41.0",
"vitest": "^4.1.2"
},
"scripts": {
"build": "rolldown -c rolldown.config.js",
"dev": "rolldown -c rolldown.config.js --watch",
"build": "rolldown -c rolldown.config.ts",
"dev": "rolldown -c rolldown.config.ts --watch",
"test": "vitest run --config vitest.config.ts",
"coverage": "vitest run --config vitest.config.ts --coverage",
"test:dev": "vitest dev"
},
"depcheckIgnore": [
"@types/css",
"@vitest/coverage-v8",
"estree",
"typescript"
"@vitest/coverage-v8"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
*/

import { defineConfig } from 'rolldown';
import { declarationFilesPlugin } from '../../scripts/plugin-declarations.js';
import { declarationFiles } from './src/plugins/declarations.js';
import pkg from './package.json' with { type: 'json' };

const packageJson = pkg as {
dependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
};

const externals = [
...Object.keys( pkg.dependencies || {} ),
...Object.keys( pkg.peerDependencies || {} )
...Object.keys( packageJson.dependencies || {} ),
...Object.keys( packageJson.peerDependencies || {} )
];

export default defineConfig( {
Expand All @@ -22,7 +27,9 @@ export default defineConfig( {
assetFileNames: '[name][extname]'
},
plugins: [
declarationFilesPlugin()
declarationFiles( {
sourceDirectory: 'src'
} )
],
external: id => externals.some( name => id.startsWith( name ) )
} );
36 changes: 19 additions & 17 deletions packages/ckeditor5-dev-build-tools/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import fs from 'node:fs';
import url from 'node:url';
import { styleText, parseArgs } from 'node:util';
import path from 'upath';
import { rollup, type RollupOutput, type GlobalsOption, type LogLevelOption } from 'rollup';
import { rolldown, type LogLevelOption, type OutputOptions, type RolldownOutput } from 'rolldown';
import { loadSourcemaps } from './plugins/loadSourcemaps.js';
import { getRollupConfig } from './config.js';
import { getRolldownConfig } from './config.js';
import { camelizeObjectKeys, removeWhitespace, getOptionalPlugin } from './utils.js';

type GlobalsOption = Record<string, string> | ( ( name: string ) => string );

export interface BuildOptions {
input: string;
output: string;
Expand All @@ -20,7 +22,6 @@ export interface BuildOptions {
globals: GlobalsOption | Array<string>;
banner: string;
external: Array<string>;
rewrite: Array<[string, string]>;
declarations: boolean;
translations: string;
sourceMap: boolean;
Expand All @@ -39,7 +40,6 @@ export const defaultOptions: BuildOptions = {
globals: {},
banner: '',
external: [],
rewrite: [],
declarations: false,
translations: '',
sourceMap: false,
Expand Down Expand Up @@ -107,20 +107,20 @@ function normalizeGlobalsParameter( globals: GlobalsOption | Array<string> ): Gl
/**
* Generates `UMD` build based on previous `ESM` build.
*/
async function generateUmdBuild( args: BuildOptions, bundle: RollupOutput ): Promise<RollupOutput> {
async function generateUmdBuild( args: BuildOptions, bundle: RolldownOutput ): Promise<RolldownOutput> {
args.input = args.output;

const { dir, name } = path.parse( args.output );
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { plugins, ...config } = await getRollupConfig( args );
const { plugins, resolve, tsconfig, transform, moduleTypes, output, ...config } = await getRolldownConfig( args );

/**
* Ignore the plugins we used for the ESM build. Instead, add a new plugin to not only
* load the source code of the dependencies (which is the default in Rollup for better
* load the source code of the dependencies (which is the default in Rolldown for better
* performance), but also their source maps to generate a proper final source map for
* the UMD bundle.
*/
const build = await rollup( {
const build = await rolldown( {
...config,
plugins: [
getOptionalPlugin(
Expand All @@ -131,9 +131,10 @@ async function generateUmdBuild( args: BuildOptions, bundle: RollupOutput ): Pro
} );

const umdBundle = await build.write( {
...( output as OutputOptions ),
format: 'umd',
file: path.join( dir, `${ name }.umd.js` ),
inlineDynamicImports: true,
codeSplitting: false,
assetFileNames: '[name][extname]',
sourcemap: args.sourceMap,
name: args.name,
Expand All @@ -148,7 +149,7 @@ async function generateUmdBuild( args: BuildOptions, bundle: RollupOutput ): Pro
...bundle.output,
...umdBundle.output
]
};
} as unknown as RolldownOutput;
}

/**
Expand Down Expand Up @@ -196,7 +197,7 @@ async function normalizeOptions( options: Partial<BuildOptions> ): Promise<Build
*/
export async function build(
options: Partial<BuildOptions> = getCliArguments()
): Promise<RollupOutput> {
): Promise<RolldownOutput> {
try {
const args: BuildOptions = await normalizeOptions( options );

Expand All @@ -210,22 +211,23 @@ export async function build(
}

/**
* Create Rollup configuration based on provided arguments.
* Create Rolldown configuration based on provided arguments.
*/
const config = await getRollupConfig( args );
const { output, ...config } = await getRolldownConfig( args );

/**
* Run Rollup to generate bundles.
* Run Rolldown to generate bundles.
*/
const build = await rollup( config );
const build = await rolldown( config );

/**
* Write bundles to the filesystem.
*/
const bundle = await build.write( {
...( output as OutputOptions ),
format: 'esm',
file: args.output,
inlineDynamicImports: true,
codeSplitting: false,
assetFileNames: '[name][extname]',
sourcemap: args.sourceMap,
name: args.name
Expand All @@ -242,7 +244,7 @@ export async function build(
} catch ( error: any ) {
let message: string;

if ( error.name === 'RollupError' ) {
if ( error.id ) {
message = `
${ styleText( 'red', 'ERROR: Error occurred when processing the file ' + error.id ) }.
${ error.message }
Expand Down
Loading