You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
{
"presets": ["es2015", "react"]
}
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 a javascript_include_tag. This is where I get a runtime error: SyntaxError: Unexpected keyword 'import'.
I tried loading the engine JS via 2 methods:
Directly load the engine JS in the 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 the engine JS in a JavaScript file in the host app (//= require engine/application) and load that file in the javascript_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'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.
The text was updated successfully, but these errors were encountered: