ckeditor/ckeditor5-react

ERR_REQUIRE_ESM with Vitest when using ckeditor5-react and ckeditor5-build-classic

f4irline opened this issue · 2 comments

Hey,

When trying to run tests using Vitest and React Testing Library, I stumble on to the following error:

Error: require() of ES Module /workspaces/workspace/node_modules/.pnpm/@ckeditor+ckeditor5-watchdog@41.3.1/node_modules/@ckeditor/ckeditor5-watchdog/src/index.js from /workspaces/workspace/node_modules/.pnpm/@ckeditor+ckeditor5-react@6.3.0_@ckeditor+ckeditor5-core@41.3.1_@ckeditor+ckeditor5-editor-mu_u4cc4mpjbdj7ukcuf4x6qwbloa/node_modules/@ckeditor/ckeditor5-react/dist/index.js not supported.
Instead change the require of /workspaces/workspace/node_modules/.pnpm/@ckeditor+ckeditor5-watchdog@41.3.1/node_modules/@ckeditor/ckeditor5-watchdog/src/index.js in /workspaces/workspace/node_modules/.pnpm/@ckeditor+ckeditor5-react@6.3.0_@ckeditor+ckeditor5-core@41.3.1_@ckeditor+ckeditor5-editor-mu_u4cc4mpjbdj7ukcuf4x6qwbloa/node_modules/@ckeditor/ckeditor5-react/dist/index.js to a dynamic import() which is available in all CommonJS modules.
 ❯ node_modules/.pnpm/@ckeditor+ckeditor5-react@6.3.0_@ckeditor+ckeditor5-core@41.3.1_@ckeditor+ckeditor5-editor-mu_u4cc4mpjbdj7ukcuf4x6qwbloa/node_modules/@ckeditor/ckeditor5-react/dist/index.js:5:122

This is with the latest version of ckeditor5-react and ckeditor5-build-classic. This did work with ckeditor5-build-classic version 39.0.2, but with the latest version there seems to be issues.

A minimal StackBlitz implementation where the error can be reproduced can be found here - just let StackBlitz install the dependencies and run npm run test