This package has been deprecated

Author message:

This package is no longer maintained. See gulp-aegean for an alternative up-to-date plugin

gulp-inline-import

0.2.1 • Public • Published

gulp-inline-import

Inline any ES6 import by fetching its resource down to the importing file.

from

import './func1.js';
 
var func2 = function() {
  func1();
}
 
export default func2;

to

var func1 = function() {
  // ...
}
 
var func2 = function() {
  func1();
}
 
export default func2;

Summary

Installation

On your node.js root project folder:

npm install --save-dev gulp-inline-import

Or

yarn install --save-dev gulp-inline-import

Optionnal

Quick full installation

npm install --save-dev gulp gulp-cli gulp-inline-import

Or

yarn install --dev gulp gulp-cli gulp-inline-import

Examples of uses

Example 1: including unnamed imports

cate.js:

import './cry.js';
import './walk.js';
 
var cate = function() {
  cry();
  walk();
 
  console.log('because I am a catto');
};
 
export default cate;

cry.js

var cry = function() {
  console.log('meow >_<');
};
 
export default cry;

walk.js

var walk = function() {
  console.log('Oh is that your keyboard? Let me show you something... Zzz...');
};
 
export default walk;

gulpfile.js

const gulp = require('gulp');
const inlineImport = require('gulp-inline-import');
 
gulp.task('inline', function() {
  return gulp.src('./src/*.js')
    .pipe( inlineImport() )
    .pipe( gulp.dest('./src') );
});

Output of cate.js

var cry = function() {
  console.log('meow >_<');
};
 
var walk = function() {
  console.log('Oh is that your keyboard? Let me show you something... Zzz...');
};
 
var cate = function() {
  cry();
  walk();
 
  console.log('because I am a catto');
};
 
export default cate;

Note

Node packages exists to remove the export statement, like the babel plugin babel-plugin-transform-remove-export .

Options

option type required default possible values description
verbose Boolean no false true,false Enable step by step in-console debug information
maxDepth Integer no 3 Number of times the plugin should go deep inside nested import statements. This prevent circular imports for instance.
allowImportExportEverywhere Boolean no false true,false Let you use import and export statements in the middle of your code instead of strictly at the top or bottom.

Package Sidebar

Install

npm i gulp-inline-import

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

12.4 kB

Total Files

5

Last publish

Collaborators

  • khalyomede