0.2.1 • Published 6 years ago

gulp-inline-import v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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

optiontyperequireddefaultpossible valuesdescription
verboseBooleannofalsetrue,falseEnable step by step in-console debug information
maxDepthIntegerno3Number of times the plugin should go deep inside nested import statements. This prevent circular imports for instance.
allowImportExportEverywhereBooleannofalsetrue,falseLet you use import and export statements in the middle of your code instead of strictly at the top or bottom.
0.2.1

6 years ago

0.2.0

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago