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

Add checking es5 task to build cycle but, the es-check module has some problem #751

Closed
donggyu04 opened this issue Jan 29, 2021 · 2 comments
Labels

Comments

@donggyu04
Copy link
Contributor

donggyu04 commented Jan 29, 2021

I added a task to our build cycle to check whether bundled javascript is es5 or not. but the es-check module has some problems.
I think we have to find another module or fix the es-check.

1. Feature

1. When pass build (no have es6 syntax)

> Task :ngrinder-frontend:checkES5
ES-Check: Going to check files using version 5
ES-Check: checking ../ngrinder-controller/build/classes/main/static/js/app.js
ES-Check: there were no ES version matching errors!  🎉

BUILD SUCCESSFUL in 50s
24 actionable tasks: 23 executed, 1 up-to-date

2. When failed build (have es6 syntax)

> Task :ngrinder-frontend:checkES5
ES-Check: Going to check files using version 5
ES-Check: checking ../ngrinder-controller/build/classes/main/static/js/app.js
ES-Check: failed to parse file: ../ngrinder-controller/build/classes/main/static/js/app.js
 - error: SyntaxError: The keyword 'const' is reserved (102:144568)
ES-Check: there were 1 ES version matching errors.

          ES-Check Error:
          ----
          · erroring file: ../ngrinder-controller/build/classes/main/static/js/app.js
          · error: SyntaxError: The keyword 'const' is reserved (102:144568)
          · see the printed err.stack below for context
          ----

          SyntaxError: The keyword 'const' is reserved (102:144568)
    at Parser.pp$4.raise (/Users/user/.npm/_npx/55223/lib/node_modules/es-check/node_modules/acorn/dist/acorn.js:2825:15)
    
...

> Task :ngrinder-frontend:checkES5 FAILED

FAILURE: Build failed with an exception.

BUILD FAILED in 33s
21 actionable tasks: 18 executed, 3 up-to-date

2. es-check module issue

It does not catch some es6 keywords like Object.assign, Promise
Actually, When I test with the below script, es-check passes the task even if it has es6 syntax.

// es-check-testing.js

var myPromise = new Promise(function(resolve, reject) {
	resolve();
	reject();
});

var o1 = { a: 1 };
var o2 = { b: 2 };
var o3 = { c: 3 };

var obj = Object.assign(o1, o2, o3);
npx es-check es5 ./es-check-testing.js --verbose

ES-Check: Going to check files using version 5
ES-Check: checking ./es-check-testing.js
ES-Check: there were no ES version matching errors!  🎉

Relevant issues below.
dollarshaveclub/es-check#122
dollarshaveclub/es-check#72

@donggyu04 donggyu04 added the task label Jan 29, 2021
@donggyu04 donggyu04 changed the title Add checkES5 task to build cycle but, the es-check module has some problem Add checking es5 task to build cycle but, the es-check module has some problem Jan 29, 2021
@junoyoon
Copy link
Contributor

junoyoon commented Jan 30, 2021

As far as I understand ,es-check checks if the check target contains illegal syntax or not. Object.assign, Promise is not syntax but Identifier (which is provided by javascript engine) and these should be handled by something else.
Even though it does not check whole IE compatibility issues, embedding es-check is better to have, I think Object.assign, Promise can be handled by polyfill instead.
Just adopt es-check.

@donggyu04
Copy link
Contributor Author

donggyu04 commented Apr 2, 2021

@junoyoon

Yes, It can't completely check the bundled code can run in IE, but I have adopted it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants