google / google/closure-compiler

--dependency_mode LOOSE does not work

Open
#3,510 3 comments 0 reactions 0 assignees View on GitHub
internal-issue-created triage-done
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Consider the following files:

greet.js:
`
function greet(msg) {
console.log(msg);
}
exports.greet = greet;
`

hellogreet.js:
`
function hellogreet(msg) {
console.log("Hello " + msg);
}
exports.hellogreet = hellogreet;
`

entrygreet.js:
`
const greetmod = require("./greet.js");
const myname = "John Doe";
greetmod.greet(myname);
`

Compile the files with the following command line:

`java -jar closure-compiler.jar --formatting PRETTY_PRINT --compilation_level SIMPLE_OPTIMIZATIONS --process_common_js_modules --dependency_mode LOOSE entrygreet.js greet.js hellogreet.js`

Expected behaviour: The output should only include contents of files entrygreet.js and greet.js.
Acutal behaviour: The output includes contents of all 3 files, including hellogreet.js.

--dependency_mode LOOSE should add all files that do not goog.provide a namespace and are not modules as --entry_point entries. In this case it is file entrygreet.js. This file depends only on greet.js and nothing depends on hellogreet.js. Therefore the generated output should definitely not include contents of hellogreet.js. So it seems --dependency_mode LOOSE is broken and acts just like --dependency_mode SORT_ONLY.

Can you please investigate and fix the problem?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.