Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,34 @@ jobs:
- name: Run Tests
run: pnpm test

smoke-tests:
name: ${{ matrix.dir }}
runs-on: ubuntu-latest
needs: "test"
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
dir:
- "vite-with-strict-app"
- "v2-addon"

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install Dependencies
run: pnpm install --no-lockfile
- name: Build Library
run: pnpm build
- name: Run Tests
working-directory: test-apps/${{ matrix.dir }}
run: pnpm test

try-scenarios:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ config/ember-cli-update.json
*.yml
*.md
*.html
/test-apps/
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ember-strict-application-resolver

A polyfill implementation of the upcoming default strict resolver built in to Ember.
A polyfill implementation of [RFC #1132](https://rfcs.emberjs.com/id/1132-default-strict-resolver) -- the upcoming default strict resolver built in to Ember.

## Installation

Expand Down Expand Up @@ -29,6 +29,7 @@ In your app.js or app.ts, or wherever you configure your application
+ './router': { default: Router },
+ './services/manual': { default: SomeService },
+ './services/manual-shorthand': SomeOtherService,
+ './config/environment': { /* config here */ },
+
+ // now import.meta.glob just works
+ ...import.meta.glob('./services/**/*', { eager: true }),
Expand Down Expand Up @@ -88,6 +89,42 @@ export default buildRegistry({
});
```

### `compatToRFC1132`

In V2 Addons, where you likely don't have a `config/enviroment.js` (which is responsible for providing the `modulePrefix`, you may want to re-add the behavior of full apps, which is to auto-discover and convert files and folders into the module format described by [RFC #1132](https://rfcs.emberjs.com/id/1132-default-strict-resolver) -- which can be done with the combination of `@embroider/virtual/compat-modules` and this `compatToRFC1132` utility.

In your app.js or app.ts, or wherever you configure your application
```diff
- import config from '<app-name>/config/environment';
- import EmberApp from '@ember/application';
- import EmberResolver from 'ember-resolver';
import compatModules from '@embroider/virtual/compat-modules';
+ import EmberApp from 'ember-strict-application-resolver';
+ import { compatToRFC1132 } from 'ember-strict-application-resolver/convert';

class YouApp extends EmberApp {
- modulePrefix = config.modulePrefix;
- podModulePrefix = config.podModulePrefix;
- Resolver = EmberResolver.withModules({
- ...compatModules,
- [`${config.modulePrefix}/router`]: { default: Router },
- [`${config.modulePrefix}/services/manual`]: { default: Manual },
- });

+ modules = {
+ // Includes services (and other things in the app-tree merging) from libraries
+ ...compatToRFC1132(compatModules),
+
+ ...import.meta.glob('./services/**/*', { eager: true }),
+ ...import.meta.glob('./routes/*', { eager: true }),
+ ...import.meta.glob('./templates/**/*', { eager: true }),
+ };
}
```

> [!IMPORTANT]
> `compatModules` finds files via the `exports` in package.json, which means to use this in a library, the library must first be built.

## Contributing

See the [Contributing](CONTRIBUTING.md) guide for details.
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { configs } from '@nullvoxpopuli/eslint-configs';
// accommodates: JS, TS, App, Addon, and V2 Addon
export default [
...configs.ember(import.meta.dirname),
{
ignores: ['node_modules', 'dist', 'dist-test', 'test-apps'],
},
{
files: ['**/*.ts'],
rules: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@types/qunit": "^2.19.12",
"babel-plugin-ember-template-compilation": "^2.2.5",
"concurrently": "^9.0.1",
"ember-page-title": "^9.0.3",
"ember-qunit": "^9.0.2",
"ember-resolver": "^13.1.0",
"ember-source": "^6.3.0",
Expand Down
Loading