Closed antoniusostermann closed 7 years ago
Hmm everything seems to be right. The only way I could see this happen if your application directory happens to be in a node_modules folder? That's the only moment when it'll exclude babelrc by default
Could you upload/git push a repo that shows this happening somewhere so I could reproduce it?
Thanks for the input, I tried using sprockets-commoner
in a new repository and thereby found the reason for my problem.
I had to remove Rails.application.config.assets.version
from my asset initializer / asset configuration. After that, everything worked seemlessly.
Setup
Used versions: node 7.2, npm 3.10.9, rails 5, sprockets 3.7, sprockets-rails 3.2, sprockets-commoner 0.6.4, babel-core: 6.13.2, babel-preset-es2015: 6.9.0 .babelrc:
{ "presets": ["es2015"] }
If I understood this gem correctly, I do not need anything else to enable babel with sprockets 3.7 (not >= sprockets 4!).
Issue
My idea is to migrate a very big project bit by bit to es6. So I created a folder
app/assets/javascripts/es6
and activated sprockets-commoner only for this directory:As you can see, I am using the rails configuration for additional precompiles and not a
manifest.js
yet (which seems to become default in sprockets 4).Next, I added a
<%= javascript_include_tag 'es6/application' %>
to myapplication.erb
. So I should be able to put migrated components into my es6-folder and link them in theapplication.js
of my es6-folder, while all other parts of my web application still work.My only problem is that babel does not seem to jump in to compile my es6-stuff. Therefore my
import
-directives also do not work.Example
es6/application.js
es6/foo.js
es6/bar.js
And this is the preprocessed
application.js
file:As you can see, the
require()
seemed to work, andsprockets-commoner
is also loaded, but babel does not jump in.. My rails console does not show any error either.