1.0.1 • Published 2 years ago

@blfisher/gulp-js-rewrite-static-import v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

What is gulp-js-rewrite-static-import?

A gulp plugin that rewrites ES6 static imports, enabling developers to write imports the way they should appear at runtime.

Installation

npm install @blfisher/gulp-js-rewrite-static-import
npm install shift-codegen shift-parser

Example

Directory Structure

build/
src/
    main/
        Module1.js
        submodule/
            Module2.js
gulpfile.js

Module1.js: BEFORE Rewrite

import Module2 from "@my-package/submodule/Module2";

class Module1
{
    // body omitted...
}

export default Module1;

gulpfile.js

const gulp = require("gulp");
const rewritejs = require("@blfisher/gulp-js-rewrite-static-import").default;
    
function build()
{
    return gulp
        .src("src/main/**/*.js")
        .pipe(rewritejs([{ match: "@my-package", substitute: "." }]))
        .pipe(gulp.dest("build"));
}

exports.default = build;

Module1.js: AFTER Rewrite

import Module2 from "./submodule/Module2";

class Module1
{
    // body omitted...
}

export default Module1;
1.0.1

2 years ago

1.0.0

2 years ago