ember-cli / ember-cli-babili

BSD 2-Clause "Simplified" License
4 stars 5 forks source link

`ember build --env production` fails when using ember-power-datepicker #8

Closed pgengler closed 7 years ago

pgengler commented 7 years ago

I'm not sure whether this is an ember-cli-babili problem (because all of the backtrace looks to be in there/dependencies) or with ember-power-datepicker because that's the only addon I've used so far that's had this issue, so I've reported it in both places (see https://github.com/cibernox/ember-power-datepicker/issues/17 for the related issue on ember-power-select).

In short, when ember-power-datepicker is included in an app that uses ember-cli-babili and the config/targets.js file is configured to allow some native ES2015/ES2016 syntax (i.e., only targeting very modern browsers), the production build process fails.

Steps to reproduce (using ember-cli 2.13.1):

The build fails with this error:

Build failed.
The Broccoli Plugin: [BabiliPlugin] failed with:
TypeError: assets/vendor.js: Cannot read property 'scope' of null
    at /Users/pgengler/tmp/babili-test/node_modules/babel-plugin-minify-simplify/lib/index.js:1504:42
    at Array.every (native)
    at genericEarlyExitTransform (/Users/pgengler/tmp/babili-test/node_modules/babel-plugin-minify-simplify/lib/index.js:1473:29)
    at earlyReturnTransform (/Users/pgengler/tmp/babili-test/node_modules/babel-plugin-minify-simplify/lib/index.js:1437:9)
    at PluginPass.exit (/Users/pgengler/tmp/babili-test/node_modules/babel-plugin-minify-simplify/lib/index.js:528:11)
    at newFn (/Users/pgengler/tmp/babili-test/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/Users/pgengler/tmp/babili-test/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/Users/pgengler/tmp/babili-test/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/Users/pgengler/tmp/babili-test/node_modules/babel-traverse/lib/path/context.js:117:8)
    at TraversalContext.visitQueue (/Users/pgengler/tmp/babili-test/node_modules/babel-traverse/lib/context.js:150:16)

The broccoli plugin was instantiated at:
    at BabiliPlugin.Plugin (/Users/pgengler/tmp/babili-test/node_modules/broccoli-plugin/index.js:7:31)
    at BabiliPlugin (/Users/pgengler/tmp/babili-test/node_modules/broccoli-babili/lib/babili-plugin.js:12:5)
    at Class.postprocessTree (/Users/pgengler/tmp/babili-test/node_modules/ember-cli-babili/lib/index.js:25:14)
    at projectOrAddon.addons.reduce (/Users/pgengler/tmp/babili-test/node_modules/ember-cli/lib/utilities/addon-process-tree.js:6:25)
    at Array.reduce (native)
    at addonProcessTree (/Users/pgengler/tmp/babili-test/node_modules/ember-cli/lib/utilities/addon-process-tree.js:4:32)
    at EmberApp.addonPostprocessTree (/Users/pgengler/tmp/babili-test/node_modules/ember-cli/lib/broccoli/ember-app.js:586:12)
    at EmberApp.toTree (/Users/pgengler/tmp/babili-test/node_modules/ember-cli/lib/broccoli/ember-app.js:1691:17)
    at module.exports (/Users/pgengler/tmp/babili-test/ember-cli-build.js:22:14)
    at Builder.setupBroccoliBuilder (/Users/pgengler/tmp/babili-test/node_modules/ember-cli/lib/models/builder.js:56:19)

If you then revert config/targets.js (so that 'ie 9' is listed again) the build succeeds.

pgengler commented 7 years ago

FYI this also happens when installing ember-basic-dropdown instead of ember-power-datepicker (which brings in ember-basic-dropdown as a dependency). Just in case that helps narrow things at all.

bmeurant commented 7 years ago

Hi,

seems related to this issue babel/babili/pull/517. I made a quick test and it seems that bumping babel-preset-babili version from 0.0.12 to 0.1.1 in https://github.com/ember-cli/broccoli-babili fixes it.

scottkidder commented 7 years ago

I am seeing this as well (using ember-power-select which also depends on ember-basic-dropdown)

rwjblue commented 7 years ago

Can you test with the latest version? Many bugs have been fixed in 0.2.0's underlying babili version...

pgengler commented 7 years ago

Confirmed that this is fixed with 0.2.0. Thanks!