use of com.google.javascript.jscomp.JSChunk in project closure-compiler by google.
the class JSChunkGraphBuilder method build.
public JSChunk[] build() {
JSChunk[] chunks = new JSChunk[this.chunks.size()];
for (int i = 0; i < this.chunks.size(); i++) {
String chunkName = this.chunkNames.getOrDefault(i, "m" + i);
JSChunk chunk = chunks[i] = new JSChunk(chunkName);
chunk.add(SourceFile.fromCode(Strings.lenientFormat(this.filenameFormat, i), this.chunks.get(i)));
}
this.graphType.addDependencyEdges(chunks);
return chunks;
}
use of com.google.javascript.jscomp.JSChunk in project closure-compiler by google.
the class ClosureIntegrationTest method testCrossChunkDepCheck_inModule_withRequire.
@Test
public void testCrossChunkDepCheck_inModule_withRequire() {
CompilerOptions options = createCompilerOptions();
options.setClosurePass(true);
ImmutableList<JSChunk> code = ImmutableList.copyOf(JSChunkGraphBuilder.forStar().addChunk("// base").addChunk("goog.module('goog.Foo'); /** @constructor */ exports = function() {};").addChunk("goog.module('goog.Bar'); const Foo = goog.require('goog.Foo'); new Foo();").setFilenameFormat(inputFileNamePrefix + "%s" + inputFileNameSuffix).build());
Compiler compiler = compile(options, code);
assertThat(compiler.getErrors()).isEmpty();
assertThat(compiler.getWarnings()).hasSize(1);
assertWithMessage("Unexpected error " + compiler.getWarnings().get(0)).that(DiagnosticGroups.STRICT_MODULE_DEP_CHECK.matches(compiler.getWarnings().get(0))).isTrue();
}
use of com.google.javascript.jscomp.JSChunk in project closure-compiler by google.
the class ClosureIntegrationTest method testCrossChunkDepCheck_forProvide_withRequire.
@Test
public void testCrossChunkDepCheck_forProvide_withRequire() {
CompilerOptions options = createCompilerOptions();
options.setClosurePass(true);
ImmutableList<JSChunk> code = ImmutableList.copyOf(JSChunkGraphBuilder.forStar().addChunk("// base").addChunk("goog.provide('goog.Foo');/** @constructor */ goog.Foo = function() {};").addChunk("goog.require('goog.Foo'); new goog.Foo();").setFilenameFormat(inputFileNamePrefix + "%s" + inputFileNameSuffix).build());
Compiler compiler = compile(options, code);
assertThat(compiler.getErrors()).isEmpty();
assertThat(compiler.getWarnings()).hasSize(1);
assertWithMessage("Unexpected error " + compiler.getWarnings().get(0)).that(DiagnosticGroups.STRICT_MODULE_DEP_CHECK.matches(compiler.getWarnings().get(0))).isTrue();
}
Aggregations