bertramdev / asset-pipeline

The core implementation of the asset pipeline for the jvm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BabelJsProcessor false triggering if code contains comments with "export default"

simoncomley opened this issue · comments

commented

We are using a half grails half react setup at the moment for a large project and have been chasing down an issue in our development environment where our bundle-vendors.js never returns from the request and it's just stuck in Pending state when looking at the network requests. Really annoying while developing.

We've tracked it down to the file "./node_modules/react-redux/es/components/connectAdvanced.js" which is one of our dependencies. Further investigation showed that inside that file is a comment (see Line 158 at https://github.com/reduxjs/react-redux/blob/master/src/components/connectAdvanced.js) which doesn't get translated by the time it hits the BabelJsProcessor so the BabelJsProcessor is trying to interpret the vendors file and freaks out completely.

Right now we are having to go into the vendors file delete those two words each time it changes which isn't ideal but better then not being able to develop!

I was wondering if the following check
if(!newEcmascriptKeywordsFound && assetFile instanceof JsAssetFile) { if(!AssetPipelineConfigHolder.config?.enableES6 && ! AssetPipelineConfigHolder.config?."enable-es6") { return input } }

should not have the config check swapped to be the first condition:
if((!AssetPipelineConfigHolder.config?.enableES6 && ! AssetPipelineConfigHolder.config?."enable-es6") || (!newEcmascriptKeywordsFound && assetFile instanceof JsAssetFile){ return input }

This way the check only comes in if we've enabled the need for Babel in config. I might be missing something though.