Skip to content

Commit 2966145

Browse files
committed
Add --minimal and --no-compat
1 parent 4aeb210 commit 2966145

File tree

3 files changed

+358
-2
lines changed

3 files changed

+358
-2
lines changed

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+

index.js

Lines changed: 159 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ module.exports = {
8080
options.packageManager === 'pnpm' && '"--pnpm"',
8181
options.ciProvider && `"--ci-provider=${options.ciProvider}"`,
8282
options.typescript && `"--typescript"`,
83+
options.minimal && `"--minimal"`,
84+
options.noCompat && `"--no-compat"`,
8385
!options.emberData && `"--no-ember-data"`,
8486
!options.warpDrive && `"--no-warp-drive"`,
8587
]
@@ -101,6 +103,37 @@ module.exports = {
101103
execBinPrefix = 'pnpm';
102104
}
103105

106+
let welcome = options.welcome;
107+
let warpDrive = options.warpDrive ?? options.emberData;
108+
let minimal = false;
109+
let compat = true;
110+
/**
111+
* --minimal overrides compat/no-compat
112+
*/
113+
if (options.minimal) {
114+
minimal = true;
115+
compat = false;
116+
117+
// Invert defaults
118+
{
119+
welcome = options.welcome = process.argv.includes('--welcome');
120+
warpDrive =
121+
options.emberData =
122+
options.warpDrive =
123+
process.argv.includes('--ember-data') ||
124+
process.argv.includes('--warp-drive');
125+
}
126+
}
127+
128+
if (!minimal) {
129+
if (options.noCompat) {
130+
compat = false;
131+
}
132+
}
133+
134+
let noCompat = !compat;
135+
let notMinimal = !minimal;
136+
104137
return {
105138
appDirectory: directoryForPackageName(name),
106139
name,
@@ -113,14 +146,18 @@ module.exports = {
113146
options.packageManager !== 'yarn' && options.packageManager !== 'pnpm',
114147
invokeScriptPrefix,
115148
execBinPrefix,
116-
welcome: options.welcome,
149+
welcome,
117150
blueprint: 'app',
118151
blueprintOptions,
119152
lang: options.lang,
120-
warpDrive: options.warpDrive ?? options.emberData,
153+
warpDrive: warpDrive,
121154
ciProvider: options.ciProvider,
122155
typescript: options.typescript,
123156
packageManager: options.packageManager ?? 'npm',
157+
compat,
158+
noCompat,
159+
minimal,
160+
notMinimal,
124161
};
125162
},
126163

