Babel not running through all JavaScript
See original GitHub issueDescription
When using Riot.js (React/Vue-like component library) it seems my components don’t get transpiled by babel plugin.
Expected behavior
I expected Brunch to compile the JS code as follows:
Compile Riot.js component files into JS -> Run Babel on all JS files -> output JS code.
Actual behavior
It seems the actual behavior is:
Run Babel on .js
files -> Compile Riot.js tags (without passing thru Babel) -> output JS code.
Sample repository (run locally)
package.json
contents
{
"name": "showcase",
"description": "Showcase",
"private": true,
"author": "Brunch",
"version": "0.0.1",
"repository": "",
"scripts": {
"start": "brunch watch --server",
"build": "brunch build --production"
},
"dependencies": {},
"devDependencies": {
"@fdaciuk/ajax": "^2.1.5",
"auto-reload-brunch": "^2",
"babel-brunch": "^6.1.1",
"brunch": "^2",
"clean-css-brunch": "^2",
"normalize.css": "^5.0.0",
"riot": "^3.3.2",
"riot-brunch": "0.0.4",
"riot-route": "^3.1.0",
"sass-brunch": "^2.10.2",
"uglify-js-brunch": "^2"
}
}
brunch config contents
// See http://brunch.io for documentation.
module.exports = {
npm: {
globals: {
riot: 'riot',
route: 'riot-route',
ajax: '@fdaciuk/ajax'
}
},
files: {
javascripts: {joinTo: 'app.js'},
stylesheets: {joinTo: 'app.css'}
},
plugins: {
on: ['riot'],
riot: {
pattern: /\.tag$/
}
},
babel: {
presets: ['es2015'],
plugins: ['transform-async-to-generator']
},
modules: {
autoRequire: { 'app.js': ['initialize'] }
}
};
As Babel plugin simply “jumps” over Riot.js code, what happens is that the output JavaScript remains with pieces of ES6 code.
This also leads to errors when trying to run brunch build --production
, as UglifyJS do not play well with ES6.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Babel doesn't seem to work - Stack Overflow
How are you running babel? Try it in the console, cd into the root directory of your app, and run: babel script.js --out-file...
Read more >babel-loader - webpack
This package allows transpiling JavaScript files using Babel and webpack. Note: Issues with the output should be reported on the Babel Issues tracker....
Read more >What is Babel? · Babel
Babel is a JavaScript compiler. ... Babel has support for the latest version of JavaScript through syntax ... Check out our React preset...
Read more >How to Setup Babel in Node.js - freeCodeCamp
It is friendly, robust, and well-maintained and it's not going ... Basic knowledge of Node.js; Node installed on your machine; Any code or ......
Read more >Quick Set up Babel to Compile Es6+ Javascript codes in Node ...
Sometimes, you do not want to compile all your codes first before executing them; you just want the compiling and executing to happen...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is related to plugin chaining. Fix is coming in
3.0
.PS. Appreciate the
<details>
thing.Workaround, in case anyone needs it:
uglify-js-brunch
package from your package.json;npm install --save-dev closure-compiler-brunch
;brunch-config.js
, add:node_modules
and runnpm install
.Closure Compiler have some basic ES6 support, which means that even with the chaining issues, your ES6 code will still be compiled properly (mostly. There may be issues, more info here).