|
1 | 1 | # ember-strict-resolver |
2 | 2 |
|
3 | | -[Short description of the addon.] |
4 | | - |
5 | | -## Compatibility |
6 | | - |
7 | | -- Ember.js v4.12 or above |
8 | | -- Embroider or ember-auto-import v2 |
| 3 | +A polyfill implementation of the upcoming default strict resolver built in to Ember. |
9 | 4 |
|
10 | 5 | ## Installation |
11 | 6 |
|
12 | 7 | ``` |
13 | | -ember install ember-strict-resolver |
| 8 | +npm add ember-strict-resolver |
14 | 9 | ``` |
15 | 10 |
|
16 | 11 | ## Usage |
17 | 12 |
|
18 | | -[Longer description of how to use the addon in apps.] |
| 13 | +In your app.js or app.ts, or wherever you configure your application |
| 14 | +```diff |
| 15 | + import config from '<app-name>/config/environment'; |
| 16 | +- import EmberApp from '@ember/application'; |
| 17 | +- import EmberResolver from 'ember-resolver'; |
| 18 | ++ import EmberApp from 'ember-strict-resolver'; |
| 19 | + |
| 20 | + class TestApp extends EmberApp { |
| 21 | + modulePrefix = config.modulePrefix; |
| 22 | +- Resolver = EmberResolver.withModules({ |
| 23 | +- [`${config.modulePrefix}/router`]: { default: Router }, |
| 24 | +- [`${config.modulePrefix}/services/manual`]: { default: Manual }, |
| 25 | +- }); |
| 26 | + |
| 27 | ++ modules = { |
| 28 | ++ './router': { default: Router }, |
| 29 | ++ './services/manual': { default: SomeService }, |
| 30 | ++ './services/manual-shorthand': SomeOtherService, |
| 31 | ++ |
| 32 | ++ // now import.meta.glob just works |
| 33 | ++ ...import.meta.glob('./services/**/*', { eager: true }), |
| 34 | ++ ...import.meta.glob('./routes/*', { eager: true }), |
| 35 | ++ ...import.meta.glob('./templates/**/*', { eager: true }), |
| 36 | ++ }; |
| 37 | + } |
| 38 | +``` |
| 39 | + |
| 40 | +The type of `modules` is: |
| 41 | +```ts |
| 42 | +{ |
| 43 | + [modulePath: string]: |
| 44 | + | ExportableType |
| 45 | + | { [exportName: string]: ExportableType }; |
| 46 | +}; |
| 47 | +``` |
| 48 | + |
19 | 49 |
|
20 | 50 | ## Contributing |
21 | 51 |
|
|
0 commit comments