Sha256: 82de0e7fcd4e8990a933f19288e12c8091548ca5ed3637da8716974a05e657d6

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

## Version 2.0 upgrade notes

### Using ESM module by default

The default setting are now changed:

Setting | Old | New 
--- | --- | ---
module\_type | nil | ESM 
namespace | Routes | nil
documentation | false | true

This is more optimized setup for WebPacker. 
New version of js-routes generates function comment in the [JSDoc](https://jsdoc.app) format.

You can restore the old configuration like this:

``` ruby
JsRoutes.setup do |config|
  config.module_type = nil
  config.namespace = 'Routes'
  config.documentation = false
end
```

However, [ESM+Webpacker](/Readme.md#webpacker) upgrade is recommended. 

### `required_params` renamed

In case you are using `required_params` property, it is now renamed and converted to a method:

``` javascript
// Old style
Routes.post_path.required_params  // => ['id']
// New style
Routes.post_path.requiredParams() // => ['id']
```

### ParameterMissing error rework

`ParameterMissing` is renamed to `ParametersMissing` error and now list all missing parameters instead of just first encountered in its message. Missing parameters are now available via `ParametersMissing#keys` property.

``` javascript
try {
  return Routes.inbox_path();
} catch(error) {
  if (error.name === 'ParametersMissing') {
    console.warn(`Missing route keys ${error.keys.join(', ')}. Ignoring.`);
    return "#";
  } else {
    throw error;
  }
}
```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
js-routes-2.0.7 VERSION_2_UPGRADE.md