Open richardvenneman opened 7 years ago
It's not supported, commoner only works with things that are placed under the app root, not with gems.
All right, thanks for clearing that up! It seems I'll still have to use browserify-rails for the engine 😀
I'm trying setup
sprockets-commoner
for use with a Rails engine. Haven't had much success so far, unfortunately as it seems the Babel transform are not getting applied.In my engine, I have added the
sprockets-commoner
gem with the following.babelrc
:In my host app I also added the
sprockets-commoner
gem, with the samen.babelrc
. I load the engine JavaScript in the host app with ajavascript_include_tag
. This is where I get a runtime error:SyntaxError: Unexpected keyword 'import'
.I tried loading the engine JS via 2 methods:
javascript_include_tag
(<%= javascript_include_tag 'engine/application', 'data-turbolinks-track' => true %>
). This results in the non-transpiled ES2015 code being loaded in the browser.//= require engine/application
) and load that file in thejavascript_include_tag
instead. This results in some commoner processed code, but without Babel transforms applied (which results in the runtime syntax error on the import statement):I was wondering if this kind of setup is actually supported.
I can setup a sample repo if you'd like.