
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
gulp-strip-import-export
Advanced tools
A gulp plugin that removes ES6-style import and export statements
A gulp plugin that removes ES6-style import and export statements
$ npm install --save-dev gulp-strip-import-export
In your gulpfile.js:
const typescript = require('gulp-typescript');
const stripImportExport = require('gulp-strip-import-export');
const tsproject = typescript.createProject({
module: 'es6',
noImplicitAny: true,
target: 'es2018'
});
gulp.task('build', function () {
return gulp.src(['src/*.ts'])
.pipe(tsproject()).js
.pipe(stripImportExport())
.pipe(gulp.dest('dist/js'));
});
Sourcemaps are supported if you've initialized the sourcemaps module.
const sourcemaps = require('gulp-sourcemaps');
gulp.task('build', function () {
return gulp.src(['src/*.ts'])
.pipe(sourcemaps.init())
.pipe(tsproject()).js
.pipe(stripImportExport())
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/js'));
});
Given an example source:
import { Foo } from './foo';
import { Bar } from './bar';
export class Baz {
constructor() { this.foo = new Foo(); }
}
This plugin produces a file stripped of import and export statements:
class Baz {
constructor() { this.foo = new Foo(); }
}
This plugin is a corner-case plugin designed for one specific use case: you're using Typescript
or Babel to process incoming javascript modules written using ES6-style import and export
statements, and you aren't going to wrap your code with a module system (be it webpack,
requirejs, rollup, etc.). This allows you to produce your final, browser-ready javascript file
by simply concatenating all of the output files in the appropriate order.
This is not a generally useful plugin, but may be useful specifically for projects where you want to minimize the total bytes in the source file -- like js13kgames.
FAQs
A gulp plugin that removes ES6-style import and export statements
We found that gulp-strip-import-export demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.