Skip to content

Commit 87dd08b

Browse files
Merge pull request #49 from ember-cli/nvp/minimal-flag-non-default
Add `--minimal` and `--no-compat`
2 parents a4314a3 + 461ef93 commit 87dd08b

41 files changed

Lines changed: 1290 additions & 985 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/node_modules/
2+
/my-app/

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,46 @@ If you have an existing app that you would like to upgrade to use Vite consider
99
```
1010
pnpm dlx ember-cli@latest new my-app-name -b @ember/app-blueprint --pnpm
1111
```
12+
13+
## Options
14+
15+
### `--no-compat`
16+
17+
```
18+
pnpm dlx ember-cli@latest new my-app-name \
19+
--blueprint @ember/app-blueprint@alpha \
20+
--pnpm \
21+
--no-compat
22+
```
23+
24+
Does the following:
25+
- enables `type=module` in package.json (required for vite-ssr, and many ESM tools)
26+
- makes the build and boot _MUCH FASTER_
27+
(in large apps, this can have your app's boot be up to 1 minute faster)
28+
- removes `@embroider/compat`
29+
- removes support for:
30+
- hbs (both for component files, and testing)
31+
- content-for (in the HTML files)
32+
- v1 addons
33+
- node-land config/environment.js
34+
- removes `ember-cli`
35+
- ember-cli brings in a ton of old dependencies, so removing it makes installs much faster
36+
- downside though is that you no longer have scaffolding (`ember g`) -- however, you could use `pnpm dlx ember-cli g ...` (or `npx ember-cli g`)
37+
38+
### `--minimal`
39+
40+
```
41+
pnpm dlx ember-cli@latest new my-app-name \
42+
--blueprint @ember/app-blueprint@alpha \
43+
--pnpm \
44+
--minimal
45+
```
46+
47+
Does the following
48+
- everything listed under `--no-compat`
49+
- Removes all linting, formatting, and testing support
50+
- leaves you with a minimal app that you can use for demos, and PRing to other repositories that have multi-framework support (and probably use other testing tools for that multi-framework support)
51+
- different defaults:
52+
- warp-drive becomes _opt-in_ (pass `--warp-drive` if you want it -- normally requires `--no-warp-drive` to remove)
53+
- ember-welcome-page becomes _opt-in_ (normally requires `--no-welcome` to remove)
54+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<% if (warpDrive) { %>import '@warp-drive/ember/install';
2+
<% } %>import Application from 'ember-strict-application-resolver';
3+
4+
export default class App extends Application {
5+
modules = {
6+
...import.meta.glob('./router.*', { eager: true }),
7+
...import.meta.glob('./templates/**/*', { eager: true }),
8+
...import.meta.glob('./services/**/*', { eager: true }),
9+
}
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
<template>
3+
<h1>Welcome to Ember</h1>
4+
5+
{{outlet}}
6+
7+
</template>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { dirname } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
<% if (warpDrive) { %>import { setConfig } from '@warp-drive/core/build-config';
4+
<% } %>import { buildMacros } from '@embroider/macros/babel';
5+
6+
<% if (warpDrive) { %>const macros = buildMacros({
7+
configure: (config) => {
8+
setConfig(config, {
9+
// for universal apps this MUST be at least 5.6
10+
compatWith: '5.6',
11+
});
12+
},
13+
});
14+
<% } else { %>const macros = buildMacros();
15+
<% } %>
16+
export default {
17+
plugins: [
18+
[
19+
'babel-plugin-ember-template-compilation',
20+
{
21+
compilerPath: 'ember-source/dist/ember-template-compiler.js',
22+
transforms: [...macros.templateMacros],
23+
},
24+
],
25+
[
26+
'module:decorator-transforms',
27+
{
28+
runtime: {
29+
import: import.meta.resolve('decorator-transforms/runtime-esm'),
30+
},
31+
},
32+
],
33+
[
34+
'@babel/plugin-transform-runtime',
35+
{
36+
absoluteRuntime: dirname(fileURLToPath(import.meta.url)),
37+
useESModules: true,
38+
regenerator: false,
39+
},
40+
],
41+
...macros.babelMacros,
42+
],
43+
44+
generatorOpts: {
45+
compact: false,
46+
},
47+
};
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { dirname } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
<% if (warpDrive) { %>import { setConfig } from '@warp-drive/core/build-config';
4+
<% } %>import { buildMacros } from '@embroider/macros/babel';
5+
6+
<% if (warpDrive) { %>const macros = buildMacros({
7+
configure: (config) => {
8+
setConfig(config, {
9+
// for universal apps this MUST be at least 5.6
10+
compatWith: '5.6',
11+
});
12+
},
13+
});
14+
<% } else { %>const macros = buildMacros();
15+
<% } %>
16+
export default {
17+
plugins: [
18+
[
19+
'@babel/plugin-transform-typescript',
20+
{
21+
allExtensions: true,
22+
onlyRemoveTypeImports: true,
23+
allowDeclareFields: true,
24+
},
25+
],
26+
[
27+
'babel-plugin-ember-template-compilation',
28+
{
29+
compilerPath: 'ember-source/dist/ember-template-compiler.js',
30+
transforms: [...macros.templateMacros],
31+
},
32+
],
33+
[
34+
'module:decorator-transforms',
35+
{
36+
runtime: {
37+
import: import.meta.resolve('decorator-transforms/runtime-esm'),
38+
},
39+
},
40+
],
41+
[
42+
'@babel/plugin-transform-runtime',
43+
{
44+
absoluteRuntime: dirname(fileURLToPath(import.meta.url)),
45+
useESModules: true,
46+
regenerator: false,
47+
},
48+
],
49+
...macros.babelMacros,
50+
],
51+
52+
generatorOpts: {
53+
compact: false,
54+
},
55+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<% if (warpDrive) { %>import '@warp-drive/ember/install';<% } %>
2+
import Application from '@ember/application';
3+
import compatModules from '@embroider/virtual/compat-modules';
4+
import Resolver from 'ember-resolver';
5+
import config from '<%= modulePrefix %>/config/environment';
6+
import { importSync, isDevelopingApp, macroCondition } from '@embroider/macros';
7+
import setupInspector from '@embroider/legacy-inspector-support/ember-source-4.12';
8+
9+
if (macroCondition(isDevelopingApp())) {
10+
importSync('./deprecation-workflow');
11+
}
12+
13+
export default class App extends Application {
14+
modulePrefix = config.modulePrefix;
15+
podModulePrefix = config.podModulePrefix;
16+
Resolver = Resolver.withModules(compatModules);
17+
inspector = setupInspector(this);
18+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<% if (notMinimal) { %><% if (typescript) { %>// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2+
// @ts-expect-error
3+
<% } %>import { getGlobalConfig } from '@embroider/macros/src/addon/runtime';
4+
<% } %>
5+
interface Config {
6+
isTesting?: boolean;
7+
environment: string;
8+
modulePrefix: string;
9+
podModulePrefix?: string;
10+
locationType: 'history' | 'hash' | 'none' | 'auto';
11+
rootURL: string;
12+
EmberENV?: Record<string, unknown>;
13+
APP: Record<string, unknown> & { rootElement?: string; autoboot?: boolean };
14+
}
15+
16+
const ENV: Config = {
17+
modulePrefix: '<%= name %>',
18+
environment: import.meta.env.DEV ? 'development' : 'production',
19+
rootURL: '/',
20+
locationType: 'history',
21+
EmberENV: {},
22+
APP: {},
23+
};
24+
25+
export default ENV;
26+
<% if (notMinimal) { %>
27+
export function enterTestMode() {
28+
ENV.locationType = 'none';
29+
ENV.APP.rootElement = '#ember-testing';
30+
ENV.APP.autoboot = false;
31+
32+
<% if (typescript) { %>// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
33+
<% } %>const config = getGlobalConfig()['@embroider/macros'];
34+
35+
<% if (typescript) { %>// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
36+
<% } %>if (config) config.isTesting = true;
37+
}
38+
<% } %>

eslint.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ export default [
2626
eslintConfigPrettier,
2727
{
2828
ignores: [
29+
'my-app/**',
2930
'tests/fixtures/*',
31+
'files/vite.config.*',
3032
'files/ember-cli-build.js',
33+
'files/testem.cjs',
3134
'conditional-files/_js_*',
3235
'conditional-files/_ts_*',
36+
'conditional-files/no-compat/_js_*',
37+
'conditional-files/no-compat/_ts_*',
3338
],
3439
},
3540
];

files/app/templates/application.gts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { pageTitle } from 'ember-page-title';
2-
<% if (welcome) {%>import { WelcomePage } from 'ember-welcome-page';<% } %>
1+
import { pageTitle } from 'ember-page-title';<% if (welcome) {%>
2+
import { WelcomePage } from 'ember-welcome-page';<% } %>
33

44
<template>
55
{{pageTitle "<%= namespace %>"}}<% if (welcome) { %>

0 commit comments

Comments
 (0)