google / google/closure-compiler
Differentiate Internal/External Require Calls for Common JS Modules
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
I want to compile this very simple piece of code:
``` javascript
// test.js
var crypto = require("crypto");
console.log(crypto.createHash("md5").update("foo").digest("hex"));
```
I know the compiler needs to know where the `crypto` library is, so I'm passing it in via `--externs` (I do _not_ want it to be compiled along with my code, I just want it bluntly passed through).
However, I cannot get this to compile at all. I'm compiling it with:
```
$ java -jar compiler.jar --js="test.js" --process_common_js_modules --common_js_entry_module "test.js" --externs closure-compiler/contrib/nodejs/crypto.js
ERROR - required entry point "module$crypto" never provided
1 error(s), 0 warning(s)
```
where `closure-compiler/contrib/nodejs/crypto.js` is the file in this git repo. I've also tried using `globals.js` to no avail. What am I doing wrong? Looking at the source, it's producing this error because `module$crypto` is not contained in `modulesByProvide` in `src/com/google/javascript/jscomp/Compiler.java:1534`, which seems to just be looping over the files I give it in `--js` and not the externs files.
Version:
```
Closure Compiler (http://github.com/google/closure-compiler)
Version: v20150505
Built on: 2015/05/06 13:09
```
Contributor guide
Assessment
This issue has not been assessed yet.