Skip to content

Commit

Permalink
fix: add warning message for ember-source below v4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aklkv committed Nov 3, 2023
1 parent 5448fe0 commit 26f9f93
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
5 changes: 3 additions & 2 deletions ember-engines-router-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"start": "rollup --config --watch"
},
"dependencies": {
"@embroider/addon-shim": "^1.8.4"
"@embroider/addon-shim": "^1.8.4",
"@embroider/macros": "^1.13.2"
},
"devDependencies": {
"@babel/core": "^7.20.7",
Expand All @@ -56,7 +57,7 @@
"rollup": "^3.8.1"
},
"engines": {
"node": "14.* || 16.* || >= 18"
"node": "16.* || 18.* || >= 20"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
37 changes: 26 additions & 11 deletions ember-engines-router-service/src/services/engine-router-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { action, computed } from '@ember/object';
import { reads } from '@ember/object/computed';
import { getOwner } from '@ember/application';
import Evented from '@ember/object/evented';
import { dependencySatisfies } from '@embroider/macros';
import { namespaceEngineRouteName } from '../utils/namespace-engine-route-name';
import { getRootOwner } from '../utils/root-owner';
import { resemblesURL } from '../utils/resembles-url';
Expand Down Expand Up @@ -66,21 +67,35 @@ export default class EngineRouterService extends Service.extend(Evented) {
}

refresh(routeName = this.currentRouteName, ...args) {
if (resemblesURL(routeName)) {
return this.externalRouter.refresh(routeName);
console.log('hello', dependencySatisfies('ember-source', '>= 4.1.0'));
if (dependencySatisfies('ember-source', '>= 4.1.0')) {
if (resemblesURL(routeName)) {
return this.externalRouter.refresh(routeName);
}

return this.externalRouter.refresh(
namespaceEngineRouteName(this._mountPoint, routeName),
...args
);
} else {
assert(
`Refresh method is not available in ember-source below v4.1 ${dependencySatisfies(
'ember-source',
'>= 4.1.0'
)}`
);
}

return this.externalRouter.refresh(
namespaceEngineRouteName(this._mountPoint, routeName),
...args
);
}

refreshExternal(routeName, ...args) {
return this.externalRouter.refresh(
this.getExternalRouteName(routeName),
...args
);
if (dependencySatisfies('ember-source', '>= 4.1.0')) {
return this.externalRouter.refresh(
this.getExternalRouteName(routeName),
...args
);
} else {
assert('Refresh method is not available in ember-source below v4.1');
}
}

transitionTo(routeName, ...args) {
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@
typescript-memoize "^1.0.1"
walk-sync "^3.0.0"

"@embroider/[email protected]", "@embroider/macros@^1.0.0", "@embroider/macros@^1.10.0", "@embroider/macros@^1.13.0", "@embroider/macros@^1.3.0":
"@embroider/[email protected]", "@embroider/macros@^1.0.0", "@embroider/macros@^1.10.0", "@embroider/macros@^1.13.0", "@embroider/macros@^1.13.2", "@embroider/macros@^1.3.0":
version "1.13.2"
resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-1.13.2.tgz#07dda11313a2539f403404881b729e622a80ca17"
integrity sha512-AUgJ71xG8kjuTx8XB1AQNBiebJuXRfhcHr318dCwnQz9VRXdYSnEEqf38XRvGYIoCvIyn/3c72LrSwzaJqknOA==
Expand Down

0 comments on commit 26f9f93

Please sign in to comment.