Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ckeditor5-react does not work with optimized imports #17533

Closed
stonebk opened this issue Nov 26, 2024 · 5 comments
Closed

ckeditor5-react does not work with optimized imports #17533

stonebk opened this issue Nov 26, 2024 · 5 comments
Labels
domain:dx This issue reports a developer experience problem or possible improvement. domain:integration-dx This issue reports a problem with the developer experience when integrating CKEditor into a system. type:bug This issue reports a buggy (incorrect) behavior.
Milestone

Comments

@stonebk
Copy link
Contributor

stonebk commented Nov 26, 2024

📝 Provide detailed reproduction steps (if any)

Using optimized imports with @ckeditor/ckeditor5-react results in incompatible type errors in TypeScript.

I modified the Headless editor demo to include an optimized import to @ckeditor/ckeditor5-core and I get build errors.

/**
 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */

import React, { useState, useEffect, StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { CKEditor } from '@ckeditor/ckeditor5-react';
import HeadlessEditor from './headless.js';
+import { EditorConfig } from '@ckeditor/ckeditor5-core/dist/index.js';

function App() {
	const [editor, setEditor] = useState(null);

+	const config: EditorConfig = {
+		placeholder: 'Type your text here!',
+	};

	return (
		<div className="App">
			<EditorToolbar editor={editor} />

			<CKEditor
+				config={config}
				editor={HeadlessEditor}

✔️ Expected result

No build errors.

❌ Actual result

Image

❓ Possible solution

Switching the import from '@ckeditor/ckeditor5-core/dist/index.js' to '@ckeditor/ckeditor5-core/src/index.js' seems to resolve the build time error, but this required all imports to now point to src instead of dist, and this resulted in runtime errors:

Image

This is actually the point I started from. I was previously using optimized imports before trying to upgrade with new installation methods when I ran into #17504. Upgrading without using the new installation method resulted in the same runtime error as above. I noticed that I was importing from src instead of dist so I tried updating all the imports and instead ran into the TS build error.


If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@stonebk stonebk added the type:bug This issue reports a buggy (incorrect) behavior. label Nov 26, 2024
@Witoso Witoso added domain:dx This issue reports a developer experience problem or possible improvement. domain:integration-dx This issue reports a problem with the developer experience when integrating CKEditor into a system. labels Nov 27, 2024
@amitjangid12

This comment has been minimized.

@amitjangid12

This comment has been minimized.

@Witoso
Copy link
Member

Witoso commented Nov 29, 2024

@amitjangid12 those issues are off-topic to this thread, please contact our support, as it relates to a premium plugin of our partner.

@Witoso
Copy link
Member

Witoso commented Nov 29, 2024

@stonebk we will take a look at this with @filipsobol. Looks like our legacy support uncovered additional thing. We will figure this out, possibly we only need to maintain one set of types (src?) as the source generating this for src and dist is the same. Stay tuned.

filipsobol added a commit that referenced this issue Dec 16, 2024
Fix: Unify TypeScript declaration files. Fixes #17575 and #17533.
@filipsobol
Copy link
Member

Fixed in #17597

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dx This issue reports a developer experience problem or possible improvement. domain:integration-dx This issue reports a problem with the developer experience when integrating CKEditor into a system. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

4 participants