'a is undefined' when compiling a cljs prj with an NPM module under :prod profile - compilation

I followed this howto: http://blob.tomerweller.com/reagent-import-react-components-from-npm and it worked great. I even managed to use one of my own NPM module on top of this example app of re-frame: https://github.com/Day8/re-frame/tree/master/examples/simple/
Starting the resulting app with:
lein clean && lein figwheel
everything works ok, but when I do:
lein do clean, with-profile prod compile
I get a TypeError: a is undefined. Any idea to fix this?
Let me provide you with the code: the bad commit is here,
while both :dev and :prod profiles work OK at this just previous commit.
Update: I managed to fix the compiled version like this (see the commit):
return d.c?d.c(c,v,w):d.call(null,c,v,w)}}(G,r,b,c,d,e)),I=dw(G);rf.b?: […]
};w.b=v;w.c=f;return w}()}(c,d,e,f))};hf.b(ow,ik);hf.b(ow,bp);hf.b(ow,To); […]
function nx(a){var b=window.deps["react-mathjax"],
- c=window.deps.clubexpr.kf;
+ c=window.deps.clubexpr.renderLispAsLaTeX;
return new U(null,3,5,V,[Vj,b.Context,new U(null,4,null)}
function Wv(){return function(a){return function(){return new U(null,6,5,V,[…]
This seems to me a compilation misconfiguration or bug.
Update 2: my code compiles OK if I set :optimizations to :simple (was :advanced). See the cljs compiler doc about this option.
Thanks.

The code that is failing is here.
It looks like you might need to provide externs for clubexpr, so that the Closure Compiler knows not to rewrite renderLispAsLatex as kf. When compiling under :simple, the Closure Compiler doesn't rewrite function names, so this problem wouldn't show up.
As a side note, you probably shouldn't use aget to get objects from the window, aget is designed for array access only. To get objects, you should use goog.object/get. See this post on Checked Array Access for more info on this.

Related

go-swagger restapi/configure_todo_list.go - api.TodoGetHandler undefined error

I am a newbie in go and go-swagger. I am following steps in Simple Server tutorial in goswagger.io.
I am using Ubuntu 18.04, swagger v0.25.0 and go 1.15.6.
Following the same steps, there are a few differences of the files generated. For instance, goswagger.io's has find_todos_okbody.go and get_okbody.go in models but mine does not. Why is that so?
Link to screenshot of my generated files vs
Link to screenshot of generated files by swagger.io
Starting the server as written in the tutorial go install ./cmd/todo-list-server/ gives me the following error. Can anyone please help with this?
# my_folder/swagger-todo-list/restapi
restapi/configure_todo_list.go:41:8: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
restapi/configure_todo_list.go:42:6: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
The first step in goswagger.io todo-list is swagger init spec .... Which directory should I run this command in? I ran it in a newly created folder in my home directory. However, from the page, it shows the path to be ~/go/src/github.com/go-swagger/go-swagger/examples/tutorials/todo-list. I am not sure whether I should use go get ..., git clone ... or create those folders. Can someone advise me?
Thanks.
This is likely the documentation lagging behind the version of the code that you are running. As long as it compiles, the specific files the tool generates isn't so crucial.
This is a compilation error. When you do go install foo it will try to build the foo package as an executable and then move that to your GOPATH/bin directory. It seems that the generated code in restapi/configure_todo_list.go isn't correct for the operations code generated.
All you need to run this tutorial yourself is an empty directory and the swagger tool (not its source code). You run the commands from the root of this empty project. In order not to run into GOPATH problems I would initialise a module with go mod init todo-list-example before doing anything else.
Note that while the todo-list example code exists inside the go-swagger source, it's there just for documenting example usage and output.
What I would advice for #2 is to make sure you're using a properly released version of go-swagger, rather than installing from the latest commit (which happens when you just do a go get), as I have found that to be occasionally unstable.
Next, re-generate the entire server, but make sure you also regenerate restapi/configure_todo_list.go by passing --regenerate-configureapi to your swagger generate call. This file isn't always refreshed because you're meant to modify it to configure your app, and if you changed versions of the tool it may be different and incompatible.
If after that you still get the compilation error, it may be worth submitting a bug report at https://github.com/go-swagger/go-swagger/issues.
Thanks #EzequielMuns. The errors in #2 went away after I ran go get - u -f ./... as stated in
...
For this generation to compile you need to have some packages in your GOPATH:
* github.com/go-openapi/runtime
* github.com/jessevdk/go-flags
You can get these now with: go get -u -f ./...
I think it's an error of swagger code generation. You can do as folloing to fix this:
delete file configure_todo_list.go;
regenerate code.
# swagger generate server -A todo-list -f ./swagger.yml
Then, you can run command go install ./cmd/todo-list-server/, it will succeed.

wxWidget C1189 #error: "wxUSE_ACTIVEX must be defined."

I use VS2015+ wxwideget 3.10 to run a very simple example from wxwidget examples
Yesterday this example was able to run properly but today the example starts to display "Error C1189 #error: "wxUSE_ACTIVEX must be defined." when building it. I didn't change the configuration settings so this thing is quite confusing. Where could be the bugs?
the place where error occured(in chkconf.h):
f/* ensure that MSW-specific settings are defined */
#ifndef wxUSE_ACTIVEX
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_ACTIVEX must be defined."
# else
# define wxUSE_ACTIVEX 0
# endif
#endif /* !defined(wxUSE_ACTIVEX) */
my property settings:
additional include directories: $(WXWIN)\include; $(WXWIN)\include\msvc;
additional library directories: $(WXWIN)\lib\vc_x64_lib
First of all, it's completely impossible that something that worked yesterday stopped working today without anything else. You did change something and, of course, only you know what it was.
Second, all wxUSE_XXX constants are defined in include/wx/msw/setup.h which is copied to lib/vc_x64_lib/mswu/wx (or another similar directory depending on debug/release, lib/DLL build settings) during the library build and is found there by by include/msvc/wx/setup.h. So if it's not defined, the first thing to do is to check that this file didn't get changed somehow (maybe accidentally, although I have trouble imagining how this could happen).

Unable to debug firebase functions

I am trying to debug my js code the runs on firebase functions.
My steps were:
install from functions
npm install --save #google-cloud/debug-agent
added index.js:
require('#google/cloud-debug').start();
when I tryed to run
firebase deploy --only functions
got an error :
Error: Error parsing triggers: Cannot find module '#google/cloud-debu
g'
Try running "npm install" in your functions directory before deployin
try: ndb firebase serve
debugger breakpoints are hit with stack traces visible, note it's a little slow so give the debugger time to instrument the child processes
Additionally I was able to debug cloud functions in isolation using (caps for removed values):
GCLOUD_PROJECT=THE-FIREBASE-PROJECT node --inspect-brk /path/to/functions-framework --target FUNCTION-NAME --port=5000
where functions-framework simply expands to the full path for the installed functions-framework (global in my case) and the working directory contains the target index.js for functions.
Alternately when or where the FIREBASE_CONFIG is needed try this format adjusted to fit:
FIREBASE_CONFIG="{\"databaseURL\":\"https://YOUR-FIREBASE-PROJECT.firebaseio.com\",\"storageBucket\":\"YOUR-FIREBASE-PROJECT.appspot.com\",\"projectId\":\"YOUR-FIREBASE-PROJECT\"}
https://github.com/GoogleChromeLabs/ndb
https://cloud.google.com/functions/docs/functions-framework
https://github.com/GoogleCloudPlatform/functions-framework-nodejs/issues/15
The addition to index.js should be:
require('#google-cloud/debug-agent').start();
or better:
require('#google-cloud/debug-agent').start({ allowExpressions: true });
We recently renamed the module, and it is possible that the instructions you are following are partially out of date. Can you point us to the instructions you have been following?
Also note that support for debugging cloud functions is experimental at this point. There are certain cases (dependent on the traffic to the function) where you function may finish before the debug-agent has a chance to initialize/register. We're currently looking into how to address this.

Compile error but js get generated

This is a new computer setup. All code compile and run on my old comupter.
I have 2 project in my solution than use typescript.
The first compile without problem.
The second one show error on compile but generate js on save.
I have installed vs 2013 update 5 then installed typescript 1.8.5.
I alsow have vs2015 installed.
After vs2015 was installed i have repair the typescript sdk.
They must have 2 different compiler setup and one in my project is not set correctly.
I have dig into the csproj and compare the 2 project but did not find missing/different parameter for typescript ....
It's like it dont take the new version. I get syntax errors in code i know it compile.
if someone had this problem, please help me.
p.s excuse me for my bad english, im french ...
UPDATE: Exemple of code dont compile
public doSomething(errorCallBack?: (failCallback1?: JQueryPromiseCallback<any> | JQueryPromiseCallback<any>[], ...failCallbacksN: Array<JQueryPromiseCallback<any> | JQueryPromiseCallback<any>[]>) => void)
{}
Error :
Error 218 Build: ',' expected.
A reduced sample code that fails to compile:
class Foo {
public doSomething(errorCallBack?: (failCallback1?: any, ...failCallbacksN: Array<any>[]>) => void)
{ }
}
You have major syntax errors in ...failCallbacksN: Array<any>[]>. You need something like ...failCallbacksN: Array<any> e.g.:
class Foo {
public doSomething(errorCallBack?: (failCallback1?: any, ...failCallbacksN: Array<any>) => void)
{ }
}
but js get generated
This is by design. Valid JavaScript will always generate valid TypeScript (even in the presence of errors). The types are considered invisible to the emitter in TypeScript so even in the presence of type errors TypeScript will try and do graceful recovery and generate JavaScript.
More
See Why TypeScript : https://basarat.gitbooks.io/typescript/content/docs/why-typescript.html
I have found than visual studio IDE was using 1.8.9 and the compiler was 1.0. This is why i had such compilation errors.
when i used "tsc -v" command in vs2013 command prompt, it show 1.0.
when i use "where tsc" it show only directory for 1.0 and not the 1.8.9.
so, i have replaced the 1.0 content with 1.8.9 . I dont use 1.0.
Now i have a 1.0 directory wish have 1.8.9 in it.
I think this is not the way it's supposed to be, but i need it to work.
It have a .target file i can modify, but i dont wish to do that.

Why does command "tsc file.ts" give no output and not produce a js file?

I have just started work on a project with some typescript code, and I'm trying to compile the .ts files to .js files from within Linux Mint, but it's not working as I'd expect.
There is a Makefile, but it's not working. Running make returns an error:
tsc --noImplicitAny --noEmitOnError --out client/welcome.js client/welcome.ts
make: *** [client/welcome.js] Error 1
I have also tried creating an example typescript file greeter.ts (as per this official tutorial) containing:
function greeter(person) {
return "Hello, " + person;
}
var user = "Jane User";
document.body.innerHTML = greeter(user);
and tried compiling the ts file to javascript with the command (as per the same tutorial) tsc greeter.ts however the command completes with no output, and no .js file has been created.
I haven't previously worked with typescript at all, and though I've used Makefile's before I don't know much about them either, so I'm hoping it's something really obvious!
I encountered this problem because I had the following line in my tsconfig.json:
"noEmit": true
It worked after removing it.
--noEmitOnError
This means that if there is an error detected no js will be generated. I highly recommend not using this option (Changes a major benefit of why typescript)
More
Check your tsc version. The code you provided works fine with 1.6:
Update
The --version command should work at the very least. See below:

Resources