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

reify

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reify - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

test/export-some.js

73

lib/compiler.js

@@ -113,17 +113,19 @@ var hasOwn = Object.prototype.hasOwnProperty;

parts.push(
"module.import(",
parts.push(toModuleImport(
this.code.slice(decl.source.start,
decl.source.end)
);
decl.source.end),
computeSpecifierMap(decl.specifiers)
));
if (decl.specifiers.length === 0) {
parts.push(");");
return parts.join("");
}
return parts.join("");
};
parts.push(",{");
function computeSpecifierMap(specifiers) {
var specifierMap;
decl.specifiers.forEach(function (s, i) {
var local = s.local.name;
specifiers.forEach(function (s) {
var local =
s.type === "ExportSpecifier" ? s.exported.name :
s.local.name;
var imported =

@@ -133,4 +135,27 @@ s.type === "ImportSpecifier" ? s.imported.name :

s.type === "ImportNamespaceSpecifier" ? "*" :
s.type === "ExportSpecifier" ? s.local.name :
null;
specifierMap = specifierMap || {};
specifierMap[local] = imported;
});
return specifierMap;
}
function toModuleImport(source, specifierMap, returnTrue) {
var parts = ["module.import(", source];
var locals = specifierMap && Object.keys(specifierMap);
if (! locals || locals.length === 0) {
parts.push(");");
return parts.join("");
}
parts.push(",{");
locals.forEach(function (local, i) {
var isLast = i === locals.length - 1;
var imported = specifierMap[local];
var valueArg = "v";

@@ -143,3 +168,2 @@ if (valueArg === local) {

var isLast = i === decl.specifiers.length - 1;
parts.push(

@@ -149,2 +173,3 @@ JSON.stringify(imported),

local, "=", valueArg,
returnTrue ? ";return true" : "",
isLast ? "}" : "},"

@@ -157,3 +182,3 @@ );

return parts.join("");
};
}

@@ -179,3 +204,23 @@ Cp.ExportAllDeclaration = function (decl) {

if (decl.specifiers) {
// TODO
if (decl.source) {
var map = computeSpecifierMap(decl.specifiers);
if (map) {
var newMap = {};
Object.keys(map).forEach(function (local) {
newMap["exports." + local] = map[local];
});
map = newMap;
}
return toModuleImport(
this.code.slice(decl.source.start,
decl.source.end),
map, true
);
} else {
// TODO
}
}

@@ -182,0 +227,0 @@

2

package.json
{
"name": "reify",
"version": "0.0.5",
"version": "0.0.6",
"main": "index.js",

@@ -5,0 +5,0 @@ "author": "Ben Newman <ben@benjamn.com>",

@@ -8,3 +8,3 @@ # re•i•fy <sub>_verb, formal_</sub> [![Build Status](https://travis-ci.org/benjamn/reify.svg?branch=master)](https://travis-ci.org/benjamn/reify)

Well, ok, one caveat: this package isn't ready for production use just yet. As of this writing, the repository is all of two days old! Watch this space to find out when `reify` is safe to use.
Well, ok, one caveat: this package isn't ready for production use just yet. As of this writing, the repository is all of two days old! Watch this space to find out when `reify` is safe to use.

@@ -11,0 +11,0 @@ Installation

@@ -27,2 +27,8 @@ var assert = require("assert");

});
it("should allow named re-exports", function test() {
import { a, v } from "./export-some.js";
assert.strictEqual(a, "a");
assert.strictEqual(v, "b");
});
});

@@ -32,3 +38,3 @@

it("should fire setters if already loaded", function () {
// The "module" module is loaded in ../lib/node.js befoe we begin
// The "module" module is required in ../lib/node.js before we begin
// compiling anything.

@@ -35,0 +41,0 @@ import { Module as M } from "module";

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