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

Cannot find module ckeditor5/translations/pl.js or its corresponding type declarations #16535

Closed
Mati365 opened this issue Jun 10, 2024 · 5 comments
Labels
domain:dx This issue reports a developer experience problem or possible improvement. resolution:resolved This issue was already resolved (e.g. by another ticket). type:bug This issue reports a buggy (incorrect) behavior.

Comments

@Mati365
Copy link
Member

Mati365 commented Jun 10, 2024

📝 Provide detailed reproduction steps (if any)

  1. Open this stack blitz demo: https://stackblitz.com/edit/vitejs-vite-ovlnsp?file=src%2FMultiRootEditor.tsx
  2. Try to import any translations/ file like in these docs (https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/getting-started/setup/ui-language.html#npm)

✔️ Expected result

No errors. Translations should be properly typed.

❌ Actual result

Cannot find module `ckeditor5/translations/pl.js` or its corresponding type declarations.

obraz

@Mati365 Mati365 added type:bug This issue reports a buggy (incorrect) behavior. release:potential-blocker This issue potentially blocks the upcoming release (should be checked). labels Jun 10, 2024
@Witoso Witoso added release:blocker This issue blocks the upcoming release (is critical). and removed release:potential-blocker This issue potentially blocks the upcoming release (should be checked). labels Jun 10, 2024
@filipsobol
Copy link
Member

When I downloaded this demo and ran it locally, I got the following error:

Cannot find module 'ckeditor5/translations/pl.js' or its corresponding type declarations.
  There are types at '/home/praca/Pobrane/vitejs-vite-75ppwy/node_modules/ckeditor5/dist/translations/pl.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.ts(2307)

This happens because "moduleResolution" in this project is set to "Node". According to the TypeScript documentation:

'node10' (previously called 'node') for Node.js versions older than v10, which only support CommonJS require. You probably won’t need to use node10 in modern code.

It looks like this issue is caused by the exports field in the package.json files in ckeditor5 and ckeditor5-premium-features, for which support was added in Node 12.

We could fix this by adding the following to exports in both packages:

"./dist/translations/*.js": {
  "types": "./dist/translations/*.d.ts",
  "import": "./dist/translations/*.js"
}

This would allow importing translations like so:

import coreTranslations from 'ckeditor5/dist/translations/pl.js';
//                                      ^^^^
import commercialTranslations from 'ckeditor5-premium-features/dist/translations/pl.js';
//                                                             ^^^^

However, since exports is supported as of Node 12 and this TypeScript configuration is discouraged, I think we can ignore this issue unless we get more feedback about it.

@Mati365 Mati365 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 10, 2024
@Witoso Witoso added domain:dx This issue reports a developer experience problem or possible improvement. resolution:resolved This issue was already resolved (e.g. by another ticket). and removed release:blocker This issue blocks the upcoming release (is critical). labels Jun 11, 2024
@human211
Copy link

human211 commented Aug 12, 2024

I have the same problem. How to solve it?
This doesn't work either
import translations from 'ckeditor5/dist/translations/ru.js';

@filipsobol
Copy link
Member

This issue was resolved in 42.0.2. If you update to 42.0.2 or newer, you should be able to import translations like so:

import translations from 'ckeditor5/translations/ru.js';

@human211
Copy link

I have the latest version
"ckeditor5": "43.0.0",

it helped me

// @ts-expect-error
import translations from 'ckeditor5/translations/ru.js';

@filipsobol
Copy link
Member

If @ts-expect-error resolved this, then it's probably caused by using moduleResolution: 'node' in TypeScript, which should only be used with Node 10 and older. If you use TypeScript 5.0 or newer, you can change 'node' to 'bundler' to fix it. Otherwise, you can refer to the docs.

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. resolution:resolved This issue was already resolved (e.g. by another ticket). type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

4 participants