Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@embroider/router

Package Overview
Dependencies
Maintainers
0
Versions
429
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embroider/router

Lazy loading router

  • 2.1.9-unstable.94a010f
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.7K
decreased by-67.41%
Maintainers
0
Weekly downloads
 
Created
Source

@embroider/router

A tiny extension to the stock Ember Router that detects the presence of lazy route bundles and loads them when needed.

Compatibility

  • Ember.js v3.28 or above
  • Ember CLI v3.28 or above
  • Node.js v16 or above

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.

Limitations

Route "serialize" hook Not Supported

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.

Route Unit Tests may need to be updated

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);
  });
});

Installation

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';

Notes on usage with pods

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.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 11 Sep 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc