FAQ Database Discussion Community


Babelify omit file extension on import

reactjs,browserify,ecmascript-6,babel
I am writing a React application with ES6 and JSX. Below is the command I use to browserify my .es6 files into a bundle.js. $ browserify src/es6/app.es6 -t babelify -o build/js/bundle.js When I try to import a component using something like import MenuBar from './menu', I get the error message:...

How to set format as hour in babel.dates.format_date?

python,babel
odoo ERP regroup by day as default : data[k] = babel.dates.format_date(v, format="dd MMM yyyy", locale=context.get('lang', 'en_US')). what i want to do is to change the format date from day to hour format. I try to change the previous code line: data[k] = babel.dates.format_date(v, format="HH dd MMM yyyy", locale=context.get('lang', 'en_US')) but...

How to setup grunt-babel to transpile an entire directory

gruntjs,babel,transpiler
So I have this in my gruntfile: gruntConfig.babel = { options: { sourceMap: true }, dist: { files: { "dist/server.js": "src/*.js" } } }; This correctly transpiles all the js files in src, but it overwrites dist/server.js every time. This must be really simple, but I can't seem to figure...

Using babel and lingua in pyramid

localization,internationalization,pyramid,babel
I've problems with babel and lingua. I want babel/lingua to scan my source folder for specific strings for creating the pot-catalog. This is my setup.py ... requires = [ ... 'Babel', 'lingua', ] extractors = { 'dbas': [ ('**.py', 'python', None ), ('**.pt', 'chameleon', None ), ('static/**', 'ignore', None), ]}...

ES6 - Using babel/traceur with jQuery plugins

javascript,jquery,gulp,ecmascript-6,babel
I want to be able to write ES6 with jQuery plugins and compile the code down to ES5 using Gulp Babel, without having to use Browserify to make them work. For example, I may have a class like this: import $ from 'jquery'; import somePlugin from 'somePlugin'; class myClass {...

Unit testing Flask Babel translations

python,unit-testing,flask,babel
I'd like to do some unit tests to check my flask app translations. I have tried this piece of code: def test_pt_br(self): with app.test_request_context(): app.config['BABEL_DEFAULT_LOCALE'] = 'pt_BR' rv = app.test_client().get('/') assert 'Execute, melhore' in str(rv.data) However, it does not work/pass although the app runs fine. What am I doing wrong?...

How does Python babel round numbers?

python,decimal,rounding,currency,babel
I'm building a financial website with the Flask framework and I'm currently writing unit tests for it. I'm using the Babel package to format money amounts and I hit upon rather strange rounding behaviour. I would expect rounding to be up in case of a 5, or to at least...

Promise.allSettled in babel ES6 implementation

javascript,node.js,ecmascript-6,babel,es6-promise
I'm using babel to transpile my [email protected] code and I'm stuck with promises. I need allSettled-type functionality that I could use in q and bluebird or angular.$q for example. On babel's core-js Promise, there is no allSettled method. Currently I'm using q.allSettled as a workaround: import { allSettled } from...

How to properly bind current object context in ES6 using babelify

ecmascript-6,babel
I'm trying to bind current instance to the class method, please note ES6 syntax. class SomeClass { search() => { ... } } Which is 100% legit code, however babelify doesn't want to compile it SyntaxError: /Users/vladmiller/Projects/test/test/client/test/app/pages/Search.react.js: Unexpected token (50:26) while parsing file: /Users/vladmiller/Projects/test/test/client/test/app/pages/Search.react.js\ Instead now I have to bind...