Skip to content

Instantly share code, notes, and snippets.

Last active Oct 29, 2015
What would you like to do?
WebAssets Filter to compile ES6 to ES5 using DukPY and BabelJS
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function
from webassets.filter import Filter
__all__ = ('BabelJS',)
# NOTE: When using the BabelJS compiler for code
# that needs to run in the browser make sure to add
class BabelJS(Filter):
"""WebAssets filter to compile ES6 to ES5 using DukPY.
can be registered in WebAssets using::
import webassets.filter
it will be available as ``babeljs``
name = 'babeljs'
max_debug_level = None
def setup(self):
import dukpy
except ImportError:
raise EnvironmentError('The "dukpy" package is not installed.')
self.dukpy = dukpy
super(BabelJS, self).setup()
def input(self, _in, out, **kw):
src = self.dukpy.babel_compile(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment