StartPolymer / polymer-starter-kit-plus-old

A starting point for building Single-Page Applications with Polymer 1.x
Other
78 stars 26 forks source link

Babel doesn't work when scripts inside .html #37

Open ozasadnyy opened 8 years ago

ozasadnyy commented 8 years ago

Babel doesn't work when scripts inside .html

Expected outcome

I want to write scripts inside .html files of components

Actual outcome

Doesn't work in this way

Steps to reproduce

Put ES6 scripts inside custom element .html

I have tried to fix that, but no really success.

First of all, you don't process .html files with crisper in js-babel task. Here my attempt to fix that (run views task before this one: gulp.task('js', ['views'], require(task('js-babel'))($, gulp)); in gulpfile.js):

module.exports = function ($, gulp) { return function () {
  return gulp.src([
      '.tmp/{scripts,elements}/**/*.html',
      'app/{scripts,elements}/**/*.js',
      '!app/scripts/analytics.js'
    ])
    .pipe($.plumber())
    .pipe($.sourcemaps.init())
    .pipe($.if('*.html', $.crisper())) // Extract JS from .html files
    .pipe($.if('*.js', $.babel({
      presets: ['es2015']
    })))
    .pipe($.sourcemaps.write('.'))
    .pipe(gulp.dest('.tmp'))
    .pipe(gulp.dest('dist'));

It almost works, but after running .pipe($.if('*.js', $.uglify())) in vulcanize task I get next error:

Uncaught SyntaxError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'e'. The type name is invalid.

My project sources are here.

Hope for your help.

JosefJezek commented 8 years ago

Ok, I will fix it...

davidmaxwaterman commented 7 years ago

any news on this?