BundlerMinifier icon indicating copy to clipboard operation
BundlerMinifier copied to clipboard

Errors on Boostrap 5.2.2 javascript minification

Open it-xtech-dev opened this issue 3 years ago • 1 comments

Installed product versions

  • Visual Studio: 2022
  • This extension: 2.9.3

Description

While bundling boostrap 5.2.2 js bundle an error occurs.

Steps to recreate

  1. Download boostrap 5.2.2, https://github.com/twbs/bootstrap/releases/download/v5.2.2/bootstrap-5.2.2-dist.zip
  2. Try to bundle: js\bootstrap.bundle.js
  3. Errors are throw: Strict-mode does not allow duplicate property names: ...(isElement$1(element) ? Manipulator.getDataAttributes(element) : {}) Strict-mode does not allow duplicate property names: ...(typeof config === 'object' ? config : {})

Current behavior

An error occurs on these lines:

    _mergeConfigObj(config, element) {
      const jsonConfig = isElement$1(element) ? Manipulator.getDataAttribute(element, 'config') : {}; // try to parse

      return { ...this.constructor.Default,
        ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
        ...(isElement$1(element) ? Manipulator.getDataAttributes(element) : {}),
        ...(typeof config === 'object' ? config : {})
      };
    }

A error will not occur when changing code like below. This points that there is some improper Minifier / nuglify behavior.

    _mergeConfigObj(config, element) {
      const jsonConfig = isElement$1(element) ? Manipulator.getDataAttribute(element, 'config') : {}; // try to parse

      const prop1  = (isElement$1(element) ? Manipulator.getDataAttributes(element) : {})
      const prop2 = (typeof config === 'object' ? config : {})

      return { ...this.constructor.Default,
        ...(typeof jsonConfig === 'object' ? jsonConfig : {}),
        ...prop1,
        ...prop2
      };
    }

Expected behavior

Should bundle without any problemy

Additional info

Issue seems to be similar to https://github.com/failwyn/BundlerMinifier/issues/2 but specified version (2.9.3) seems not solve the problem.

it-xtech-dev avatar Oct 25 '22 09:10 it-xtech-dev

There are a few issues in the NUglify repo about the spread operator, hopefully updating the version will address this issue; will get it out as soon as I can.

failwyn avatar Nov 10 '22 11:11 failwyn