Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-rewrite-imports

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-rewrite-imports - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

1

index.d.ts

@@ -14,4 +14,5 @@ /// <reference types="node" />

noRequire?: boolean;
noExportFrom?: boolean;
}
declare const _default: (options: Options) => import("stream").Transform;
export = _default;

26

index.js

@@ -11,3 +11,3 @@ "use strict";

function createRegex() {
return /(?:import(.*?)from ?(?:(?:"([^"]+)")|(?:'([^']+)'));?)|(?:require\((?:(?:"([^"]+)")|(?:'([^']+)'))\))|(?:import\((?:(?:"([^"]+)")|(?:'([^']+)'))\))/g;
return /(?:import(.*?)from ?(?:(?:"([^"]+)")|(?:'([^']+)'));?)|(?:export(.*?)from ?(?:(?:"([^"]+)")|(?:'([^']+)'));?)|(?:require\((?:(?:"([^"]+)")|(?:'([^']+)'))\))|(?:import\((?:(?:"([^"]+)")|(?:'([^']+)'))\))/g;
}

@@ -32,2 +32,8 @@ function pipeRequireSQ(module) {

}
function pipeExportFromSQ(module, exports) {
return "export " + exports + " from '" + module + "';";
}
function pipeExportFromDQ(module, exports) {
return "export " + exports + " from \"" + module + "\";";
}
function resolveRelativePath(inPath, relativeTo, file) {

@@ -69,6 +75,6 @@ if (!relativeTo) {

var imports;
if ((match[4] || match[5]) && !options.noRequire) {
if ((match[7] || match[8]) && !options.noRequire) {
// require(xxx)
srcModule = match[4] || match[5];
importWriter = match[4] ? pipeRequireDQ : pipeRequireSQ;
srcModule = match[7] || match[8];
importWriter = match[7] ? pipeRequireDQ : pipeRequireSQ;
}

@@ -81,6 +87,12 @@ else if ((match[2] || match[3]) && !options.noImportFrom) {

}
else if ((match[6] || match[7]) && !options.noImport) {
else if ((match[5] || match[6]) && !options.noExportFrom) {
// export xxx from yyy
imports = match[4].trim();
srcModule = match[5] || match[6];
importWriter = match[5] ? pipeExportFromDQ : pipeExportFromSQ;
}
else if ((match[9] || match[20]) && !options.noImport) {
// import(xxx)
srcModule = match[6] || match[7];
importWriter = match[6] ? pipeImportDQ : pipeImportSQ;
srcModule = match[9] || match[10];
importWriter = match[9] ? pipeImportDQ : pipeImportSQ;
}

@@ -87,0 +99,0 @@ else {

{
"name": "gulp-rewrite-imports",
"author": "kremi151",
"version": "1.0.6",
"version": "1.1.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": {

# gulp-rewrite-imports
![NPM](https://img.shields.io/npm/v/gulp-rewrite-imports?color=green)
A gulp plugin which allows to rewrite `import` and `require` statements in JavaScript and TypeScript files.

@@ -4,0 +6,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc