-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Disallow the use of global
in the JS code intended for the browser
#14173
Comments
The issue occurred again. Initially reported in ckeditor/vite-plugin-ckeditor5#17. Using 39.x packages with Vite results in the following error on editor focus:
Source maps point to the
|
Our first idea to solve this problem was to add an ESLint rule that would disallow the use of TypeScript configurationAs it turned out, the source of the problem was in-direct dependencies (dependencies of dependencies) in our project that depended on To fix this, I created PR #14808 which adds ESLint configurationOn top of that, I noticed that the environment was not set up in the ESLint configuration, forcing us to use magic CodeFinally, I noticed that the After some testing it turns out that this is no longer needed and direct access to Since this is a breaking change, we'll (1) write an ADR to get feedback from the community and other teams, and (2) wait with these two PRs until we start working on the v40 release. |
If I could propose something, I suggest creating an issue for each PR. There's so many of them, that it becomes unclear what closes what issue and in which order. We should make it more visible on our boards. |
Those comments could indicate where we use DOM APIs if we ever want to support headless editor mode (running without DOM on the node server). If we remove those, then it could be harder to spot. OTOH we could then switch to node env and check what is failing, but this would need to scan much more errors and could be overwhelming. |
I feel like this could be related to my previous comment (for easier moving to a headless editor). |
Hello guys, thanks to @LukaszGudel we noticed that you plan to remove As we are using However, we are not sure if this will still work after removing Are you able to release for us some test version of It would also be ideal to get an editorBundle that we can test to see if it works with features like documents-storage. However, as these functions are already run in the browser (puppeteer), we do not anticipate problems with this. |
Fix: Don't rely on `global` object available only in Node. Fixes ckeditor/vite-plugin-ckeditor5#17 and #14801. Internal: Load only specified typings for TypeScript. Closes #14173.
Other (generator): Aligned the produced configuration to changes in CKEditor 5. See ckeditor/ckeditor5#14173. Closes #160. Feature (tools): Karma will use the `tsconfig.test.json` file as a TypeScript configuration if it exists when executing automated tests. By default, it fallbacks to `tsconfig.json` file. MINOR BREAKING CHANGE (tools): The `typescript()` function exported from the `webpack-utils` module requires passing the `cwd` as the first argument. Optionally, you can pass the TypeScript configuration file name that should be used when processing TS files by `ts-loader`.
We've just stumbled upon an issue with the accidental use of
global
in our code: dc25921Which resulted in an error only when the editor was built with Vite (and probably other bundlers that don't try to polyfill the CJS env):
The issue in our code was hard to spot during the review because as you can see in dc25921 we actually have a module named
global
too and when you copy&paste code between files you may copy the usage of it but miss the import.If you'd like to see this improvement implemented, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: