Security News
OpenJS: “XZ Utils Cyberattack Likely Not an Isolated Incident”
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
@embroider/router
Advanced tools
Weekly downloads
Readme
A tiny extension to the stock Ember Router that detects the presence of lazy route bundles and loads them when needed.
To get code-splitting, your app must build with Embroider. It's safe to use this router in apps that aren't building with Embroider, but it won't do anything.
When using lazily-loaded routes, the serialize
hook on Route
is not supported, because this would require us to load a Route
when someone is only linking to it, not actually visiting it.
Once you enable lazy loading of routes, any Route unit tests that try to lookup('route:your-route-name')
can fail because the route is not necessarily loaded. You can adjust your tests to explicitly import and register the Route:
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
+ import ExampleRoute from 'your-app/routes/example';
module('Unit | Route | example', function (hooks) {
setupTest(hooks);
+ hooks.beforeEach(function () {
+ this.owner.register('route:example', ExampleRoute);
+ });
test('it exists', function (assert) {
let route = this.owner.lookup('route:example');
assert.ok(route);
});
});
ember install @embroider/router
In your router.js
file, import our router instead of the stock one:
-import EmberRouter from '@ember/routing/router';
+import EmberRouter from '@embroider/router';
If you use the pod file layout for your routes, you have to make sure to set a non-undefined podModulePrefix
in your config/environment.js
. podModulePrefix: ''
is also allowed. Otherwise, your pod routes will not be picked up by Embroider.
This project is licensed under the MIT License.
FAQs
Lazy loading router
The npm package @embroider/router receives a total of 20,336 weekly downloads. As such, @embroider/router popularity was classified as popular.
We found that @embroider/router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Company News
Come meet the Socket team at BSidesSF and RSA! We're sponsoring several fun networking events and we would love to see you there.
Security News
OSI is starting a conversation aimed at removing the excuse of the SaaS loophole for companies navigating licensing and the complexities of doing business with open source.