-
Notifications
You must be signed in to change notification settings - Fork 8
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
NullPointerException when processing externs files #7
Comments
Thanks for the issue report. Changing the the default behavior to process .cljs and .cljc files only seems a sensible idea, as long as there's an option to change it. |
@weavejester Which kind of option did you have in mind? A boolean switch for "proccess all files" vs. "process only cljs/cljc" files? Or something completely flexible where the user could specify specific subsets of files? (e.g., providing some matching criteria) |
A regular expression for matching filenames seems reasonable to me. Maybe Figwheel already has that? Or at least has a filtering function? |
lein-figwheel expects that all files with .js extension inside its source directories are foreign libraries. And foreign libraries must declare a namespace. In fact, lein-figwheel assumes all .js files have such a namespace declared. And it blindly tries to use it to map the .js file back to a source .cljs file. When the namespace is not declared in the .js file, lein-figwheel bombs out with a NullPointerException when it tries to check if the the source .cljs file exists. This might happen when you put your externs file(s) inside the source directories (this is our case, e.g. https://github.com/magnetcoop/hydrogen-ce/blob/master/src/hyd/client/externs.js) lein-figwheel doesn't try to process such files by default on its own. But when using Duct server.figwheel, it tells lein-figwheel to process all files inside the configured source directories (see https://github.com/duct-framework/server.figwheel/blob/master/src/duct/server/figwheel.clj#L54-L55). Clearly lein-figwheel should be more robust and handle that situation in a more graceful way[1]. On the other hand Duct server.figwheel shouldn't be telling lein-figwheel to process absolutely all files in source directories. It doesn't make sense to process .clj files, .edn files, etc. Probably just those having .cljs/.cljc extension and those declared as foreign libraries. In issue duct-framework#7 James Reeves suggested that instead of hard-coding the list of files to process by lein-figwheel, we should have configurable options with default values. And he suggested using a regular expression for matching filenames. [1] We opened a pull request in lein-figwheel regarding this behaviour, see bhauman/lein-figwheel#739. It has been fixed since then and included in figwheel-sidecar 0.5.20. But Duct server.figwheel is still using figwheel-sidecar 0.5.18
@weavejester What do you think about this patch? d34312b |
There are a few rough edges that would need to be sanded down, but otherwise that looks good. Submit it as a PR. |
lein-figwheel expects files with .js extension inside its source directories to be foreign libraries. And foreign libraries must declare a namespace. In fact, lein-figwheel assumes it, and if it
doesn't find it and can't map the file back to a source .cljs file, it bombs out with a NullPointerException when trying to check for its existance.
This might happen when you put your externs file(s) inside the source directories (this is our case, e.g. https://github.com/magnetcoop/hydrogen-ce/blob/master/src/hyd/client/externs.js)
While lein-figwheel doesn't by default try to process such files on its own, when using Duct server.figwheel it tells lein-figwheel to proccess all files inside the configured source directories (see
https://github.com/duct-framework/server.figwheel/blob/master/src/duct/server/figwheel.clj#L54-L55).
Clearly lein-figwheel should be more robust and handle that situation in a more graceful way[1]. But on the other hand Duct server.figwheel shouldn't be telling lein-figwheel to
process absolutely all files in source directories (but probably just those having .cljs/cljc extension and those declared as foreign libraries).
[1] We have opened a pull request in lein-figwheel regarding this behaviour, see bhauman/lein-figwheel#739
The text was updated successfully, but these errors were encountered: