Comparing version 0.9.6 to 0.9.7
@@ -126,2 +126,4 @@ var assert = require("assert"); | ||
context.setUseProvidesModule(self.useProvidesModule); | ||
return new ModuleReader( | ||
@@ -214,2 +216,3 @@ context, | ||
.option("--follow-requires", "Scan modules for required dependencies") | ||
.option("--use-provides-module", "Respect @providesModules pragma in files") | ||
.option("--cache-dir <directory>", "Alternate directory to use for disk cache") | ||
@@ -236,2 +239,3 @@ .option("--no-cache-dir", "Disable the disk cache") | ||
commoner.relativize = options.relativize; | ||
commoner.useProvidesModule = options.useProvidesModule; | ||
commoner.sourceCharset = normalizeCharset(options.sourceCharset); | ||
@@ -238,0 +242,0 @@ commoner.outputCharset = normalizeCharset(options.outputCharset); |
@@ -103,2 +103,11 @@ var assert = require("assert"); | ||
BCp.setUseProvidesModule = function(value) { | ||
Object.defineProperty(this, "useProvidesModule", { | ||
value: !!value | ||
}); | ||
}; | ||
// This default can be overridden by individual BuildContext instances. | ||
BCp.setUseProvidesModule(false); | ||
BCp.setCacheDirectory = function(dir) { | ||
@@ -105,0 +114,0 @@ if (!dir) { |
@@ -77,5 +77,9 @@ var assert = require("assert"); | ||
var reader = this; | ||
return reader.getSourceP(id).then(function(source) { | ||
return reader.context.getProvidedId(source) || id; | ||
}); | ||
if (reader.context.useProvidesModule) { | ||
return reader.getSourceP(id).then(function(source) { | ||
return reader.context.getProvidedId(source) || id; | ||
}); | ||
} else { | ||
return Q(id); | ||
} | ||
}), | ||
@@ -87,7 +91,9 @@ | ||
return reader.getSourceP(id).then(function(source) { | ||
// If the source contains a @providesModule declaration, treat | ||
// that declaration as canonical. Note that the Module object | ||
// returned by readModuleP might have an .id property whose | ||
// value differs from the original id parameter. | ||
id = reader.context.getProvidedId(source) || id; | ||
if (reader.context.useProvidesModule) { | ||
// If the source contains a @providesModule declaration, treat | ||
// that declaration as canonical. Note that the Module object | ||
// returned by readModuleP might have an .id property whose | ||
// value differs from the original id parameter. | ||
id = reader.context.getProvidedId(source) || id; | ||
} | ||
@@ -94,0 +100,0 @@ assert.strictEqual(typeof source, "string"); |
@@ -17,3 +17,3 @@ { | ||
], | ||
"version": "0.9.6", | ||
"version": "0.9.7", | ||
"license": "MIT", | ||
@@ -34,3 +34,3 @@ "homepage": "http://github.com/reactjs/commoner", | ||
"q": "~1.0.1", | ||
"recast": "~0.6.0", | ||
"recast": "~0.7.0", | ||
"commander": "~2.2.0", | ||
@@ -37,0 +37,0 @@ "graceful-fs": "~2.0.3", |
@@ -23,20 +23,31 @@ var assert = require("assert"); | ||
var debugContext = new BuildContext({ | ||
config: { debug: true }, | ||
sourceDir: sourceDir | ||
}, new ReadFileCache(sourceDir)); | ||
// Get a new context. Defaults to setRelativize(true) and setUseProvidesModule(true) | ||
function getNewContext(options) { | ||
var context = new BuildContext({ | ||
config: { debug: options.debug }, | ||
sourceDir: sourceDir | ||
}, new ReadFileCache(sourceDir)); | ||
context.setCacheDirectory(path.join(outputDir, options.cacheDirectory)); | ||
context.setRelativize(options.relative === undefined || options.relative); | ||
context.setUseProvidesModule(options.useProvidesModule === undefined || options.useProvidesModule ); | ||
return context; | ||
} | ||
var releaseContext = new BuildContext({ | ||
config: { debug: false }, | ||
sourceDir: sourceDir | ||
}, new ReadFileCache(sourceDir)); | ||
function getNewDebugContext(options) { | ||
options = options || {}; | ||
options.debug = true; | ||
options.cacheDirectory = ".debug-module-cache"; | ||
return getNewContext(options); | ||
} | ||
debugContext.setCacheDirectory(path.join( | ||
outputDir, ".debug-module-cache")); | ||
function getNewReleaseContext(options) { | ||
options = options || {}; | ||
options.debug = false; | ||
options.cacheDirectory = ".release-module-cache"; | ||
return getNewContext(options); | ||
} | ||
releaseContext.setCacheDirectory(path.join( | ||
outputDir, ".release-module-cache")); | ||
var debugContext = getNewDebugContext(); | ||
debugContext.setRelativize(true); | ||
releaseContext.setRelativize(true); | ||
var releaseContext = getNewReleaseContext(); | ||
@@ -55,6 +66,6 @@ function getProvidedP(id) { | ||
function waitForHelpers(done, helperP) { | ||
function waitForHelpers(done, helperP, contextOptions) { | ||
Q.all([ | ||
helperP(debugContext), | ||
helperP(releaseContext) | ||
helperP(getNewDebugContext(contextOptions)), | ||
helperP(getNewReleaseContext(contextOptions)) | ||
]).done(function() { | ||
@@ -430,2 +441,28 @@ done(); | ||
describe("canonical module identifiers without --use-provides-module", function() { | ||
it("should not be returned by reader.getCanonicalIdP nor reader.readModuleP", function(done) { | ||
function helperP(context) { | ||
console.log(context.useProvidesModule); | ||
var reader = new ModuleReader(context, [ | ||
getProvidedP, | ||
getSourceP | ||
], []); | ||
return Q.spread([ | ||
reader.getCanonicalIdP("widget/share"), | ||
reader.getCanonicalIdP("WidgetShare"), | ||
reader.readModuleP("widget/share").get("id"), | ||
reader.readModuleP("WidgetShare").get("id") | ||
], function(ws1, ws2, ws3, ws4) { | ||
assert.strictEqual(ws1, "widget/share"); | ||
assert.strictEqual(ws2, "WidgetShare"); | ||
assert.strictEqual(ws3, "widget/share"); | ||
assert.strictEqual(ws4, "WidgetShare"); | ||
}); | ||
} | ||
waitForHelpers(done, helperP, {useProvidesModule: false}); | ||
}); | ||
}) | ||
describe("util.flatten", function() { | ||
@@ -432,0 +469,0 @@ it("should flatten deeply nested arrays", function() { |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
94207
2164
1
+ Addedesprima-fb@6001.1001.0-dev-harmony-fb(transitive)
+ Addedrecast@0.7.5(transitive)
- Removedrecast@0.6.10(transitive)
Updatedrecast@~0.7.0