stealjs / steal

Gets JavaScript
https://stealjs.com
MIT License
1.36k stars 522 forks source link

Tree-shaking extension fails for non-named imports #1477

Closed mjstahl closed 5 years ago

mjstahl commented 5 years ago

Assuming an imported file helpers/helpers.js that includes a handfull of imports like so:

// helpers/helpers.js
import 'a.js'
import 'b.js'

In a stache file, use can-import to import the helpers file

<!-- index.stache -->
<can-import from="~/helpers/" />

When loading that stache file the following error will occur.

screen shot 2018-11-21 at 9 06 58 am

This error occurs at https://github.com/stealjs/steal/blob/2488567bcb55a38958ba3877a280ad7202d3e28c/src/extension-tree-shaking.js#L106 because parentImportNames (parentLoad.metadata.importNames) is undefined.

A work around for this is to name the imports.

// helpers/helpers.js
import A from 'a.js'
import B from 'b.js'