@meteorjs/reify
Advanced tools
Comparing version 0.23.0-beta.0 to 0.23.0-beta.1
@@ -92,26 +92,46 @@ "use strict"; | ||
// Wrap assignments to exported identifiers with `module.runSetters`. | ||
let modifiedExports = []; | ||
// Identify which exports if any are modified by the assignment. | ||
for (let i = 0; i < nameCount; ++i) { | ||
let name = assignedNames[i]; | ||
if ( | ||
visitor.exportedLocalNames[name] === true && | ||
visitor.exportedLocalNames[name] && | ||
inModuleScope(name) | ||
) { | ||
wrap(visitor, path); | ||
break; | ||
modifiedExports.push(...visitor.exportedLocalNames[name]); | ||
} | ||
} | ||
// Wrap assignments to exported identifiers with `module.runSetters`. | ||
if (modifiedExports.length > 0) { | ||
wrap(visitor, path, modifiedExports); | ||
} | ||
} | ||
function wrap(visitor, path) { | ||
function wrap(visitor, path, names) { | ||
const value = path.getValue(); | ||
if (visitor.magicString !== null) { | ||
let end = ')'; | ||
if (names) { | ||
end = `,[${names.map(n => `"${n}"`).join(',')}])`; | ||
} | ||
visitor.magicString.prependRight( | ||
value.start, | ||
visitor.moduleAlias + ".runSetters(" | ||
).appendLeft(value.end, ")"); | ||
).appendLeft(value.end, end); | ||
} | ||
if (visitor.modifyAST) { | ||
let args = [value]; | ||
if (names) { | ||
let array = { | ||
type: "ArrayExpression", | ||
elements: names.map(n => ({ type: "StringLiteral", value: n })) | ||
}; | ||
args.push(array); | ||
} | ||
path.replace({ | ||
@@ -130,3 +150,3 @@ type: "CallExpression", | ||
}, | ||
arguments: [value] | ||
arguments: args | ||
}); | ||
@@ -133,0 +153,0 @@ } |
@@ -460,8 +460,6 @@ "use strict"; | ||
for (let j = 0; j < localCount; ++j) { | ||
// It's tempting to record the exported name as the value here, | ||
// instead of true, but there can be more than one exported name | ||
// per local variable, and we don't actually use the exported | ||
// name(s) in the assignmentVisitor, so it's not worth the added | ||
// complexity of tracking unused information. | ||
exportedLocalNames[locals[j]] = true; | ||
if (exportedLocalNames[locals[j]] === undefined) { | ||
exportedLocalNames[locals[j]] = []; | ||
} | ||
exportedLocalNames[locals[j]].push(exported); | ||
} | ||
@@ -468,0 +466,0 @@ } |
@@ -120,4 +120,4 @@ "use strict"; | ||
// so we want Module.prototype.runSetters to run each time. | ||
function runSetters(valueToPassThrough) { | ||
Entry.getOrCreate(this.id, this).runSetters(); | ||
function runSetters(valueToPassThrough, names) { | ||
Entry.getOrCreate(this.id, this).runSetters(names, true); | ||
@@ -124,0 +124,0 @@ // Assignments to exported local variables get wrapped with calls to |
@@ -14,2 +14,4 @@ "use strict"; | ||
const REIFY_PACKAGE_NAME = '@meteorjs/reify'; | ||
const DEFAULT_PKG_CONFIG = { | ||
@@ -27,4 +29,4 @@ "cache-directory": ".reify-cache", | ||
const entry = json[name]; | ||
return utils.isObject(entry) && hasOwn.call(entry, "reify") | ||
? SemVer.validRange(entry.reify) | ||
return utils.isObject(entry) && hasOwn.call(entry, REIFY_PACKAGE_NAME) | ||
? SemVer.validRange(entry[REIFY_PACKAGE_NAME]) | ||
: null; | ||
@@ -123,3 +125,3 @@ } | ||
const reify = pkgJSON.reify; | ||
const reify = pkgJSON[REIFY_PACKAGE_NAME]; | ||
@@ -126,0 +128,0 @@ if (reify === false) { |
{ | ||
"name": "@meteorjs/reify", | ||
"version": "0.23.0-beta.0", | ||
"version": "0.23.0-beta.1", | ||
"main": "node/index.js", | ||
@@ -5,0 +5,0 @@ "browser": "lib/empty.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172278
3061