Sha256: af2f3d01831a64c33229c37668048a2d349541124b6abad6800d22f3bd934568

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 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

This is more optimized setup for WebPacker. You can restore the old configuration like this:

``` ruby
JsRoutes.setup do |config|
  config.module_type = nil
  config.namespace = 'Routes'
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;
  }
}
```

### JSDoc comment format

New version of js-routes generates function comment in the [JSDoc](https://jsdoc.app) format.
If you have any problems with that disable the annotation:

``` ruby
JsRoutes.setup do |config|
  config.documentation = false
end
```

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
js-routes-2.0.6 VERSION_2_UPGRADE.md
js-routes-2.0.5 VERSION_2_UPGRADE.md
js-routes-2.0.4 VERSION_2_UPGRADE.md
js-routes-2.0.3 VERSION_2_UPGRADE.md
js-routes-2.0.2 VERSION_2_UPGRADE.md
js-routes-2.0.1 VERSION_2_UPGRADE.md
js-routes-2.0.0 VERSION_2_UPGRADE.md