0

I am writing the typescript code and want to convert into .min.js file,

After the conversion is getting exports and require an undefined exception. if I will use the latest gulp commands am getting a module exception because am using old node js, because our product using nodejs 6

how to convert the .js.map file and minify to a single file

gulpfile.js

var path = require('path');
var ts = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
const gulp = require('gulp');
const concat = require('gulp-concat');
const jshint = require('gulp-jshint');
let babel = require('gulp-babel');
const map = require('map-stream');
const del = require('del');
const uglify = require('gulp-uglify');
const jasmine = require('gulp-jasmine');
var debug = require("gulp-debug");

var config = {
  src: './Scripts',
  dest: './build',
};



gulp.task('build-sources', function () {
  return gulp.src(path.join(config.src, '/**/*.ts'))
    //  .pipe(sourcemaps.init())
    .pipe(ts.createProject('./tsconfig.json')())
    //   .pipe(sourcemaps.write())
    .pipe(babel({
      presets: ['@babel/env']
    }))
    .pipe(uglify())
    .pipe(concat('bundle.js'))

    .pipe(gulp.dest('build/app/'))
});



gulp.task('css', function () {
  return gulp.src(['styles/css/**.*'])
    .pipe(gulp.dest('build/css/'))
});

gulp.task('images', function () {
  return gulp.src(['styles/images/*'])
    .pipe(gulp.dest('build/images/'))
});
gulp.task('libs', function () {
  return gulp.src(['styles/libs/*'])
    .pipe(gulp.dest('build/libs/'))
});

gulp.task('lint', function () {
  const jshintTotals = jshintTotalReporter();
  return gulp.src(sourceCode)
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.r`enter code here`eporter('jshint-stylish'))
    .pipe(jshintTotals.collect)
    .on('end', jshintTotals.report);
});
gulp.task('test', () =>
  gulp.src([testCasesPath])
    // gulp-jasmine works on filepaths so you can't have any plugins before it
    .pipe(jasmine())
);


gulp.task('clean', function () {
  return del([
    'build/app/',
    'build/css/',
    'build/images/',
    'build/libs/',
  ]);
});

//gulp.task('default', gulp.series('ts'));
//gulp.task('clean', gulp.series('clean'));
gulp.task('build', gulp.series('build-sources'));
//gulp.task('run_Prod_Build', gulp.series('clean', 'css','libs', 'images', 'prod_env_js'));
//gulp.task('run_dev', gulp.series('clean', 'css', 'images','libs', 'dev_env_js'));
Reactgular
  • 52,335
  • 19
  • 158
  • 208
  • Gulp TypeScript requires Node 8+: https://github.com/ivogabe/gulp-typescript/issues/584. Node 6 isn't even in LTS any more, it's past time to upgrade: https://github.com/nodejs/Release – jonrsharpe Jul 09 '19 at 07:37
  • I'm voting to close this question as off-topic because trying to squeeze new features into EoL / deprecated software that has a updated version available should not be encouraged or supported. – GottZ Jul 09 '19 at 08:10
  • if I want to minify typescript to js, please suggest me which is the better way to do, I will follow – user2471037 Jul 09 '19 at 08:46
  • The whole idea of a `.js.map` file is to provide information about a minified file. It should not be part of that minified file. What you're trying to do doesn't make a lot of sense IMHO. – Knelis Jul 09 '19 at 09:59
  • Thanks Knelis, I have tried different ways also , but this old product they are using node 6 ,so if I will use the latest one am getting this error "webassembly is not defined" and I have done different ways but while loading am getting 'exports is not found' sorry to saying am very new in gulp build . Please help me. – user2471037 Jul 09 '19 at 10:29

0 Answers0