Skip to content

Uncaught SyntaxError: unexpected token: keyword 'const' when minifying javascript files with constants and backticks ` #35476

@ioweb-gr

Description

@ioweb-gr

Preconditions (*)

Please check this line of code for example

const EVENT_KEY = `.${DATA_KEY}`

  1. Magento 2.4.4

Steps to reproduce (*)

  1. Set the following config options
dev/js/merge_files - 1
dev/js/enable_js_bundling - 1
dev/js/minify_files - 1
  1. Create a few orders
  2. Deploy static files and visit the orders grid
  3. Watch the javascript errors

Expected result (*)

  1. No javascript errors

Actual result (*)

Uncaught SyntaxError: unexpected token: keyword 'const'[collapse.min.js:4:30](https://dev.safeblock.gr/static/version1652532411/adminhtml/Magento/backend/en_US/jquery/bootstrap/collapse.min.js)

Uncaught SyntaxError: unexpected token: keyword 'const'

The minified javascript files become broken like this because there are no delimiters for each new line when backticks are used.

define(["jquery","./util/index","./dom/data","./dom/event-handler","./dom/manipulator","./dom/selector-engine"],function($,Util,Data,EventHandler,Manipulator,SelectorEngine){'use strict';const defineJQueryPlugin=Util.defineJQueryPlugin;const executeAfterTransition=Util.executeAfterTransition;const getElement=Util.getElement;const getSelectorFromElement=Util.getSelectorFromElement;const getElementFromSelector=Util.getElementFromSelector;const reflow=Util.reflow;const typeCheckConfig=Util.typeCheckConfig;const VERSION='5.1.3'
const NAME='collapse'
const DATA_KEY='bs.collapse'
const EVENT_KEY=`.${DATA_KEY}`const DATA_API_KEY='.data-api'
const Default={toggle:true,parent:null}

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions