- Support
bigint
route parameter
import {nft_path} from "./routes"
nft_path(123456789012345678901234567890n)
// => /nfts/123456789012345678901234567890
- Fix rake task for non-esm modules. #316
- Fix deprecator usage in
rake js:routes:typescript
#327 - Migrate to yarn 4
- Deprecated
prefix
option in favor ofdefault_url_options.script_name
. - Add support for
script_name
Rails helper option.
Routes.post_path(1, { script_name: "/myapp" })
// => /myapp/post/1
Routes.configure({
default_url_options: { script_name: "/myapp" }
})
Routes.post_path(1) // => /myapp/post/1
- Rework default banner to use
routes.rb
digest instead of timestamp to ensure consistent routes.js version accross environments. - Use JSDoc Tags in banner by default.
The new default banner:
/**
* @file Generated by js-routes 2.3.3. Based on Rails 7.2.0 routes of App.
* @see https://github.com/railsware/js-routes
* @version e289929fc3fbe69b77aa24c5c3a58fcb1246ad1ea3f4e883f7eafa915ca929f3
*/
- Add
banner
option that allow to control JSDoc on top of generated file. #324.
JsRoutes.setup do |c|
c.banner = -> {
<<~DOC
@file Javascript Route helpers of my magic pony app.
@author Bogdan Gusiev
@license MIT
@version #{JsRoutes.digest}
DOC
}
end
- Add timestamp on when routes.js was generated into banner.
- Fix application specified directly without proc. #323
- Support
optional_definition_params
option. See Related Docs.
- Drop support of Rails 4.x
- Fix support of shakapacker #321.
- Fix support for Rails 8 #319
- Deprecated
rake js:routes:typescript
.rake js:routes
now automatically detects if types support can be used on not.
- Remove sorbet files from repo
- Clearly define files included in gem
- Fix Middleware and Middleware generator bugs #316
- Remove empty object linter warning on DTS module
- Generators: Add
.ts
extension when searching for main JS file of the project
- Fix middleware error for non-modern setup.
- Added Sorbet method signatures.
- Always use DTS module type when calling JsRoutes.definitions or .definitions!. #313
- Leave emoji symbols intact when encoding URI fragment #312
- Use webpacker config variable instead of hardcode #309
- Use
File.exist?
to be compatible with all versions of ruby #310
- Fix ESM Tree Shaking #306
- Prefer to extend
javascript:build
instead ofassets:precompile
. #305 - Add stimulus framework application.js location to generators
- Upgraded eslint and prettier versions #304
- Fix middleware generator #300
- Support
params
special parameter
- Fix rails engine loading if sprockets is not in Gemfile. Fixes #294
- Fixed NIL module type namespace defintion #297.
- The patch may cause a problem with nested
namespace
option. - Ex. Value like
MyProject.Routes
requires to definewindow.MyProject
before importing the routes file
- The patch may cause a problem with nested
- Fix custom file path #295
- Improve generator to update route files on
assets:precompile
and add them to.gitignore by default
#288
- Use Rack Middleware to automatically update routes file in development #288
- This setup is now a default recommended due to lack of any downside comparing to ERB Loader and Manual Setup
- Fix
default_url_options
bug. #290
- Improve browser window object detection. #287
- Added webpacker generator
./bin/rails generate js_routes:webpacker
- Reorganized Readme to describe different setups with their pros and cons more clearly
- Support typescript defintions file aka
routes.d.ts
. See Readme.md for more information.
- Forbid usage of
namespace
option ifmodule_type
is notnil
. #281.
- Remove source map annotation from JS file. Fixes #277
- Generated file is not minified, so it is better to use app side bundler/compressor for source maps
- Disable
namespace
option default for all envs #278
- Fixed backward compatibility issue #276
- Fixed backward compatibility issue #275
- Fixed backward compatibility issue #275
- Fixed backward compatibility issue #274
- Fixed backward compatibility issue #272
Version 2.0 has some breaking changes. See UPGRADE TO 2.0 for guidance.
module_type
option supportdocumentation
option spport- Migrated implementation to typescript
- ESM tree shaking support
- Support camel case
toParam
version ofto_param
property
- Fix compatibility with UMD modules #237 Comment
- Improve compatibility with node environment #269.
- Change default file location configuration to Webpacker if both Webpacker and Sprockets are loaded
- Use app/javascript/routes.js as a default file location if app/javascript directory exists
- Add
default
export for better experience when used as es6 module
- Require engine only when sprockets is loaded #257.
- Allow to specify null namespace and receive routes as an object without assigning it anywhere #247
- Fix a LocalJumpError on secondary initialization of the app #248
- Fix regression of #244 in #243
- Fix escaping inside route parameters and globbing #244
- More informative stack trace for ParameterMissing error #235
- Proper implementation of the :subdomain option in routes generation
- Added JsRoutes namespace to Engine #230
- Fixed bug when js-routes is used in envs without window.location #224
- Implemented Routes.config() and Routes.configure instead of Routes.defaults
New methods support 4 options at the moment:
Routes.configuration(); // =>
/*
{
prefix: "",
default_url_options: {},
special_options_key: '_options',
serializer: function(...) { ... }
}
*/
Routes.configure({
prefix: '/app',
default_url_options: {format: 'json'},
special_options_key: '_my_options_key',
serializer: function(...) { ... }
});
- Improved optional parameters support #216
- Added
application
option #214
- Raise error object with id null passed as route paramter #209
- Sprockets bugfixes #212
- Introduce the special _options key. Fixes #86
- Fixed deprecation varning on Sprockets 3.7
- Bugfix warning on Sprockets 4.0 #202
- Drop support 1.9.3
- Add helper for indexOf, if no native implementation in JS engine
- Add sprockets3 compatibility
- Bugfix domain defaults to path #197
- Use default prefix from
Rails.application.config.relative_url_root
#186 - Bugfix route globbing with optional fragments bug #191
- Bugfix subdomain default parameter in routes #184
- Bugfix infinite recursion in some specific route sets #183
- Additional bugfixes to support all versions of Sprockets: 2.x and 3.x
- Sprockets ~= 3.0 support
- Sprockets ~= 3.0 support
- Support default parameters specified in route.rb file
- Fixes for Rails 5
- Support host, port and protocol inline parameters
- Support host, port and protocol parameters given to a route explicitly
- Remove all incompatibilities between Actiondispatch and js-routes
- Bugfix support nested object null parameters #164
- Bugfix support for nested optional parameters #162 #163
- Bugfix regression in serialisation on blank strings caused by #155
- Ensure routes are loaded, prior to generating them #148
- Use
flat_map
rather thanmap{...}.flatten
#149 - URL escape routes.rb url to fix bad URI(is not URI?) error #150
- Fix for rails 5 - test rails-edge on travis allowing failure #151
- Adds
serializer
option #155
- Support sprockets-3
- Performance optimization of include/exclude options
- Add the compact mode #125
- Add support for host, protocol, and port configuration #137
- Routes path specs #135
- Support Rails 4.2 and Ruby 2.2 #140
- Bugfix Rails Engine subapplication route generation when they are nested #120