Skip to content

Commit fbc3a7d

Browse files
authored
Merge pull request #2329 from bgantzler/deprecate-routes-function
Deprecate the routes only version of the config
2 parents e6cde69 + f4b56f4 commit fbc3a7d

File tree

3 files changed

+38
-20
lines changed

3 files changed

+38
-20
lines changed

addon/start-mirage.js

+23
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ export default function startMirage(
5151
// Are they using the routes as the default export
5252
if (baseConfig && baseConfig.length === 0) {
5353
routes = baseConfig;
54+
55+
deprecate(
56+
'The routes only function has been deprecated. Please use the make server version your default export in the config.',
57+
false,
58+
{
59+
id: 'ember-cli-mirage-config-routes-only-export',
60+
for: 'ember-cli-mirage',
61+
since: '2.4.0',
62+
until: '3.0.0',
63+
url: 'https://www.ember-cli-mirage.com/docs/advanced/server-configuration',
64+
}
65+
);
5466
}
5567

5668
// Is the default exported function the makeServer function
@@ -62,6 +74,17 @@ export default function startMirage(
6274
let mirageEnvironment = env['ember-cli-mirage'] || {};
6375

6476
let discoverEmberDataModels = mirageEnvironment.discoverEmberDataModels;
77+
deprecate(
78+
'The discoverEmberDataModels environment variable has been deprecated. See the server configuration section on how to discover models',
79+
discoverEmberDataModels === undefined,
80+
{
81+
id: 'ember-cli-mirage-config-discover-ember-data-models',
82+
for: 'ember-cli-mirage',
83+
since: '2.4.0',
84+
until: '3.0.0',
85+
url: 'https://www.ember-cli-mirage.com/docs/advanced/server-configuration',
86+
}
87+
);
6588
if (discoverEmberDataModels === undefined) {
6689
discoverEmberDataModels = true;
6790
}

test-projects/01-basic-app/config/environment.js

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ module.exports = function (environment) {
4848

4949
ENV.APP.rootElement = '#ember-testing';
5050
ENV.APP.autoboot = false;
51+
52+
ENV['ember-cli-mirage'] = {
53+
discoverEmberDataModels: true,
54+
};
5155
}
5256

5357
if (environment === 'production') {

tests/dummy/app/pods/docs/advanced/server-configuration/template.md

+11-20
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
# Server configuration
22

3-
The MirageJS server is configured for you by ember-cli-mirage. However, if you
4-
need to customize the server you can by creating a makeServer function in the
5-
config.js.
6-
7-
Typically, the `/mirage/config.js` file contains a single default export which
8-
is a function defining all your Mirage route handlers. Ember CLI Mirage then
9-
uses this function, along with all the other modules you've defined in
10-
`mirage/models`, `mirage/fixtures`, `mirage/factories`, and
11-
`mirage/serializers`, to create your Mirage JS server when your app boots up
12-
in development and testing.
13-
14-
You can now opt in to having more control over exactly how your Mirage server
15-
is instantiated using the same code as the mirageJS examples of creating a server
16-
by changing your current default export that represents the routes to a normal function,
17-
then creating a new default export function that creates the mirageJS server.
18-
19-
This new default export function receives a single argument named `config`,
3+
The MirageJS server used to be configured for you by ember-cli-mirage. This has been
4+
deprecated in favor of configuring the server similar to MirageJS.
5+
6+
Typically, the `/mirage/config.js` file contains a default export (no
7+
parameters) which
8+
is a function defining all your Mirage route handlers.
9+
10+
This new default export function receives a single argument usually named `config`,
2011
which contains all the factory/fixture/serializer/model modules that exist
2112
in your project's `/mirage` directory. This saves you from having to import
2213
each module explicitly and then pass it into your Mirage server, just like
@@ -47,9 +38,9 @@ independently of `ember-cli-mirage`.
4738

4839
All the objects from `miragejs` are re-exported in `ember-cli-mirage` such as
4940
`Model`, `belongsTo`, `hasMany` as well as `Fixtures`, `Traits` for example.
50-
These should in the future also be imported directly from `miragejs` as
51-
eventually these re-exports will be removed. This will help align the
52-
`ember-cli-mirage` users with the rest of the Mirage JS community.
41+
These have also been deprecated and you should import directly from `miragejs`.
42+
This will help align the `ember-cli-mirage` users with the rest of the
43+
Mirage JS community.
5344

5445
```javascript
5546
// Example with inline routes

0 commit comments

Comments
 (0)