aurelia / webpack-plugin

A plugin for webpack that enables bundling Aurelia applications.
MIT License
90 stars 36 forks source link

fix: broken webpack mangling of harmony imports in production mode #222

Closed vilnytskyi closed 1 year ago

vilnytskyi commented 1 year ago

There is an issue when bundling code with imported aurelia dependency via harmony import. The code like:

import { ConsoleAppender } from 'aurelia-logging-console'
console.log(ConsoleAppender)

bundles into something like:

var a=r("aurelia-logging-console")
console.log(a.A)

while aurelia-logging-console isn't mangled itself to match the export names, so i.I is undefined.

This fix seem to work for all such cases but I am not sure if the original approach was written in such way for some specific cases which I might not be aware of so better to be investigated by core team.There is an issue when bundling code with imported aurelia dependency via harmony import. The code like:

import { ConsoleAppender } from 'aurelia-logging-console'
console.log(ConsoleAppender)

bundles into something like:

var a=r("aurelia-logging-console")
console.log(a.A)

while aurelia-logging-console isn't mangled itself to match the export names, so i.I is undefined.

This fix seem to work for all such cases but I am not sure if the original approach was written in such way for some specific cases which I might not be aware of so better to be investigated by core team.

Credits to @alexander-akait for pointing this out!