Coder Social home page Coder Social logo

gulp-remove-use-strict's Introduction

Hi! I'm @azu.

I've worked on Open Source since 2010. I've created 500+ npm pacakges and These are 10 million downloads a year.

I've created and now maintain many open-source projects:

  • textlint is a linter for natural languages
  • Secretlint is a pluggable linting tool to prevent committing credential.
  • HonKit build books using Markdown
  • etc...

Also, I the main writer of some blogs about JavaScript and ECMAScript.

I've written JavaScript books as Open Source in Japanese.

If you want to support me, please see GitHub Sponsors♥️

❓If you want to know about me, create AMA Issue❓

gulp-remove-use-strict's People

Contributors

azu avatar tommcc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gulp-remove-use-strict's Issues

remove use strict does not work

const gulp = require('gulp')
const del = require('del')
const removeUseStrict = require('gulp-remove-use-strict')

gulp.task('remove-strict', ['remove-strict:clean'], function () {
return gulp.src('./dist/static/js/*.js')
.pipe(removeUseStrict())
.pipe(gulp.dest('./dist/newJS/'))
})
gulp.task('remove-strict:clean', [], function () {
return del(['./dist/newJS/'], { force: true })
})

Not working (gulp 4)

Getting this error:

TypeError: through.obj is not a function

Changed this line:

// return through.obj(removeUseStrict);
return through({ objectMode: true }, removeUseStrict);

(at least no error) but still doesn't work, 'use strict' text still present in output.

Interferes with gulp-uglify

I get this error only when using gulp-remove-use-strict.

events.js:160
throw er; // Unhandled 'error' event
^
GulpUglifyError: unable to minify JavaScript
at createError (/Users/sean/dev/web/node_modules/gulp-uglify/lib/create-error.js:6:14)
at wrapper (/Users/sean/dev/web/node_modules/lodash/_createHybridWrapper.js:88:15)
at trycatch (/Users/sean/dev/web/node_modules/gulp-uglify/minifier.js:26:12)
at DestroyableTransform.minify [as _transform] (/Users/sean/dev/web/node_modules/gulp-uglify/minifier.js:76:19)
at DestroyableTransform.Transform._read (/Users/sean/dev/web/node_modules/readable-stream/lib/_stream_transform.js:159:10)
at DestroyableTransform.Transform._write (/Users/sean/dev/web/node_modules/readable-stream/lib/_stream_transform.js:147:83)
at doWrite (/Users/sean/dev/web/node_modules/readable-stream/lib/_stream_writable.js:313:64)
at writeOrBuffer (/Users/sean/dev/web/node_modules/readable-stream/lib/_stream_writable.js:302:5)
at DestroyableTransform.Writable.write (/Users/sean/dev/web/node_modules/readable-stream/lib/_stream_writable.js:241:11)
at Transform.ondata (/Users/sean/dev/web/node_modules/gulp-insert/node_modules/readable-stream/lib/_stream_readable.js:572:20)

Duplicate data property in object literal not allowed in strict mode

Task:

gulp.task('scripts', function() {

function createErrorHandler(name) {
return function (err) {
console.error('Error from ' + name + ' in compress task', err.toString());
};
}

return gulp.src(srcDir + '/app/**/*.js')
.on('error', createErrorHandler('gulp.src'))
.pipe(removeUseStrict())
.on('error', createErrorHandler('remove'))
.pipe(sourcemaps.init())
.pipe(concat('app.min.js'))
//.pipe(gulpif(!dist, uglify()))
.pipe(gulpif(!dist, gulp.dest(devDir + '/scripts/')))
.pipe(gulpif(!dist, connect.reload()))
.pipe(gulpif(dist, uglify())) // gulpif(dist, uglify())
.on('error', createErrorHandler('uglify'))
.pipe(gulpif(dist, stripDebug()))
.on('error', createErrorHandler('strip'))
.pipe(gulpif(!dist, sourcemaps.write('/')))
.pipe(gulpif(dist, gulp.dest(distDir + '/scripts/')))
.on('error', createErrorHandler('gulp.dest'));
});

It gives me this error:

/Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:3872
throw e;
^

Error: Line 26: Duplicate data property in object literal not allowed in strict mode
at throwError (/Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:1161:21)
at throwErrorTolerant (/Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:1172:24)
at parseObjectInitialiser (/Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:1460:25)
at parsePrimaryExpression (/Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:1556:20)
at /Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:3609:38
at trackLeftHandSideExpressionAllowCall (/Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:3504:61)
at parsePostfixExpression (/Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:1703:20)
at /Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:3609:38
at parseUnaryExpression (/Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:1784:16)
at /Users/anshad/Desktop/GitLab/Workspace/FrontEnd/node_modules/remove-use-strict/node_modules/esprima/esprima.js:3609:38

无效,还是一样会添加'use strict';

我的配置如下:

var removeUseStrict = require("gulp-remove-use-strict");

// 压缩js文件
gulp.task('minify-js', function (done) {
    return gulp.src(['./public/**/*.js', '!./public/**/*.min.js'])
        .pipe(babel({
            //将ES6代码转译为可执行的JS代码
            presets: ['es2015'] // es5检查机制
        }))
        .pipe(uglify())
        .pipe(removeUseStrict()) //取消严格模式方法("use strict")
        .pipe(gulp.dest('./public'));
    done();
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.