Comments (6)
TLDR;
If you guys are sure the new PR will solve this problem - no problem. Feel free to close the issue. You have already paid attention to the problem which is enough to remember it if necessary. My goal was to tell you about a nasty issue that happens on runtime.
Full story
I use [email protected]. Perhaps this problem will go away with new installation methods (#15502)
@maxmartynov Are you using the latest version of terser?
I use (Nuxt.js uses under the hood) [email protected]. The latest version is 5.29.2.
it correctly converts ITEMS_PER_REQUEST.toString() to 50..toString()
I confirm that for me disabling the flags reduce_vars: false, collapse_vars: false
leads to having 50..toString()
in the resulting bundle. And this works.
I've created this issue mostly to point out the fact that (warn: IMHO) using <number>.toString()
is not the best practice. My project uses ~70 libs in package.json and that means about 1.4k libs as nested dependencies. And they all play well with these Terser options enabled. The only place I noticed a problem is this one row in ckeditor5. You can check your project and make sure that there are no other places where you stringify numbers this way (not 100% info).
The reason why I've created this issue is to report the problem that appears in runtime only and happens NOT IN 100% CASES. My users got the error SyntaxError: Invalid or unexpected token
randomly in different browsers. I assume that some browser engines can handle 50.toString() sometimes, because I don't know the reason why only half of my users get this error sometimes.
from ckeditor5.
Fixed in the PR #16041
from ckeditor5.
Ha, that's very intriguing. What kind of bundler/minifier are you using? Tactical cc to @filipsobol, as we start to bundle ourselves in #15502.
from ckeditor5.
I use Terser (Stack: Nuxt.js 3, Vue 3, Vite, Terser).
Disabling these two options of Terser makes ckeditor build correctly:
export default defineNuxtConfig({
vite: {
build: {
minify: 'terser',
terserOptions: {
compress: {
reduce_vars: false,
collapse_vars: false,
},
},
},
},
})
But in general, I had to disable these two options only for two rows in ckeditor lib which I've fixed in my PR. If I disable these options, the expression ITEMS_PER_REQUEST.toString()
becomes 50..toString()
(with two dots) in the result bundle and it works
from ckeditor5.
We use terser to minify bundles for the new installation methods (#15502) and it correctly converts ITEMS_PER_REQUEST.toString()
to 50..toString()
. This is consistent with the output in the Terser REPL:
// Input
const test = 50;
console.log(test.toString());
// Output
console.log(50..toString());
@maxmartynov Are you using the latest version of terser?
Out of curiosity, I also checked swc and (when compression is enabled) it converts ITEMS_PER_REQUEST.toString()
to "50"
.
from ckeditor5.
Hmm, with the options mentioned by @maxmartynov
compress: {
reduce_vars: false,
collapse_vars: false,
},
the live REPL also produces working code:
const o=50;console.log(o.toString());
It looks like a Terser issue (maybe older version produced wrong results), or maybe something else causes problems in your environment?
TBH I don't see this as a bug on our side 🤔 Changing working code to some other implementation just because minification crashes it, looks like the tail wagging the dog.
from ckeditor5.
Related Issues (20)
- Disallow any formatting for links
- Center a list
- Docs issue report from "installation/integrations/dotnet.html"
- Unable to replace the default shortcut for Link
- The list properties toolbar is overriden by `List` plugin
- How to disable the 'background' option for the table plugin.
- Inline object in editing view rendered invisible by stale data-ck-unsafe-element attribute after editing source HOT 1
- Spam element containing style with background-color is divided to two span elements HOT 1
- [question] how to automatically remove image or link on command?
- Additional, empty lines added to Source Editing view when using it with HTML Embed
- Accessibility help dialog content got incorrectly resized HOT 2
- [Chrome + Mac] Copying non-ASCII characters from CKEditor and then pasting them produces different symbols HOT 6
- Ckeditor 5 automatically changes the html structure in Source editing mode. HOT 2
- Allow adding new lines after widgets like code blocks
- Incorrect image size is shown when shrinking a block image
- Docs issue report from "installation/getting-started/quick-start.html" HOT 2
- previewsInData: true not working
- Unknown file extension ".css" HOT 2
- Drastically increased build size between versions 41.2.1 and 41.3.0 HOT 8
- Triple click does not highlight the whole paragraph when used in read-only mode HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ckeditor5.