@@ -131,6 +168,10 @@ module.exports = {
131168

132169
let files = this._super();
133170

171+
// Locals is where we calculate defaults and such.
172+
// Let's not duplicate that work here
173+
options = this.locals(options);
174+
134175
if (options.ciProvider !== 'github') {
135176
files = files.filter((file) => file.indexOf('.github') < 0);
136177
}
@@ -150,6 +191,43 @@ module.exports = {
150191
files = files.filter((file) => !file.includes('services/.gitkeep'));
151192
}
152193

194+
if (options.noCompat) {
195+
files = files.filter((file) => {
196+
return (
197+
!file.includes('deprecation-workflow') &&
198+
!file.includes('ember-cli') &&
199+
!file.includes('ember-cli-build.js') &&
200+
!file.includes('controllers/') &&
201+
!file.includes('config/environment.js') &&
202+
!file.includes('config/optional-features') &&
203+
!file.includes('config/targets') &&
204+
!file.includes('helpers/')
205+
);
206+
});
207+
}
208+
209+
if (options.minimal) {
210+
files = files.filter((file) => {
211+
return (
212+
!file.includes('.github/') &&
213+
!file.includes('.prettierignore') &&
214+
!file.includes('README') &&
215+
!file.includes('components/') &&
216+
!file.includes('eslint.config') &&
217+
!file.includes('prettierrc') &&
218+
!file.includes('public/') &&
219+
!file.includes('routes/') &&
220+
!file.includes('services/') &&
221+
!file.includes('stylelint') &&
222+
!file.includes('styles/') &&
223+
!file.includes('template-lintrc') &&
224+
!file.includes('testem') &&
225+
!file.includes('tests/') &&
226+
!file.includes('watchman')
227+
);
228+
});
229+
}
230+
153231
this._files = files;
154232

155233
return this._files;
@@ -182,6 +260,85 @@ module.exports = {
182260
updatePackageJson(options, content) {
183261
let contents = JSON.parse(content);
184262

263+
if (options.minimal) {
264+
// Remove linting
265+
{
266+
delete contents.scripts['format'];
267+
delete contents.scripts['lint'];
268+
delete contents.scripts['lint:format'];
269+
delete contents.scripts['lint:fix'];
270+
delete contents.scripts['lint:js'];
271+
delete contents.scripts['lint:js:fix'];
272+
delete contents.scripts['lint:css'];
273+
delete contents.scripts['lint:css:fix'];
274+
delete contents.scripts['lint:hbs'];
275+
delete contents.scripts['lint:hbs:fix'];
276+
277+
delete contents.devDependencies['@babel/eslint-parser'];
278+
delete contents.devDependencies['@eslint/js'];
279+
delete contents.devDependencies['concurrently'];
280+
delete contents.devDependencies['ember-template-lint'];
281+
delete contents.devDependencies['eslint'];
282+
delete contents.devDependencies['eslint-config-prettier'];
283+
delete contents.devDependencies['eslint-plugin-ember'];
284+
delete contents.devDependencies['eslint-plugin-n'];
285+
delete contents.devDependencies['eslint-plugin-qunit'];
286+
delete contents.devDependencies['eslint-plugin-warp-drive'];
287+
delete contents.devDependencies['globals'];
288+
delete contents.devDependencies['prettier'];
289+
delete contents.devDependencies['prettier-plugin-ember-template-tag'];
290+
delete contents.devDependencies['stylelint'];
291+
delete contents.devDependencies['stylelint-config-standard'];
292+
delete contents.devDependencies['typescript-eslint'];
293+
}
294+
// Remove testing
295+
{
296+
delete contents.scripts['test'];
297+
delete contents.devDependencies['@ember/test-helpers'];
298+
delete contents.devDependencies['@ember/test-waiters'];
299+
delete contents.devDependencies['ember-qunit'];
300+
delete contents.devDependencies['qunit'];
301+
delete contents.devDependencies['qunit-dom'];
302+
delete contents.devDependencies['testem'];
303+
}
304+
// Extraneous / non-core deps.
305+
// if folks go minimal, they know what they are doing
306+
{
307+
delete contents.devDependencies['ember-welcome-page'];
308+
delete contents.devDependencies['tracked-built-ins'];
309+
delete contents.devDependencies['ember-page-title'];
310+
delete contents.devDependencies['ember-modifier'];
311+
}
312+
// common-in-the-vite-ecosystem alias
313+
{
314+
contents.scripts.dev = contents.scripts.start;
315+
}
316+
}
317+
if (options.noCompat) {
318+
contents.type = 'module';
319+
contents.engines.node = '>= 24';
320+
delete contents.directories;
321+
delete contents.devDependencies['@ember/string'];
322+
delete contents.devDependencies['@ember/optional-features'];
323+
delete contents.devDependencies['@embroider/compat'];
324+
delete contents.devDependencies['@embroider/config-meta-loader'];
325+
delete contents.devDependencies['ember-resolver'];
326+
// Users should use npx ember-cli instead
327+
delete contents.devDependencies['ember-cli'];
328+
delete contents.devDependencies['ember-cli-babel'];
329+
delete contents.devDependencies['ember-load-initializers'];
330+
// This arguable should still exist, but it's a v1 addon
331+
delete contents.devDependencies['ember-cli-deprecation-workflow'];
332+
333+
// A nice feature of modern apps is using sub-path imports
334+
// Why specify the whole app name, when you can use `#`?
335+
contents.imports = {
336+
'#app/*': './app/*',
337+
'#config': './app/config/environment',
338+
'#components/*': './app/components/*',
339+
};
340+
}
341+
185342
return stringifyAndNormalize(sortPackageJson(contents));
186343
},
187344
};

0 commit comments

Comments
 (0)