Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Clarification regarding require constraints #11

Open
martinklepsch opened this issue Sep 5, 2015 · 4 comments
Open

Clarification regarding require constraints #11

martinklepsch opened this issue Sep 5, 2015 · 4 comments

Comments

@martinklepsch
Copy link

NOTE: This comment on its own does nothing. But if you stick to the template, that is including the fs module exactly the same way naming it also "fs", the compiler will know how to handle the module and its subcomponents. For example:

// This is bad:
var EventEmitter = require("events").EventEmitter;

// This is good:
var events = require("events");
var EventEmitter = events.EventEmitter;

The description and the example don't fully match up for me. I just tried compiling something with

var f = require("fs")
var cp = require("child_process")

and it worked fine. Is that what's expected?

Also thank you for this project!

@dcodeIO
Copy link
Owner

dcodeIO commented Sep 5, 2015

This only matters when compiling with advanced optimizations, isn't an issue otherwise.

@martinklepsch
Copy link
Author

@dcodeIO Sure. I forgot to say that I compiled with advanced optimizations. :)

@dcodeIO
Copy link
Owner

dcodeIO commented Sep 5, 2015

Ah, ok. Iirc the Closure Compiler team has also added node externs to the compiler, partly based on this package here, so it might be that.

@martinklepsch
Copy link
Author

Oh, that's cool. That said do you know any points of reference for properly writing externs for node modules? I don't quit understand how it deals with the fact that things can be imported under different names...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants