Skip to content

Commit b88fafa

Browse files
committed
Eliminate node-based config/environment
1 parent 89d5b62 commit b88fafa

10 files changed

Lines changed: 38 additions & 225 deletions

File tree

docs/app/config/environment.ts

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,19 @@
1-
import loadConfigFromMeta from '@embroider/config-meta-loader';
2-
import { assert } from '@ember/debug';
1+
import { setTesting } from '@embroider/macros';
32

4-
const config = loadConfigFromMeta('docs') as unknown;
3+
const config = {
4+
environment: import.meta.env.DEV ? 'development' : 'production',
5+
rootURL: '/',
6+
locationType: 'history',
7+
EmberENV: {} as Record<string, unknown>,
8+
APP: {} as Record<string, unknown>,
9+
};
510

6-
assert(
7-
'config is not an object',
8-
typeof config === 'object' && config !== null,
9-
);
10-
assert(
11-
'modulePrefix was not detected on your config',
12-
'modulePrefix' in config && typeof config.modulePrefix === 'string',
13-
);
14-
assert(
15-
'locationType was not detected on your config',
16-
'locationType' in config && typeof config.locationType === 'string',
17-
);
18-
assert(
19-
'rootURL was not detected on your config',
20-
'rootURL' in config && typeof config.rootURL === 'string',
21-
);
22-
assert(
23-
'APP was not detected on your config',
24-
'APP' in config && typeof config.APP === 'object',
25-
);
11+
export default config;
2612

27-
export default config as {
28-
modulePrefix: string;
29-
podModulePrefix?: string;
30-
locationType: string;
31-
rootURL: string;
32-
APP: Record<string, unknown>;
33-
} & Record<string, unknown>;
13+
export function enterTestMode() {
14+
setTesting(true);
15+
16+
config.locationType = 'none';
17+
config.APP.rootElement = '#ember-testing';
18+
config.APP.autoboot = false;
19+
}

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@ember/test-helpers": "^5.4.1",
3939
"@embroider/core": "^4.4.7",
4040
"@embroider/legacy-inspector-support": "^0.1.3",
41+
"@embroider/macros": "^1.20.2",
4142
"@embroider/vite": "^1.7.2",
4243
"@glimmer/component": "^2.1.1",
4344
"@glimmer/tracking": "^1.0.4",

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-app/app/config/environment.js

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
1-
import loadConfigFromMeta from '@embroider/config-meta-loader';
2-
import { assert } from '@ember/debug';
1+
import { setTesting } from '@embroider/macros';
32

4-
const config = loadConfigFromMeta('test-app');
5-
6-
assert(
7-
'config is not an object',
8-
typeof config === 'object' && config !== null
9-
);
10-
assert(
11-
'modulePrefix was not detected on your config',
12-
'modulePrefix' in config && typeof config.modulePrefix === 'string'
13-
);
14-
assert(
15-
'locationType was not detected on your config',
16-
'locationType' in config && typeof config.locationType === 'string'
17-
);
18-
assert(
19-
'rootURL was not detected on your config',
20-
'rootURL' in config && typeof config.rootURL === 'string'
21-
);
22-
assert(
23-
'APP was not detected on your config',
24-
'APP' in config && typeof config.APP === 'object'
25-
);
3+
const config = {
4+
environment: import.meta.env.DEV ? 'development' : 'production',
5+
rootURL: '/',
6+
locationType: 'history',
7+
EmberENV: {},
8+
APP: {},
9+
};
2610

2711
export default config;
12+
13+
export function enterTestMode() {
14+
setTesting(true);
15+
16+
config.locationType = 'none';
17+
config.APP.rootElement = '#ember-testing';
18+
config.APP.autoboot = false;
19+
}

test-app/config/ember-cli-update.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

test-app/config/ember-try.js

Lines changed: 0 additions & 78 deletions
This file was deleted.

test-app/config/environment.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

test-app/config/optional-features.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

test-app/config/targets.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

test-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@ember/test-helpers": "^5.4.1",
4040
"@embroider/core": "^4.4.7",
4141
"@embroider/legacy-inspector-support": "^0.1.3",
42-
"@embroider/macros": "^1.16.10",
42+
"@embroider/macros": "^1.20.2",
4343
"@embroider/vite": "^1.7.2",
4444
"@glimmer/component": "^2.1.1",
4545
"@rollup/plugin-babel": "^6.1.0",

0 commit comments

Comments
 (0)