Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ck/epic/melman
Browse files Browse the repository at this point in the history
  • Loading branch information
mmotyczynska committed Aug 7, 2024
2 parents ce92bfc + d42283d commit 028f5c2
Show file tree
Hide file tree
Showing 21 changed files with 161 additions and 66 deletions.
82 changes: 50 additions & 32 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
Changelog
=========

## [42.0.0](https://github.com/ckeditor/ckeditor5-dev/compare/v41.0.0...v42.0.0) (2024-07-29)

We are excited to announce a new major release of the `@ckeditor/ckeditor5-dev-*` packages.

### Release highlights

This release brings the updated configuration for the build tools. As it might produce output incompatible with the previous settings, this release is marked as a major bump.

The [`@ckeditor/ckeditor5-dev-build-tools`](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-build-tools) package now supports a new `globals` option, which allows passing pairs of external package names and associated global variables used in the `umd` build.

Additionally, the global names for the `ckeditor5` and `ckeditor5-premium-features` packages in the UMD builds have been changed to `CKEDITOR` and `CKEDITOR_PREMIUM_FEATURES` respectively.

### MAJOR BREAKING CHANGES [ℹ️](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/versioning-policy.html#major-and-minor-breaking-changes)

* **[build-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-build-tools)**: The global names for the `ckeditor5` and `ckeditor5-premium-features` packages in the UMD builds have been changed to `CKEDITOR` and `CKEDITOR_PREMIUM_FEATURES` respectively.

### MINOR BREAKING CHANGES [ℹ️](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/versioning-policy.html#major-and-minor-breaking-changes)

* **[build-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-build-tools)**: Ability to pass `globals` parameter if necessary for external imports in `umd` bundles.

### Bug fixes

* **[build-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-build-tools)**: Ability to pass `globals` parameter if necessary for external imports in `umd` bundles. See https://github.com/ckeditor/ckeditor5/issues/16798. ([commit](https://github.com/ckeditor/ckeditor5-dev/commit/74f4571f186a2cbb30a8d3fcb62475c89f59c641))

### Released packages

Check out the [Versioning policy](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/versioning-policy.html) guide for more information.

<details>
<summary>Released packages (summary)</summary>

Other releases:

