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.17.0 to 0.17.1

146

lib/runtime/entry.js

@@ -16,5 +16,8 @@ "use strict";

function Entry(exported) {
// The module.exports of the module this Entry is managing.
this.exports = exported;
function Entry(id) {
// The canonical absolute module ID of the module this Entry manages.
this.id = id;
// The Module object this Entry manages, unknown until module.export or
// module.link is called for the first time.
this.module = null;
// Getters for local variables exported from the managed module.

@@ -27,79 +30,20 @@ this.getters = Object.create(null);

this.namespace = utils.createNamespace();
// Map from module.id string to module object for each module this Entry
// is managing.
this.ownerModules = Object.create(null);
// Boolean indicating whether all the modules this Entry is managing
// have finished loading yet. Call entry.hasLoaded() to compute.
this._loaded = false;
}
var Ep = utils.setPrototypeOf(Entry.prototype, null);
var entryMap = Object.create(null);
var weakEntryMap = typeof WeakMap === "function"
? new WeakMap
: new (function FakeWeakMap() {
// A barely functional WeakMap polyfill, just in case. This
// implementation needs to be logically correct only in the specific
// ways that the Entry class uses it. It isn't even "weak" in the
// garbage-collection sense of the word, but that's fine.
var keys = [];
var values = [];
Entry.getOrCreate = function (id, mod) {
var entry = hasOwn.call(entryMap, id)
? entryMap[id]
: entryMap[id] = new Entry(id);
this.get = function (obj) {
var index = keys.indexOf(obj);
if (index >= 0) {
return values[index];
}
};
this.set = function (obj, value) {
var index = keys.indexOf(obj);
if (index >= 0) {
values[index] = value;
} else {
keys.push(obj);
values.push(value);
}
};
});
Entry.get = function (exported) {
if (utils.isObjectLike(exported)) {
var entry = weakEntryMap.get(exported);
if (entry !== void 0) {
return entry;
}
if (utils.isObject(mod) &&
mod.id === entry.id) {
entry.module = mod;
}
return null;
};
Entry.getOrCreate = function (exported, mod) {
var entry = getOrCreate(exported);
if (utils.isObject(mod)) {
entry.ownerModules[mod.id] = mod;
}
return entry;
};
function getOrCreate(exported) {
if (! utils.isObjectLike(exported)) {
// In case the child module modified module.exports, create a temporary
// Entry object so that we can call the entry.addSetters method once,
// which will trigger entry.runSetters(names), so that module.importSync
// behaves as expected.
return new Entry(exported);
}
var entry = weakEntryMap.get(exported);
if (entry !== void 0) {
return entry;
}
var entry = new Entry(exported);
weakEntryMap.set(exported, entry);
return entry;
};
function safeKeys(obj) {

@@ -223,3 +167,3 @@ var keys = Object.keys(obj);

this.namespace[name] = value;
this.exports[name] = value;
this.module.exports[name] = value;
}

@@ -232,11 +176,14 @@ }

if (! utils.getESModule(entry.exports)) {
if (entry.module === null) return;
var exports = entry.module.exports;
if (! utils.getESModule(exports)) {
// If the module entry is managing overrides module.exports, that
// value should be exposed as the .default property of the namespace,
// unless module.exports is marked as an ECMASCript module.
entry.namespace.default = entry.exports;
entry.namespace.default = exports;
setDefault = true;
}
if (! utils.isObjectLike(entry.exports)) {
if (! utils.isObjectLike(exports)) {
return;

@@ -247,3 +194,3 @@ }

names.indexOf("*") >= 0) {
names = Object.keys(entry.exports);
names = Object.keys(exports);
}

@@ -254,7 +201,7 @@

// entry.getters, don't accidentally override entry.namespace.default,
// and only copy own properties from entry.exports.
// and only copy own properties from entry.module.exports.
if (! hasOwn.call(entry.getters, key) &&
! (setDefault && key === "default") &&
hasOwn.call(entry.exports, key)) {
utils.copyKey(key, entry.namespace, entry.exports);
hasOwn.call(exports, key)) {
utils.copyKey(key, entry.namespace, exports);
}

@@ -264,28 +211,2 @@ });

// Called by module.runSetters once the module this Entry is managing has
// finished loading.
Ep.hasLoaded = function () {
if (this._loaded) {
return true;
}
var ids = Object.keys(this.ownerModules);
var idCount = ids.length;
for (var i = 0; i < idCount; ++i) {
var owner = this.ownerModules[ids[i]];
if (! owner.loaded && owner.exports === this.exports) {
// At least one owner module whose exports are still ===
// this.exports has not finished loading, so this this Entry cannot
// be marked as loaded yet.
return false;
}
}
// Set entry._loaded = true only if all the modules in
// entry.ownerModules that are still associated with entry.exports have
// finished loading.
return this._loaded = true;
};
// Called whenever module.exports might have changed, to trigger any

@@ -330,3 +251,3 @@ // setters associated with the newly exported values. The names parameter

var parent = parents[parentIDs[i]];
var parentEntry = Entry.get(parent.exports);
var parentEntry = entryMap[parent.id];
if (parentEntry) {

@@ -441,3 +362,3 @@ parentEntry.runSetters();

// getter, because we need to remember the original value in case
// anyone tampers with entry.exports[name].
// anyone tampers with entry.module.exports[name].
delete setters[key];

@@ -458,15 +379,16 @@ }

var exported = entry.exports;
if (entry.module === null) return;
var exports = entry.module.exports;
if (name === "default" &&
! (utils.getESModule(exported) &&
"default" in exported)) {
return exported;
! (utils.getESModule(exports) &&
"default" in exports)) {
return exports;
}
if (exported == null) {
if (exports == null) {
return;
}
return exported[name];
return exports[name];
}

@@ -473,0 +395,0 @@

@@ -15,5 +15,8 @@ "use strict";

exports.enable = function (mod) {
if (typeof mod.resolve !== "function") {
throw new Error("module.resolve not implemented");
}
if (mod.link !== moduleLink) {
mod.link = moduleLink;
mod.watch = moduleWatch;
mod["export"] = moduleExport;

@@ -33,23 +36,33 @@ mod.exportDefault = moduleExportDefault;

// Shorthand for module.watch(require(id), setters) that accepts just a
// string module identifier `id` rather than the exports object for the
// required module. In the future, this API will replace module.watch, and
// will allow for creating Entry objects before module evaluation, which
// will solve some problems with import cycles and hoisted declarations.
// Calling module.link(id, setters) resolves the given ID using
// module.resolve(id), which should return a canonical absolute module
// identifier string (like require.resolve); then creates an Entry object
// for the child module and evaluates its code (if this is the first time
// it has been imported) by calling module.require(id). Finally, the
// provided setter functions will be called with values exported by the
// module, possibly multiple times when/if those exported values change.
// The module.link name is intended to evoke the "liveness" of the
// exported bindings, since we are subscribing to all future exports of
// the child module, not just taking a snapshot of its current exports.
function moduleLink(id, setters, key) {
return moduleWatch.call(this, this.require(id), setters, key);
}
// If key is provided, it will be used to identify the given setters so
// that they can be replaced if module.watch is called again with the same
// key. This avoids potential memory leaks from import declarations inside
// loops. The compiler generates these keys automatically (and
// deterministically) when compiling nested import declarations.
function moduleWatch(exported, setters, key) {
utils.setESModule(this.exports);
Entry.getOrCreate(this.exports, this);
Entry.getOrCreate(this.id, this);
var absChildId = this.resolve(id);
var childEntry = Entry.getOrCreate(absChildId);
if (utils.isObject(setters)) {
Entry.getOrCreate(exported).addSetters(this, setters, key);
childEntry.addSetters(this, setters, key);
}
var exports = this.require(absChildId);
if (childEntry.module === null) {
childEntry.module = {
id: absChildId,
exports: exports
};
}
childEntry.runSetters();
}

@@ -62,3 +75,3 @@

utils.setESModule(this.exports);
var entry = Entry.getOrCreate(this.exports, this);
var entry = Entry.getOrCreate(this.id, this);
entry.addGetters(getters, constant);

@@ -83,8 +96,7 @@ if (this.loaded) {

// Returns a function suitable for passing as a setter callback to
// module.watch or module.link. If name is an identifier, calling the
// function will set the export of that name to the given value. If the
// name is "*", all properties of the value object will be exported by
// name, except for "default" (use "*+" instead of "*" to include it).
// Discussion of why the "default" property is skipped:
// https://github.com/tc39/ecma262/issues/948
// module.link. If name is an identifier, calling the function will set
// the export of that name to the given value. If the name is "*", all
// properties of the value object will be exported by name, except for
// "default" (use "*+" instead of "*" to include it). Why the "default"
// property is skipped: https://github.com/tc39/ecma262/issues/948
function moduleExportAs(name) {

@@ -111,14 +123,4 @@ var entry = this;

function runSetters(valueToPassThrough) {
var entry = Entry.get(this.exports);
if (entry !== null) {
entry.runSetters();
}
Entry.getOrCreate(this.id, this).runSetters();
if (this.loaded) {
// If this module has finished loading, then we must create an Entry
// object here, so that we can add this module to entry.ownerModules
// by passing it as the second argument to Entry.getOrCreate.
Entry.getOrCreate(this.exports, this);
}
// Assignments to exported local variables get wrapped with calls to

@@ -125,0 +127,0 @@ // module.runSetters, so module.runSetters returns the

@@ -5,3 +5,8 @@ "use strict";

const setDefaults = require("../lib/options").setDefaults;
const Module = module.constructor;
Module.prototype.resolve = function (id) {
return Module._resolveFilename(id, this);
};
let isDefaultsSet = false;

@@ -8,0 +13,0 @@ const parentModule = module.parent || __non_webpack_module__.parent;

{
"name": "reify",
"version": "0.17.0",
"version": "0.17.1",
"main": "node/index.js",

@@ -38,6 +38,6 @@ "browser": "lib/empty.js",

"devDependencies": {
"@babel/core": "^7.0.0-beta.53",
"@babel/parser": "^7.0.0-beta.53",
"@babel/preset-env": "^7.0.0-beta.53",
"babel-plugin-transform-es2015-modules-reify": "^0.16.0",
"@babel/core": "^7.0.0-beta.55",
"@babel/parser": "^7.0.0-beta.55",
"@babel/preset-env": "^7.0.0-beta.55",
"babel-plugin-transform-es2015-modules-reify": "^0.17.0",
"babylon": "^7.0.0-beta.47",

@@ -44,0 +44,0 @@ "lodash": "^4.17.10",

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