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

🧩 Missing imports after update to v42.0.0+ #17289

Open
Witoso opened this issue Oct 21, 2024 · 9 comments
Open

🧩 Missing imports after update to v42.0.0+ #17289

Witoso opened this issue Oct 21, 2024 · 9 comments
Labels
domain:integration-dx This issue reports a problem with the developer experience when integrating CKEditor into a system. squad:core Issue to be handled by the Core team.

Comments

@Witoso
Copy link
Member

Witoso commented Oct 21, 2024

Missing imports

We've received reports on our GitHub issue tracker (e.g., issue #17207) about missing code imports after upgrading to CKEditor 5 version 42.0.0 or higher. These issues mainly affect integrators who noticed that certain classes and utilities used for custom plugins and integrations are no longer available for import.

Depending on the integration method, the errors may look different but importing the missing item will always fail in the runtime:

import { LINK_KEYSTROKE } from 'ckeditor5';

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/ckeditor5.js?v=635e45a4' does not provide an export named 'LINK_KEYSTROKE'

This situation is partly due to the migration to TypeScript in version 37.0.0, which introduced import indexes, along with recent changes to installation methods. While these updates aim to simplify CKEditor 5 integration, they have caused some unintended issues for existing setups.

What are we doing about it?

  • We are actively working to address this problem, and we review each request for imports and decide if it should be part of the public API of the editor.
  • Historically, the editor exposed many internal functions because we provided access to almost all source code. This meant that any function shared across files could be treated as a public API.
  • If it's an obvious case, we add the missing export to the indexes right away.
  • If we decide not to export a function, we will explain why and provide any possible workarounds (in some cases, better alternatives may be available).
  • We are also working on updating our API documentation. Over the next few months, we plan to improve its organization and make it more consistent with the new installation methods.

What can I do as an integrator?

  • If you encounter missing imports, please open an issue on our bug tracker listing the imports you need.
    • Providing information on how you use these imports and why they are essential will help us understand your needs and shape our API accordingly.
    • Licensed CKEditor 5 users can contact us directly for assistance.
  • For simple public utilities and types, you may temporarily copy them directly from the editor's source code. Use GitHub's search functionality to locate them in the codebase.

We appreciate your patience as we address these issues and improve the experience for everyone.

@Witoso Witoso added domain:integration-dx This issue reports a problem with the developer experience when integrating CKEditor into a system. squad:core Issue to be handled by the Core team. labels Oct 21, 2024
@Witoso Witoso pinned this issue Oct 21, 2024
@stonebk
Copy link

stonebk commented Oct 24, 2024

I recently tried to upgrade from the 41.3.0-alpha releases to version 43.2.0. Everything seems to work fine except for my tests where it cannot find the ckeditor5 module:

 FAIL   @ms/yammer-publisher-components  src/RichTextEditor/RichTextEditor.spec.tsx
  ● Test suite failed to run

    Cannot find module 'ckeditor5' from 'src/editor/HeadlessEditor.ts'

    Require stack:
      src/editor/HeadlessEditor.ts
      src/RichTextEditor/RichTextEditor.tsx
      src/RichTextEditor/RichTextEditor.spec.tsx

    > 1 | import { Autoformat, DecoupledEditor, EditorConfig, Essentials, Paragraph } from 'ckeditor5';
        | ^
      2 |

      at Resolver._throwModNotFoundError (../../../common/temp/node_modules/.pnpm/[email protected]/node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.require (src/editor/HeadlessEditor.ts:1:1)
      at Object.require (src/RichTextEditor/RichTextEditor.tsx:4:1)
      at Object.require (src/RichTextEditor/RichTextEditor.spec.tsx:8:1)

Does this sound like a related issue?

@filipsobol
Copy link
Member

@stonebk I can't think of any change that would cause this. Could you try reinstalling the dependencies?

@Witoso
Copy link
Member Author

Witoso commented Oct 24, 2024

Looks like jest (jest-resolver) cannot properly find the package. Which is weird because we are a standard ESM. A quick internet search showed clearing cache jest --clearCache, or using explicit config:

module.exports = {
  // Existing config...
  moduleNameMapper: {
    '^ckeditor5$': '<rootDir>/path/to/ckeditor',
  },
};

But the above looks weird...

@stonebk
Copy link

stonebk commented Oct 24, 2024

@stonebk I can't think of any change that would cause this. Could you try reinstalling the dependencies?

The dependencies are definitely there -- the code runs great outside of jest. I can try playing around with moduleNameMapper as @Witoso suggests. --clearCache didn't help.

This could very well be an issue specific to our setup. We're using rush and pnpm. We were wondering if pnpm's flat store has something to do with it.

@stonebk
Copy link

stonebk commented Oct 24, 2024

Thank you @Witoso, this appears to work:

  moduleNameMapper: {
    '^ckeditor5$': '<rootDir>/node_modules/ckeditor5/dist/ckeditor5.js',
  },

@Witoso
Copy link
Member Author

Witoso commented Nov 6, 2024

I would really appreciate it if someone could share a minimal reproducible sample for us, with jest version, etc. Before we start updating the docs, it would be great to understand the issue and describe it better.

@stefanseeger
Copy link
Contributor

Hi @Witoso here you go
https://github.com/stefanseeger/ckeditor5-43.3-jest-broken

@ckeditor ckeditor deleted a comment from Greatowen42 Nov 8, 2024
@amitjangid12

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:integration-dx This issue reports a problem with the developer experience when integrating CKEditor into a system. squad:core Issue to be handled by the Core team.
Projects
None yet
Development

No branches or pull requests

5 participants