Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to use handlebars-helpers in browser, cannot bablify completely with browserify #320

Open
happyvig opened this issue Jun 13, 2018 · 0 comments

Comments

@happyvig
Copy link

Hi,
I need to use handlebars-helpers in my browser web app.

I referred this as per documentation :
https://github.com/doowb/handlebars-helpers-browserify-example

But this didnt had any mention about babelify. Looks like some dependent node_module called 'striptags' used ES6 const notation. I tried adding bablify into the browserify workflow. But the resultant app.js inside gh_pages folder still had const notation and not completely transpiled.

app.js : require('handlebars-helpers')({ handlebars: Handlebars });

_gh_pages/app.js : (notice this file still has const ES6 notation and not 'var' notation)

 .....
  const STATE_PLAINTEXT = Symbol('plaintext');
  const STATE_HTML      = Symbol('html');
  const STATE_COMMENT   = Symbol('comment');

  const ALLOWED_TAGS_REGEX  = /<(\w*)>/g;
  const NORMALIZE_TAG_REGEX = /<\/?([^\s\/>]+)/;

  function striptags(html, allowable_tags, tag_replacement) { ... }
   .....

gulpfile.js

.....
var babelify = require('babelify');
gulp.task('**browserify**', function () {
  var b = browserify({
    entries: './src/app.js',
    debug: false,
    external: 'Handlebars'
  })**.transform(babelify, { presets: ["es2015"],  extensions: ['.js', '.ts'] })**;

  // ignore the internal handlebars require
  b.ignore('handlebars');

  return b.bundle()
    .pipe(source('app.js'))
    .pipe(buffer())
    //.pipe(uglify())
    .pipe(gulp.dest('./_gh_pages/'))
    .pipe(browserSync.stream());
});
......
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant