You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-41Lines changed: 60 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ your production app and have FastBoot work.
21
21
22
22
## Installation
23
23
24
-
FastBoot requires Ember 2.3 or higher.
24
+
FastBoot requires Ember 2.3 or higher. It is also preferable that your app is running `ember-cli` 2.12.0 and higher.
25
25
26
26
From within your Ember CLI application, run the following command:
27
27
@@ -31,33 +31,38 @@ ember install ember-cli-fastboot
31
31
32
32
## Running
33
33
34
-
*`ember fastboot --serve-assets`
35
-
* Visit your app at `http://localhost:3000`.
34
+
If your app is running `ember-cli` 2.12.0-beta.1+ you can run as follows:
35
+
36
+
*`ember serve`
37
+
* Visit your app at `http://localhost:42000`
36
38
37
39
You may be shocked to learn that minified code runs faster in Node than
38
40
non-minified code, so you will probably want to run the production
39
41
environment build for anything "serious."
40
42
41
43
```
42
-
ember fastboot --environment production
44
+
ember serve --environment production
43
45
```
44
46
45
47
You can also specify the port (default is 3000):
46
48
47
49
```
48
-
ember fastboot --port 8088
50
+
ember serve --port 8088
49
51
```
50
52
51
-
See `ember help fastboot` for more.
53
+
See `ember help` for more.
52
54
53
-
### With `ember-cli` version 2.12.0-beta.1 and above
54
-
If your app is running ember-cli v2.12.0-beta.1+, you can just use `ember serve` instead of `ember fastboot --serve-assets` and visit at `http://localhost:4200/`.
55
+
### Disabling FastBoot with `ember serve`
55
56
56
57
Optionally you can even disable the fastboot serving at runtime using the `fastboot` query parameter. Example to turn off fastboot serving,
57
58
visit your app at `http://localhost:4200/?fastboot=false`. If you want to turn on fastboot serving again, simply visit at `http://localhost:4200/?fastboot=true` or `http://localhost:4200/`.
58
59
59
60
You can even disable serving fastboot with `ember serve` using an environment flag: `FASTBOOT_DISABLED=true ember serve`. If you have disabled building fastboot assets using the same flag as described [here](https://github.com/ember-fastboot/ember-cli-fastboot#double-build-times-and-no-incremental-builds), remember to also disable serving fastboot assets when using `ember serve`.
60
61
62
+
### Deprecation of `ember fastboot`
63
+
64
+
`ember fastboot` which was earlier required to run your app in FastBoot is now deprecated and is removed in the RC builds of `ember-cli-fastboot`. With FastBoot 1.0 to be released soon, this command will no longer exists and will be replaced by `ember serve`. It is recommended that your upgrade the `ember-cli` version of your app to be 2.12.0 and above.
There are two places where the inclusion of incompatible JavaScript libraries could
353
360
occur:
354
361
355
362
1.`app.import` in the application's `ember-cli-build.js`
356
363
2.`app.import` in an addon's `included` hook
357
364
358
-
`ember-cli-fastboot` sets the `EMBER_CLI_FASTBOOT` environment variable when it is
359
-
building the FastBoot version of the application. You can use this to prevent the
360
-
inclusion of the library at build time:
365
+
You can include the incompatible Javascript libraries by wrapping them with a `FastBoot` variable check. In the browser, `FastBoot` global variable is not defined.
361
366
362
367
```js
363
-
if (!process.env.EMBER_CLI_FASTBOOT) {
364
-
// This will only be included in the browser build
// this file will be loaded in FastBoot but will not be eval'd
380
+
app.import('vendor/<browserLibName>.js');
366
381
}
367
382
```
368
383
369
-
*Note*: This is soon going to be deprecated. See [this issue](https://github.com/ember-fastboot/ember-cli-fastboot/issues/360).
384
+
*Note*: `ember-cli-fastboot` will no longer provide the `EMBER_CLI_FASTBOOT` environment variable to differentiate browser and fastboot builds with rc builds and FastBoot 1.0 and above.
370
385
371
-
## Loading additional assets in FastBoot environment
386
+
###Loading additional assets in FastBoot environment
372
387
373
388
Often addons require to load libraries that are specific to the FastBoot environment and only need to be loaded on the server side. This can include loading
374
389
libraries before or after the vendor file is loaded in the sandbox and/or before or after the app file is loaded in the sandbox. Since the FastBoot manifest defines
*Note*: `process.env.EMBER_CLI_FASTBOOT`is soon going to be deprecated and [eventually removed](https://github.com/ember-fastboot/ember-cli-fastboot/issues/360).
415
+
*Note*: `process.env.EMBER_CLI_FASTBOOT`will be removed in RC builds and FastBoot 1.0.
401
416
Therefore, if you are relying on this environment variable to import something in the fastboot environment, you should instead use `updateFastBootManifest` hook.
402
417
418
+
### Conditionally include assets in FastBoot asset
419
+
420
+
Often your addon may need to conditionally include additional app trees based on ember version. Example, Ember changed an API and in order to have your addon be backward compatible for the API changes you want to include an asset when the ember version is x. For such usecases you could define the `treeForFastBoot` hook in your addon's `index.js` as below:
421
+
422
+
```js
423
+
treeForFastBoot:function(tree) {
424
+
let fastbootHtmlBarsTree;
425
+
426
+
// check the ember version and conditionally patch the DOM api
427
+
if (this._getEmberVersion().lt('2.10.0-alpha.1')) {
return tree ?newMergeTrees([tree, fastbootHtmlBarsTree]) : fastbootHtmlBarsTree;
430
+
}
431
+
432
+
return tree;
433
+
},
434
+
```
435
+
436
+
The `tree` is the additional fastboot asset that gets generated and contains the fastboot overrides.
437
+
403
438
404
439
## Known Limitations
405
440
@@ -428,22 +463,6 @@ Prototype extensions do not currently work across node "realms." Fastboot
428
463
applications operate in two realms, a normal node environment and a [virtual machine](https://nodejs.org/api/vm.html). Passing objects that originated from the normal realm will not contain the extension methods
429
464
inside of the sandbox environment. For this reason, it's encouraged to [disable prototype extensions](https://guides.emberjs.com/v2.4.0/configuring-ember/disabling-prototype-extensions/).
430
465
431
-
### Double build times and no incremental builds
432
-
433
-
Due to limitations in Ember CLI, builds take twice as long to generate the
434
-
second set of FastBoot assets. This also means incremental builds with
435
-
live reload don't work either. This aims to be resolved by FastBoot 1.0.
436
-
In the mean time, we introduce a short-circuit environment flag to not do
437
-
a FastBoot build:
438
-
439
-
```
440
-
FASTBOOT_DISABLED=true ember build
441
-
```
442
-
443
-
This is useful to keep your existing workflow while in development, while
444
-
still being able to deploy FastBoot. This flag will be removed in FastBoot
445
-
1.0.
446
-
447
466
## Troubleshooting
448
467
449
468
Because your app is now running in Node.js, not the browser, you'll
@@ -456,7 +475,7 @@ Enable verbose logging by running the FastBoot server with the following
456
475
environment variables set:
457
476
458
477
```sh
459
-
DEBUG=ember-cli-fastboot:* ember fastboot
478
+
DEBUG=ember-cli-fastboot:* ember serve
460
479
```
461
480
462
481
PRs adding or improving logging facilities are very welcome.
@@ -487,14 +506,10 @@ node-inspector --no-preload
487
506
488
507
Once the debug server is running, you'll want to start up the FastBoot
489
508
server with Node in debug mode. One thing about debug mode: it makes
490
-
everything much slower. Since the `ember fastboot` command does a full
491
-
build when launched, this becomes agonizingly slow in debug mode.
492
-
493
-
Avoid the slowness by manually running the build in normal mode, then
494
-
running FastBoot in debug mode without doing a build:
509
+
everything much slower.
495
510
496
511
```sh
497
-
ember build && node --debug-brk ./node_modules/.bin/ember fastboot --no-build
512
+
ember build && node --debug-brk ./node_modules/.bin/ember serve
498
513
```
499
514
500
515
This does a full rebuild and then starts the FastBoot server in debug
@@ -551,3 +566,7 @@ Run the tests with the `DEBUG` environment variable set to
551
566
```sh
552
567
DEBUG=fastboot-test npm test
553
568
```
569
+
570
+
### Questions
571
+
572
+
Reach out to us in Ember community slack in the `#-fastboot` channel.
0 commit comments