SAP / ui5-tooling

An open and modular toolchain to develop state of the art applications based on the UI5 framework
https://sap.github.io/ui5-tooling
Apache License 2.0
466 stars 71 forks source link

Enable ES2020 Support #278

Closed LachlanEdwards closed 3 years ago

LachlanEdwards commented 4 years ago

Expected Behavior

I would like to be able to use ES2020 notation in our SAPUI5 Project. When using Optional Chaining (foo?.bar) I would expect to be able to deploy this to the Cloud Platform.

Current Behavior

Esprima throws the error "Unexpected token ." on the first line I use Optional Chaining, I suspect this is because Esprima hasn't been updated in two years and only provides support up to ES2017. It does have an Open Issue regarding Optional Chaining however JQuery/the development team haven't responded.

Steps to reproduce the issue

  1. Write a program that contains Optional Chaining.
  2. Try to build the project (I build an MTA file in the SAP Business Application Studio).
  3. Encounter an Esprima error (Unexpected token .).

Context

Affected components (if known)

Log Output / Stack Trace

ui5 build --clean-dest --include-task=generateManifestBundle generateCachebusterInfo

info builder:builder Building project scripting_formrenderer not including dependencies...
info builder:builder πŸ›   (1/1) Building project scripting_formrenderer
info builder:builder application scripting_formrenderer πŸ”¨ (1/14) Running task escapeNonAsciiCharacters...
.info builder:builder application scripting_formrenderer πŸ”¨ (2/14) Running task replaceCopyright...
info builder:builder application scripting_formrenderer πŸ”¨ (3/14) Running task replaceVersion...
info builder:builder application scripting_formrenderer πŸ”¨ (4/14) Running task generateFlexChangesBundle...
info builder:builder application scripting_formrenderer πŸ”¨ (5/14) Running task webide-extension-task-updateManifestJson...
info builder:builder application scripting_formrenderer πŸ”¨ (6/14) Running task generateManifestBundle...
info builder:builder application scripting_formrenderer πŸ”¨ (7/14) Running task generateComponentPreload...
ERR! lbt:resources:ResourcePool Error: Line 52: Unexpected token .
ERR! lbt:resources:ResourcePool     at ErrorHandler.constructError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5012:22)
ERR! lbt:resources:ResourcePool     at ErrorHandler.createError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5028:27)
ERR! lbt:resources:ResourcePool     at Parser.unexpectedTokenError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1985:39)
ERR! lbt:resources:ResourcePool     at Parser.throwUnexpectedToken (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1995:21)
ERR! lbt:resources:ResourcePool     at Parser.parsePrimaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2366:38)
ERR! lbt:resources:ResourcePool     at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)
ERR! lbt:resources:ResourcePool     at Parser.parseLeftHandSideExpressionAllowCall (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2899:26)
ERR! lbt:resources:ResourcePool     at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)
ERR! lbt:resources:ResourcePool     at Parser.parseUpdateExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3004:26)
ERR! lbt:resources:ResourcePool     at Parser.parseUnaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3048:26)
ERR! lbt:resources:ResourcePool  failed to parse or analyze %s: com/REDACTED/scripting/admin/Scripting_FormRenderer/controller/Main.controller.js { Error: Line 52: Unexpected token .
ERR! lbt:resources:ResourcePool     at ErrorHandler.constructError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5012:22)
ERR! lbt:resources:ResourcePool     at ErrorHandler.createError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5028:27)
ERR! lbt:resources:ResourcePool     at Parser.unexpectedTokenError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1985:39)
ERR! lbt:resources:ResourcePool     at Parser.throwUnexpectedToken (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1995:21)
ERR! lbt:resources:ResourcePool     at Parser.parsePrimaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2366:38)
ERR! lbt:resources:ResourcePool     at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)
ERR! lbt:resources:ResourcePool     at Parser.parseLeftHandSideExpressionAllowCall (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2899:26)
ERR! lbt:resources:ResourcePool     at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)
ERR! lbt:resources:ResourcePool     at Parser.parseUpdateExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3004:26)
ERR! lbt:resources:ResourcePool     at Parser.parseUnaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3048:26)
ERR! lbt:resources:ResourcePool   index: 2160,
ERR! lbt:resources:ResourcePool   lineNumber: 52,
ERR! lbt:resources:ResourcePool   description: 'Unexpected token .',
ERR! lbt:resources:ResourcePool   stack:
ERR! lbt:resources:ResourcePool    'Error: Line 52: Unexpected token .\n    at ErrorHandler.constructError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5012:22)\n    at ErrorHandler.createError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5028:27)\n    at Parser.unexpectedTokenError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1985:39)\n    at Parser.throwUnexpectedToken (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1995:21)\n    at Parser.parsePrimaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2366:38)\n    at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)\n    at Parser.parseLeftHandSideExpressionAllowCall (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2899:26)\n    at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)\n    at Parser.parseUpdateExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3004:26)\n    at Parser.parseUnaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3048:26)' }
ERR! lbt:resources:ResourcePool Error: Line 23: Unexpected token .
ERR! lbt:resources:ResourcePool     at ErrorHandler.constructError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5012:22)
ERR! lbt:resources:ResourcePool     at ErrorHandler.createError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5028:27)
ERR! lbt:resources:ResourcePool     at Parser.unexpectedTokenError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1985:39)
ERR! lbt:resources:ResourcePool     at Parser.throwUnexpectedToken (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1995:21)
ERR! lbt:resources:ResourcePool     at Parser.parsePrimaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2366:38)
ERR! lbt:resources:ResourcePool     at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)
ERR! lbt:resources:ResourcePool     at Parser.parseLeftHandSideExpressionAllowCall (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2899:26)
ERR! lbt:resources:ResourcePool     at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)
ERR! lbt:resources:ResourcePool     at Parser.parseUpdateExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3004:26)
ERR! lbt:resources:ResourcePool     at Parser.parseUnaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3048:26)
ERR! lbt:resources:ResourcePool  failed to parse or analyze %s: com/REDACTED/scripting/admin/Scripting_FormRenderer/common/ControlDictionary.js { Error: Line 23: Unexpected token .
ERR! lbt:resources:ResourcePool     at ErrorHandler.constructError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5012:22)
ERR! lbt:resources:ResourcePool     at ErrorHandler.createError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5028:27)
ERR! lbt:resources:ResourcePool     at Parser.unexpectedTokenError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1985:39)
ERR! lbt:resources:ResourcePool     at Parser.throwUnexpectedToken (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1995:21)
ERR! lbt:resources:ResourcePool     at Parser.parsePrimaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2366:38)
ERR! lbt:resources:ResourcePool     at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)
ERR! lbt:resources:ResourcePool     at Parser.parseLeftHandSideExpressionAllowCall (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2899:26)
ERR! lbt:resources:ResourcePool     at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)
ERR! lbt:resources:ResourcePool     at Parser.parseUpdateExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3004:26)
ERR! lbt:resources:ResourcePool     at Parser.parseUnaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3048:26)
ERR! lbt:resources:ResourcePool   index: 455,
ERR! lbt:resources:ResourcePool   lineNumber: 23,
ERR! lbt:resources:ResourcePool   description: 'Unexpected token .',
ERR! lbt:resources:ResourcePool   stack:
ERR! lbt:resources:ResourcePool    'Error: Line 23: Unexpected token .\n    at ErrorHandler.constructError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5012:22)\n    at ErrorHandler.createError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:5028:27)\n    at Parser.unexpectedTokenError (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1985:39)\n    at Parser.throwUnexpectedToken (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:1995:21)\n    at Parser.parsePrimaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2366:38)\n    at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)\n    at Parser.parseLeftHandSideExpressionAllowCall (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2899:26)\n    at Parser.inheritCoverGrammar (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:2285:37)\n    at Parser.parseUpdateExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3004:26)\n    at Parser.parseUnaryExpression (/home/user/projects/REDACTED/app/scripting_formrenderer/node_modules/@ui5/cli/node_modules/esprima/dist/esprima.js:3048:26)' }
ERR! builder:builder Build failed in 524 ms
info builder:builder Executing cleanup tasks...

⚠️  Process Failed With Error

Error Message:
Unexpected token: punc (.)
codeworrior commented 4 years ago

Thank you for the detailed report. As described in https://github.com/SAP/ui5-builder/issues/514, we plan to replace esprima with some more up-to-date parser implementation and have put this as a task on our backlog.

Closing this issue here as a duplicate.