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

defroute is undefined when compiled with sourcemap build settings #14

Open
kevincolyar opened this issue Feb 25, 2014 · 6 comments
Open
Labels

Comments

@kevincolyar
Copy link

I'm trying to use secretary in conjunction with om and it works fine using the release cljsbuild settings, however the development settings don't work. I'm not sure if it's the source map that's messing it up or the js include in the index.html.

https://github.com/swannodette/om#using-it

Using the following dev build settings I get an error that defroute is undefined:

:cljsbuild {
  :builds [{:id "dev"
            :source-paths ["src"]
            :compiler {
              :output-to "main.js"
              :output-dir "out"
              :optimizations :none
              :source-map true}}]}
    <script src="main.js" type="text/javascript"></script>
    <script type="text/javascript">goog.require("main.core");</script>
@noprompt
Copy link
Collaborator

Typically I don't use :optimizations :none in favor of :optimizations :whitespace during development in order to avoid having to do the whole <script> song and dance in the HTML. You might try that.

@kevincolyar
Copy link
Author

Hmm, using :optimizations :none seems to be the only way to build it with source maps.

I tried settings :source-map to "main.js.map" which worked but jacked my lein cljsbuild auto times up to 25 seconds for each change (opposed to <1s) because it has to recompile the source map each change (I assume).

@gf3 gf3 reopened this Feb 26, 2014
@noprompt
Copy link
Collaborator

Hmm, using :optimizations :none seems to be the only way to build it with source maps.

@kevincolyar That certainly is not the case. You can see an example here.

I tried settings :source-map to "main.js.map" which worked but jacked my lein cljsbuild auto times up to 25 seconds for each change...

Yeah, that sounds about right. You'll have to decide whether it's worth the wait or not (or get a quad core 😄). A good combination is to use something like austin and work with a bREPL to get faster feedback.

@kevincolyar
Copy link
Author

@noprompt thanks for the example! I'm using om too so that will be helpful.

I'll try messing with my index.html setup to see if I'm doing something wrong there. I'll take another look at austin, too.

Thanks for the help.

@kevincolyar
Copy link
Author

I think I've narrowed down the issue to this line which seems to be required when using a source-map directory.

     <script type="text/javascript">goog.require("activity_log.core");</script>

I don't understand well enough how secretary's defroute macro is working to know why wouldn't be defined when requiring this file that defines my routes.

Here's all of my js includes:

    <script src="http://fb.me/react-0.9.0.js"></script>
    <script src="out/goog/base.js" type="text/javascript"></script>
    <script src="main.js" type="text/javascript"></script>
    <script type="text/javascript">goog.require("activity_log.core");</script>

From what I can tell, the goog.require is starting my application. I don't have to use this line when I build in release because I'm not using source maps output directory:

  :cljsbuild {
              :builds [{:id "dev"
                        :source-paths ["src"]
                        :compiler {
                                   :output-to "main.js"
                                   :output-dir "out"
                                   :optimizations :none
                                   :source-map true}
                        }
                       {:id "release"
                        :source-paths ["src"]
                        :compiler {
                                   :output-to "main.js"
                                   :optimizations :advanced
                                   :pretty-print false
                                   :preamble  ["react/react.min.js"]
                                   :externs  ["react/externs/react.js"]}
                        }]})

@kevincolyar kevincolyar reopened this Feb 26, 2014
@gf3 gf3 added the question label Feb 28, 2014
@Quantisan
Copy link

@kevincolyar I'm thinking that the two builds are compiling to the same output file. Can you please try naming the different builds to output to different js files and update the index.html to point to the right one? i.e. :output-to "main_dev.js for the dev one and update the index.html to use that

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

No branches or pull requests

4 participants