* [@ckeditor/ckeditor5-dev-build-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-build-tools/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-bump-year](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-bump-year/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-ci](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-ci/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-dependency-checker](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-dependency-checker/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-docs](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-docs/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-release-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-release-tools/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-stale-bot](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-stale-bot/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-tests](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-tests/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-transifex](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-transifex/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-translations](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-translations/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-utils](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-utils/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/ckeditor5-dev-web-crawler](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-web-crawler/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/jsdoc-plugins](https://www.npmjs.com/package/@ckeditor/jsdoc-plugins/v/42.0.0): v41.0.0 => v42.0.0
* [@ckeditor/typedoc-plugins](https://www.npmjs.com/package/@ckeditor/typedoc-plugins/v/42.0.0): v41.0.0 => v42.0.0
</details>


## [41.0.0](https://github.com/ckeditor/ckeditor5-dev/compare/v40.5.0...v41.0.0) (2024-07-22)

We are excited to announce a new major release of the `@ckeditor/ckeditor5-dev-*` packages.
Expand Down Expand Up @@ -163,38 +213,6 @@ Other releases:
* [@ckeditor/typedoc-plugins](https://www.npmjs.com/package/@ckeditor/typedoc-plugins/v/40.4.0): v40.3.1 => v40.4.0
</details>


## [40.3.1](https://github.com/ckeditor/ckeditor5-dev/compare/v40.3.0...v40.3.1) (2024-07-10)

### Bug fixes

* **[build-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-build-tools)**: Preserve CSS variables used by other CSS variables when splitting styles into editor- or content-only stylesheets. Fixes [[ckeditor/ckeditor5#16689](https://github.com/ckeditor/ckeditor5/issues/16689)](https://github.com/ckeditor/ckeditor5/issues/16689). ([commit](https://github.com/ckeditor/ckeditor5-dev/commit/9481eacf673d5b291cec3f69e61a847f775a95eb))

### Released packages

Check out the [Versioning policy](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/versioning-policy.html) guide for more information.

<details>
<summary>Released packages (summary)</summary>

Other releases:

* [@ckeditor/ckeditor5-dev-build-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-build-tools/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-bump-year](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-bump-year/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-ci](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-ci/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-dependency-checker](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-dependency-checker/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-docs](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-docs/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-release-tools](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-release-tools/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-stale-bot](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-stale-bot/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-tests](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-tests/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-transifex](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-transifex/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-translations](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-translations/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-utils](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-utils/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/ckeditor5-dev-web-crawler](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-web-crawler/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/jsdoc-plugins](https://www.npmjs.com/package/@ckeditor/jsdoc-plugins/v/40.3.1): v40.3.0 => v40.3.1
* [@ckeditor/typedoc-plugins](https://www.npmjs.com/package/@ckeditor/typedoc-plugins/v/40.3.1): v40.3.0 => v40.3.1
</details>

---

To see all releases, visit the [release page](https://github.com/ckeditor/ckeditor5-dev/releases).
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "ckeditor5-dev",
"version": "41.0.0",
"version": "42.0.0",
"private": true,
"devDependencies": {
"@ckeditor/ckeditor5-dev-ci": "^41.0.0",
"@ckeditor/ckeditor5-dev-release-tools": "^41.0.0",
"@ckeditor/ckeditor5-dev-ci": "^42.0.0",
"@ckeditor/ckeditor5-dev-release-tools": "^42.0.0",
"coveralls": "^3.1.1",
"eslint": "^7.0.0",
"eslint-config-ckeditor5": "^6.0.0",
Expand Down
24 changes: 24 additions & 0 deletions packages/ckeditor5-dev-build-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,30 @@ The name of the UMD bundle. This name will be used as the global variable name w

This option is required if the `browser' option is enabled.

#### `globals` / `--globals=[moduleID:Global]`

**Type:** `{ [ name: string ]: string } | ( ( name: string ) => string )` | `string[]`

**Default value:** `{}`

Pairs of external package names and associated global variables used in the `umd` build.

The list already contains `ckeditor5` and `ckeditor5-premium-features` which are mapped to `CKEDITOR` and `CKEDITOR_PREMIUM_FEATURES`.

When using the CLI, this option can be used multiple times.

**Example value:** `--globals=external-id:variableName --globals=another-external-id:anotherVariableName`

When using the JavaScript API, the option must be an object.

**Example value:**
```js
globals: {
'external-id': 'variableName',
'another-external-id': 'anotherVariableName'
}
```

#### `external` / `--external=[path]`

**Type:** `string[]` | `string`
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-dev-build-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ckeditor/ckeditor5-dev-build-tools",
"version": "41.0.0",
"version": "42.0.0",
"description": "Rollup-based tools used to build CKEditor 5 packages.",
"keywords": [],
"author": "CKSource (http://cksource.com/)",
Expand Down
39 changes: 33 additions & 6 deletions packages/ckeditor5-dev-build-tools/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import url from 'url';
import util from 'util';
import chalk from 'chalk';
import path from 'upath';
import { rollup, type RollupOutput } from 'rollup';
import { rollup, type RollupOutput, type GlobalsOption } from 'rollup';
import { getRollupConfig } from './config.js';
import { getCwdPath, camelizeObjectKeys, removeWhitespace } from './utils.js';

Expand All @@ -17,6 +17,7 @@ export interface BuildOptions {
output: string;
tsconfig: string;
name: string;
globals: GlobalsOption | Array<string>;
banner: string;
external: Array<string>;
rewrite: Array<[string, string]>;
Expand All @@ -33,6 +34,7 @@ export const defaultOptions: BuildOptions = {
output: 'dist/index.js',
tsconfig: 'tsconfig.json',
name: '',
globals: {},
banner: '',
external: [],
rewrite: [],
Expand All @@ -44,6 +46,14 @@ export const defaultOptions: BuildOptions = {
browser: false
};

/**
* `ckeditor5` and `ckeditor5-premium-features` globals.
*/
const CKEDITOR_GLOBALS: GlobalsOption = {
ckeditor5: 'CKEDITOR',
'ckeditor5-premium-features': 'CKEDITOR_PREMIUM_FEATURES'
};

/**
* Reads CLI arguments and turn the keys into camelcase.
*/
Expand All @@ -61,7 +71,8 @@ function getCliArguments(): Partial<BuildOptions> {
'minify': { type: 'boolean' },
'clean': { type: 'boolean' },
'browser': { type: 'boolean' },
'name': { type: 'string' }
'name': { type: 'string' },
'globals': { type: 'string', multiple: true }
},

// Skip `node ckeditor5-build-package`.
Expand All @@ -74,6 +85,17 @@ function getCliArguments(): Partial<BuildOptions> {
return camelizeObjectKeys( values );
}

/**
* Convert `globals` parameter to object when it's passed via CLI as `<external-id:variableName,another-external-id:anotherVariableName, >`
*/
function normalizeGlobalsParameter( globals: GlobalsOption | Array<string> ): GlobalsOption | Array<string> {
if ( Array.isArray( globals ) ) {
return Object.fromEntries( globals.map( item => item.split( ':' ) ) );
}

return globals;
}

/**
* Generates `UMD` build based on previous `ESM` build.
*/
Expand All @@ -83,17 +105,18 @@ async function generateUmdBuild( args: BuildOptions, bundle: RollupOutput ): Pro
const { dir, name } = path.parse( args.output );
const { plugins, ...config } = await getRollupConfig( args );
const build = await rollup( config );
const globals = {
...CKEDITOR_GLOBALS,
...args.globals as GlobalsOption
};

const umdBundle = await build.write( {
format: 'umd',
file: path.join( dir, `${ name }.umd.js` ),
assetFileNames: '[name][extname]',
sourcemap: args.sourceMap,
name: args.name,
globals: {
ckeditor5: 'ckeditor5',
'ckeditor5-premium-features': 'ckeditor5-premium-features'
}
globals
} );

return {
Expand Down Expand Up @@ -137,6 +160,10 @@ async function normalizeOptions( options: Partial<BuildOptions> ): Promise<Build
normalized.banner = banner;
}

if ( normalized.globals ) {
normalized.globals = normalizeGlobalsParameter( normalized.globals );
}

return normalized;
}

Expand Down
25 changes: 25 additions & 0 deletions packages/ckeditor5-dev-build-tools/tests/build/arguments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ test( '--external', async () => {
expect( spy ).toHaveBeenCalledWith( expect.objectContaining( { external: [ 'foo', 'bar' ] } ) );
} );

test( '--globals', async () => {
const spy = getConfigMock();

mockCliArgs( '--globals=foo:bar', '--globals=baz:faz' );
await build();

expect( spy ).toHaveBeenCalledWith( expect.objectContaining( { globals: { foo: 'bar', baz: 'faz' } } ) );
} );

test( '--declarations', async () => {
const spy = getConfigMock();

Expand Down Expand Up @@ -212,6 +221,22 @@ test( '.external', async () => {
expect( spy ).toHaveBeenCalledWith( expect.objectContaining( { external: [ 'foo', 'bar' ] } ) );
} );

test( '.globals', async () => {
const spy = getConfigMock();

await build( { globals: { foo: 'bar' } } );

expect( spy ).toHaveBeenCalledWith( expect.objectContaining( { globals: { foo: 'bar' } } ) );
} );

test( '.globals (empty object)', async () => {
const spy = getConfigMock();

await build( { globals: {} } );

expect( spy ).toHaveBeenCalledWith( expect.objectContaining( { globals: {} } ) );
} );

test( '.rewrite', async () => {
const spy = getConfigMock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ test( 'Minify', async () => {
expect( output[ 0 ].code ).toContain( 'export{' );
} );

test( 'Minification doesnt remove banner', async () => {
test( 'Minification doesn\'t remove banner', async () => {
const { output } = await build( {
input: 'src/input.js',
banner: 'src/banner.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const defaults: Options = {
banner: '',
external: [],
rewrite: [],
globals: [],
declarations: false,
translations: '',
sourceMap: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-dev-bump-year/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ckeditor/ckeditor5-dev-bump-year",
"version": "41.0.0",
"version": "42.0.0",
"description": "Used to bump year in the licence text specified at the top of the file.",
"keywords": [],
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-dev-ci/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ckeditor/ckeditor5-dev-ci",
"version": "41.0.0",
"version": "42.0.0",
"description": "Utils used on various Continuous Integration services.",
"keywords": [],
"main": "lib/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-dev-dependency-checker/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@ckeditor/ckeditor5-dev-dependency-checker",
"version": "41.0.0",
"version": "42.0.0",
"description": "Contains tools for validating dependencies specified in package.json.",
"keywords": [],
"dependencies": {
"@ckeditor/ckeditor5-dev-utils": "^41.0.0",
"@ckeditor/ckeditor5-dev-utils": "^42.0.0",
"chalk": "^4.1.0",
"depcheck": "^1.3.1",
"glob": "^10.2.5",
Expand Down
8 changes: 4 additions & 4 deletions packages/ckeditor5-dev-docs/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@ckeditor/ckeditor5-dev-docs",
"version": "41.0.0",
"version": "42.0.0",
"description": "Tasks used to build and verify the documentation for CKEditor 5.",
"keywords": [],
"main": "lib/index.js",
"dependencies": {
"@ckeditor/ckeditor5-dev-utils": "^41.0.0",
"@ckeditor/jsdoc-plugins": "^41.0.0",
"@ckeditor/typedoc-plugins": "^41.0.0",
"@ckeditor/ckeditor5-dev-utils": "^42.0.0",
"@ckeditor/jsdoc-plugins": "^42.0.0",
"@ckeditor/typedoc-plugins": "^42.0.0",
"fast-glob": "^3.2.4",
"fs-extra": "^9.0.0",
"jsdoc": "ckeditor/jsdoc#fixed-trailing-comment-doclets",
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-dev-release-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@ckeditor/ckeditor5-dev-release-tools",
"version": "41.0.0",
"version": "42.0.0",
"description": "Tools used for releasing CKEditor 5 and related packages.",
"keywords": [],
"main": "lib/index.js",
"dependencies": {
"@ckeditor/ckeditor5-dev-utils": "^41.0.0",
"@ckeditor/ckeditor5-dev-utils": "^42.0.0",
"@octokit/rest": "^19.0.0",
"chalk": "^4.0.0",
"cli-table": "^0.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-dev-stale-bot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ckeditor/ckeditor5-dev-stale-bot",
"version": "41.0.0",
"version": "42.0.0",
"description": "A stale bot is used to mark issues and pull requests that have not recently been updated.",
"keywords": [],
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/ckeditor5-dev-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@ckeditor/ckeditor5-dev-tests",
"version": "41.0.0",
"version": "42.0.0",
"description": "Testing environment for CKEditor 5.",
"keywords": [],
"main": "lib/index.js",
"dependencies": {
"@babel/core": "^7.10.5",
"@ckeditor/ckeditor5-dev-translations": "^41.0.0",
"@ckeditor/ckeditor5-dev-utils": "^41.0.0",
"@ckeditor/ckeditor5-dev-translations": "^42.0.0",
"@ckeditor/ckeditor5-dev-utils": "^42.0.0",
"@ckeditor/ckeditor5-inspector": "^4.0.0",
"@types/chai": "^4.3.5",
"@types/karma-sinon-chai": "^2.0.2",
Expand Down
Loading

0 comments on commit 028f5c2

Please sign in to comment.