You can’t miss the JS compatibility checker ES5 Validator

If you encounter “SyntaxError: Unexpected Token…” This is usually caused by compatibility issues, which can be shown as a blank screen when you enter a small program, which can be very serious and often leads to the application being unavailable.

So after rapid hemostatic rollback, how can we quickly locate the problem?

Quick post location

Using the ES5-Validator to detect the error line JS bundle file, the second level of exposure: discover function default values and advanced syntax such as let.

prevention

For third-party dependencies that cannot be compiled

Of course, the best solution is to upgrade the builder. If you don’t want to upgrade, you can prevent it in advance by introducing the ES5-Validator into the project and verifying the build product after build.

Package. Json:

{
   "postbuild": "es5-validator ./dist/index.min.js"
}
Copy the code

Uncompiled business source code for historical legacy

Still need to maintain ancient code? Still tiptoeing around using const, arrow functions, computed properties, property abbreviations, and for of? If you manually check and CR, can you be sure that there isn’t a high-level syntax lurking online that could be a time bomb to trigger a failure?

The following is discovered by connecting to the ES5-Validator:

Thorough prevention

Package. Json:

{
  "scripts": {
    "postbuild": "npm run validate:es5"."validate:es5": "es5-validator ./app/scripts/*.js",},"devDependencies": {
    "es5-validator": "^ 1.0.8." ",}}Copy the code