-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure lazy engines with async routes are handled
Lazy engine routes are initially promises which resolve to route instances once the modules are loaded. In these cases prefetch current throws an error 'TypeError: route.prefetch is not a function' since it tries to call prefetch directly on the promise. It seems this used to be handled properly but was lost in a more recent refactor. This is just adding the functionality back. It's important to note that we do not preload the lazy engine assets in the test environment here because preloaded engine routes are not promises but the actual route instance. - Adds ember-engines to dev dependencies for testing. - Create a lazy engine in the dummy app. - Make sure we can visit this engine without preloading its assets. Related changes: - Update node for CI to version 10 to satisfy the requirements for ember-engines. - Change CI install command to fix errors when yarn tries to install link dependencies.
- Loading branch information
1 parent
fc5a602
commit ab03a39
Showing
15 changed files
with
676 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/tmp/ | ||
|
||
# dependencies | ||
/node_modules/ | ||
**/node_modules/ | ||
|
||
# misc | ||
/.env* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { module, test } from 'qunit'; | ||
import { visit, currentURL } from '@ember/test-helpers'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
|
||
module('Acceptance | lazy engine', function(hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
test('it can load an async route from a lazy loaded engine', async function(assert) { | ||
await visit('/lazy-engine'); | ||
|
||
assert.equal(currentURL(), '/lazy-engine'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Engine from 'ember-engines/engine'; | ||
import loadInitializers from 'ember-load-initializers'; | ||
import Resolver from './resolver'; | ||
import config from './config/environment'; | ||
|
||
const { modulePrefix } = config; | ||
const Eng = Engine.extend({ | ||
modulePrefix, | ||
Resolver | ||
}); | ||
|
||
loadInitializers(Eng, modulePrefix); | ||
|
||
export default Eng; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Resolver from 'ember-resolver'; | ||
|
||
export default Resolver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import buildRoutes from 'ember-engines/routes'; | ||
|
||
export default buildRoutes(function() { | ||
// Define your engine's route map here | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{outlet}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-env node */ | ||
'use strict'; | ||
|
||
module.exports = function(environment) { | ||
let ENV = { | ||
modulePrefix: 'lazy-engine', | ||
environment | ||
}; | ||
|
||
return ENV; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-env node */ | ||
'use strict'; | ||
|
||
// eslint-disable-next-line node/no-extraneous-require | ||
const EngineAddon = require('ember-engines/lib/engine-addon'); | ||
|
||
module.exports = EngineAddon.extend({ | ||
name: 'lazy-engine', | ||
|
||
lazyLoading: Object.freeze({ | ||
enabled: true | ||
}), | ||
|
||
isDevelopingAddon() { | ||
return true; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "lazy-engine", | ||
"version": "0.0.0", | ||
"keywords": [ | ||
"ember-addon", | ||
"ember-engine" | ||
], | ||
"ember-addon": { | ||
"engineConfigPath": "ember-config" | ||
}, | ||
"dependencies": { | ||
"ember-cli-babel": "*", | ||
"ember-cli-htmlbars": "*" | ||
} | ||
} |
Oops, something went wrong.