From 6130d2a28aa6652f401be68fa2118e2a299715b6 Mon Sep 17 00:00:00 2001 From: Mateusz Baginski Date: Wed, 25 Sep 2024 10:43:24 +0200 Subject: [PATCH] Restore UMD support --- package.json | 14 ++++++-------- src/test-utils.ts | 10 ---------- src/test-utils/index.ts | 13 +++++++++++++ vite.config.ts | 9 ++++----- vite.test-utils.config.ts | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 23 deletions(-) delete mode 100644 src/test-utils.ts create mode 100644 src/test-utils/index.ts create mode 100644 vite.test-utils.config.ts diff --git a/package.json b/package.json index c45081d..574ebd5 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ }, "homepage": "https://github.com/ckeditor/ckeditor5-integrations-common", "scripts": { - "build": "vite build", + "build": "yarn build:lib && yarn build:test-utils", + "build:lib": "vite build", + "build:test-utils": "vite build --config vite.test-utils.config.ts", "dev": "vite", "lint": "eslint --quiet \"**/*.{ts,tsx}\"", "test": "vitest run --coverage", @@ -58,17 +60,13 @@ }, "require": { "types": "./dist/index.d.ts", - "default": "./dist/index.cjs" + "default": "./dist/index.umd.cjs" } }, "./test-utils": { "import": { - "types": "./dist/test-utils.d.ts", - "default": "./dist/test-utils.js" - }, - "require": { - "types": "./dist/test-utils.d.ts", - "default": "./dist/test-utils.cjs" + "types": "./dist/test-utils/index.d.ts", + "default": "./dist/test-utils/index.js" } } }, diff --git a/src/test-utils.ts b/src/test-utils.ts deleted file mode 100644 index 13b47dc..0000000 --- a/src/test-utils.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. - * For licensing, see LICENSE.md. - */ - -import './globals.d'; -import './cdn/ck/globals.js'; -import './cdn/ckbox/globals.js'; - -export { removeAllCkCdnResources } from './test-utils/cdn/removeAllCkCdnResources.js'; diff --git a/src/test-utils/index.ts b/src/test-utils/index.ts new file mode 100644 index 0000000..612c6f5 --- /dev/null +++ b/src/test-utils/index.ts @@ -0,0 +1,13 @@ +/** + * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. + * For licensing, see LICENSE.md. + */ + +import '../globals.d'; +import '../cdn/ck/globals.js'; +import '../cdn/ckbox/globals.js'; + +/** + * It's public API, make sure to keep it in sync with the documentation. + */ +export { removeAllCkCdnResources } from './cdn/removeAllCkCdnResources.js'; diff --git a/vite.config.ts b/vite.config.ts index e93ba73..677f001 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -13,11 +13,10 @@ export default defineConfig( { build: { target: 'esnext', lib: { - formats: [ 'es', 'cjs' ], - entry: { - index: 'src/index', - 'test-utils': 'src/test-utils' - } + entry: 'src/index', + fileName: 'index', + formats: [ 'es', 'umd' ], + name: 'CKEDITOR_INTEGRATIONS_COMMON' }, sourcemap: true, emptyOutDir: true, diff --git a/vite.test-utils.config.ts b/vite.test-utils.config.ts new file mode 100644 index 0000000..89b6cf9 --- /dev/null +++ b/vite.test-utils.config.ts @@ -0,0 +1,35 @@ +/** + * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. + * For licensing, see LICENSE.md. + */ + +import 'vitest/config'; + +import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; +import tsconfigPaths from 'vite-tsconfig-paths'; + +export default defineConfig( { + build: { + target: 'esnext', + lib: { + entry: 'src/test-utils/index', + fileName: 'test-utils/index', + formats: [ 'es' ] + }, + sourcemap: true, + emptyOutDir: false + }, + plugins: [ + tsconfigPaths(), + dts( { + include: [ 'src/test-utils/**/*.ts' ], + exclude: [ '**/*.test.ts', '**/*.test.tsx' ], + copyDtsFiles: true, + clearPureImport: false, + compilerOptions: { + baseUrl: './src/test-utils' + } + } ) + ] +} );