mjmlio / gulp-mjml

Add Gulp to your MJML workflow!
MIT License
161 stars 37 forks source link

MJML 4.2 breaks gulp tasks #41

Closed sinklair closed 5 years ago

sinklair commented 5 years ago

Using a gulp task that was working fine up until I updated to MJML 4.2.0. Now I receive the following error if I keep 4.2 in the project

events.js:167
      throw er; // Unhandled 'error' event
      ^
Error: Error in file mjml/email.mjml: mjmlEngine is not a function
The terminal process terminated with exit code: 1

gulp.js looks likes this

var gulp = require('gulp');
var mjmlEngine = require('mjml');
var mjml = require('gulp-mjml');

gulp.task('html', function(){
    gulp.src('mjml/*.mjml')
        .pipe(mjml(mjmlEngine, {minify: true}))
        .pipe(gulp.dest('./output'))
})
sinklair commented 5 years ago

This works fine if I revert to 4.1.2

Michael-wm commented 5 years ago

This seems to be a problem with the way mjml is exporting the default method since 4.2.

You can temporarily fix this by changing line 2 in gulp.js to var mjmlEngine = require('mjml').default

The corresponding bug is referenced here: https://github.com/mjmlio/mjml/issues/1387

iRyusa commented 5 years ago

We did fix the .default on 4.2.1 try to remove it now

On 25 Nov 2018, at 01:49, Sakana Productions notifications@github.com wrote:

@Michael-wm using var mjmlEngine = require('mjml').default didn't work on a new install of mjml and gulp-mjml. Below is my gulpfile.js

var gulp = require('gulp'); var mjmlEngine = require('mjml').default; var mjml = require('gulp-mjml');

gulp.task('default', function(){ gulp.src('mjml/*.mjml') .pipe(mjml(mjmlEngine, {minify: true})) .pipe(gulp.dest('./output')) }) and my package.json

{ "name": "dm-emails", "version": "1.0.0", "main": "index.js", "license": "MIT", "dependencies": { "gulp": "^3.9.1", "gulp-mjml": "^3.0.0", "mjml": "4.2" } } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

sinklair commented 5 years ago

Updated and works great. Thank you