Using gulp with tsify and babelify isn't running babel
I have the following gulp task (including all of my requires, as requested):
const gulp = require("gulp");
const browserify = require("browserify");
const tsify = require("tsify");
const sass = require('gulp-sass');
const fs = require('fs');
const uglify = require('gulp-uglify');
const tslint = require('gulp-tslint');
const gutil = require('gulp-util');
const babelify = require("babelify");
gulp.task('js', function () {
return browserify({
entries: paths.ts + 'App/start.ts',
debug: true
}).plugin("tsify")
.transform(babelify.configure({
presets: ["es2015"]
}))
.bundle()
.on('error', swallowError)
.pipe(fs.createWriteStream(jsOutput + "app.js"));
});
with all the of the required modules included in package.json, including babel-preset-es2015. However, the babelify transform isn't doing anything at all, to the extent that I can change "es2015" to be anything and I get the exact same result (es6 output).
I've tried including a .babelrc file with the preset specified, to no effect, as well as several different ways of specifying the babelify transform, including adding in .ts file extensions.
My tsconfig.json has the following:
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
which specifies the output type as ES6.
No errors are thrown during this process, and the typescript is fully transpiled, I'm just left with ES6 code.
您必须告诉Babelify需要考虑的文件扩展名,在这种情况下,TypeScript是.ts
。
// ...
.transform(babelify, {
presets: ['es2015'],
extensions: ['.js', '.ts'] // <-- I have added .js and .ts
})
// ...
链接地址: http://www.djcxy.com/p/32972.html