gulp-community / gulp-coffee

Coffeescript plugin for gulp
MIT License
226 stars 70 forks source link

coffeescript 2 with transpile + inlined source maps? #91

Open d9k opened 6 years ago

d9k commented 6 years ago

Please include configuration examples to README.md

d9k commented 6 years ago

I'm getting error:

Error: Source map to be applied is missing the "file" property
    at assertProperty (/home/myuser/myproject/node_modules/vinyl-sourcemaps-apply/index.js:36:13)
    at applySourceMap (/home/myuser/myproject/node_modules/vinyl-sourcemaps-apply/index.js:15:3)
    at DestroyableTransform.transform [as _transform] (/home/myuser/myproject/node_modules/gulp-coffee/index.js:41:7)
    at DestroyableTransform.Transform._read (/home/myuser/myproject/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.
js:184:10)

My gulp task:

var gulp    = require('gulp'),
    coffee  = require('gulp-coffee'),
    sourcemaps = require('gulp-sourcemaps');

gulp.task('coffee', function(){
    gulp.src(config.coffeePath + '/**/*.coffee')
        .pipe(sourcemaps.init())
        .pipe(coffee({
          bare: true,
          transpile: {
            presets: [
              // Without any configuration options, babel-preset-env behaves exactly the same as babel-preset-latest (or babel-preset-es2015, babel-preset-es2016, and babel-preset-es2017 together).
              'env',
            ],
            plugins: [
              ["transform-react-jsx"]
            ],
          }
        }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('./static/js'));
});
shnam7 commented 6 years ago

I'm experiencing the same problem. Any progress on this?

yocontra commented 6 years ago

Does adding sourceMap: true, inlineMap: true to the options work? I think they changed this recently - if that fixes it I will update the module.

shnam7 commented 6 years ago

Hi contra, Thanks for the reply. I tried it with following options, but the result is the same.

{transpile: {presets: ['env']}, sourceMap: true, inlineMap: true}
phonowell commented 5 years ago

just got the same problem, any one could help?

brewster1134 commented 4 years ago

➕ 1️⃣

yocontra commented 4 years ago

Couple of pointers to help you all:

brewster1134 commented 4 years ago

i guess my issue was more with just being able to transpile at all... gulp-coffee doesn't support the coffeescript's transpile feature. also, i was unable to get sourcemaps to work with gulp 4... i had to still use the gulp-sourcemaps plugin. i currently don't have my project in a state to test it ATM, but would be good to hear someone confirm it is actually working...

nitely commented 4 years ago

You can use gulp-babel instead of coffeescript transpile option.

Example:

var gulp = require('gulp');
var babel = require('gulp-babel');
var coffee = require('gulp-coffee');

gulp.task('coffee', function() {
  gulp.src('./src/*.coffee', { sourcemaps: true })
    .pipe(coffee({bare: true}))
    .pipe(babel({presets: ['@babel/preset-env']}))
    .pipe(gulp.dest('./public/', { sourcemaps: true }));  // change to , { sourcemaps: '.' } to generate external sourcemaps
});

The transpile option should work, but it does not at the moment.