Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:foreign-libs use leads to goog.nodeGlobalRequire issue #201

Open
mfikes opened this issue Oct 20, 2018 · 3 comments
Open

:foreign-libs use leads to goog.nodeGlobalRequire issue #201

mfikes opened this issue Oct 20, 2018 · 3 comments

Comments

@mfikes
Copy link

mfikes commented Oct 20, 2018

If you use :foreign-libs you will encounter an issue with goog.nodeGlobalRequire is not a function that is evidently related to :target :nodejs introduced with 0.9.0.

Repro:

src/aaa.js:

function AAA() {
    return 42;
}

Add to your compiler options:

:foreign-libs [{:file "src/aaa.js"
                         :provides ["aaa"]}]

Bring up the app and a REPL with lein figwheel ios and then repro with

ios:cljs.user=> (require 'aaa)
#object[TypeError TypeError: goog.nodeGlobalRequire is not a function. (In 'goog.nodeGlobalRequire(file)', 'goog.nodeGlobalRequire' is undefined)]
cljs$core$load_file
eval code
eval@[native code]
figwheel$client$utils$eval_helper
nil

This goes away if you comment the :target :nodejs from the compiler options.

@igrishaev
Copy link

thanks @mfikes for reporting it, let me post a screenshot to subscribe to that issue:

screen shot 2018-10-20 at 5 02 55 pm

@mharju
Copy link

mharju commented Jan 17, 2019

Bumped to the same issue. The target: nodejs was added in the commit saying it fixes :closure-defines and :preloads.

To what extent do we need the target: nodejs to accomplish this, specifically the :closure-defines -part. I'm just thinking would it be safe to just remove the target: nodejs from the compiler defs as @mfikes suggested or should this issue be delt with in another way?

@mfikes
Copy link
Author

mfikes commented Jul 24, 2019

Yeah, it seems that, while :target :nodejs provides an easy solution to some issues, it puts the compiler into the wrong mode for other things.

In this particular case it causes the compiler to take the wrong branch here.

You can see that if the compiler took the other branch, things would work by, for the foreign lib described in this issue's description, doing this

ios:cljs.user=> (require 'aaa)
#object[TypeError TypeError: goog.nodeGlobalRequire is not a function. (In 'goog.nodeGlobalRequire(file)', 'goog.nodeGlobalRequire' is undefined)]
cljs$core$load_file
eval code
eval@[native code]
figwheel$client$utils$eval_helper

ios:cljs.user=> (goog/require "aaa")
nil
ios:cljs.user=> (js/AAA)
42

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

No branches or pull requests

3 participants