railsware / js-routes

Brings Rails named routes to javascript
http://railsware.github.io/js-routes/
MIT License
1.61k stars 151 forks source link

Failing requests for "No route matches [GET] "/assets/routes.js.map" #277

Closed supairish closed 3 years ago

supairish commented 3 years ago

Hello!

I'm working on upgrading a bit older rails app to 6.1.x and after updating js-routes to the 2.X series I keep seeing failed requests in my logs for

Exception: ActionController::RoutingError: No route matches [GET] "/assets/routes.js.map"

Also, I'm using Sprockets with js-routes still.

As far as I can tell js-routes still works fine.

Is there a way to turn off these source map requests? (I'm assuming that's what that file is)

Cheers

bogdan commented 3 years ago

I am not sure how you setup your Js Route env. Can you specify which configuration method do you use?

It is odd that it is requested for routes file only... And even if it is, it is definetelly something required in production and something that should be generated by webpack or sprockets.

supairish commented 3 years ago

I followed the VERSION_2_UPGRADE.md

JsRoutes.setup do |config|
  # config for "old" way after upgrade to JsRoutes 2.0+
  # see https://github.com/railsware/js-routes/blob/master/VERSION_2_UPGRADE.md
  #
  config.module_type = nil
  config.namespace = 'Routes'
end

Then deleted the Rails caches and reran the generator

rails tmp:clear
rails js:routes
bogdan commented 3 years ago

Where is [GET] "/assets/routes.js.map" request generated?

supairish commented 3 years ago

I'm not sure I thought it was coming from within js-routes

Let me investigate further today and see if I can get you more info

I appreciate your time

supairish commented 3 years ago

Sorry for slow response. The only reference I can find to "routes.js.map" is at the bottom of the generated routes.js file

    Utils.namespace(Root, "Routes", result);
    if (null) {
        Utils.define_module(null, result);
    }
    return result;
})(this);
//# sourceMappingURL=routes.js.map                 <--- HERE

Then it appears chrome/firefox devtools fires off the request for this file which doesn't exist for me.

Is the generator rake task suppose to create this file when using Sprockets or is this assuming I'm using webpack?

Thx

le0pard commented 3 years ago

@supairish source maps generated by js build systems, not by this library. You need check you webpack/sprokets/whatever, where it hide source maps

bogdan commented 3 years ago

@supairish I've got where it is comming from. Can you check the current master's version and see if the error goes away?

supairish commented 3 years ago

@bogdan Yep that got rid of the request/error for me.

Thanks! ✌️😁👍