Thanks again all for your replies.  I guess it would help to shed some
light that I am also learning TypeScript and NodeJS for Visual Studio 2013
in the middle of all of this, and one of the settings there is to compile
all javascript within a TypeScript application into a single file.  There
are a lot of pieces to fit together here, so I am just exploring all
possibilities.  I am also checking out CommonJS vs. RequireJS to really
figure out the best way of structuring my application.  As noted, perhaps
combining everything into one file is not the best approach, and leveraging
module-loading is the better way to go.

Thanks again,
Michael


On Mon, May 19, 2014 at 8:51 AM, // ravi <[email protected]> wrote:

> On May 19, 2014, at 8:36 AM, Michael DeMond <[email protected]>
> wrote:
>
> My problem had to do with how I was packaging my code for my Node.js
> application.  Essentially, I was creating a single "application.js" file,
> but the contents would be:
>
> <entry.js>
> <dependency.js>
>
> entry.js was referencing elements in dependency.js, but since
> dependency.js was being emitted *after* entry.js, I was getting a
> ReferenceError at runtime.  By putting my entry.js in a setTimeout (with
> 0ms), I was able to work around this problem.  setTimeout has always seemed
> like a hack to me, so I try to avoid it at all costs, but here it seems
> like a good use of it.
>
>
> Michael, if entry.js has a dependency on dependency.js, then I’d suggest
> require()’ing dependency.js in entry.js (require caching should, in most
> cases, avoid reloading dependency.js even if it is multiply required). Or
> load dependency.js first. I think you may be using “emitted” wrongly,
> above, unless there is actually some event being emitted by dependency.js
> which is listened to in entry.js.
>
> I think you are right in your wariness of using a setTimeout hack. I’d
> suggest not using it here as well.
>
> —ravi
>
>  --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "nodejs" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/nodejs/DFzVn3YBbM0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/010C8A32-ABA9-4BDF-AA3D-DF9DCE2B4EC6%40g8o.net<https://groups.google.com/d/msgid/nodejs/010C8A32-ABA9-4BDF-AA3D-DF9DCE2B4EC6%40g8o.net?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAMgyEdR6rXjJTj-5_7UcKX4dT0RFGDL75hZ4GuTGwdHkmZgrpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to