There are basically two main issues that need to be worked around for FastBoot:
We cannot load the asset map via document.querySelector(...), as document is not available in Node
We cannot load the locale files (e.g. en.json) via XMLHttpRequest, as that is not available in Node
For 1.), I used the same approach as the one in the references PR to ember-cli-ifa, to build a custom module for Node which can be requested in FastBoot environment (this is encapsulated in the new utils/get-locale-asset-map.js file).
For 2.), we embed the actual locale file content in the asset map, instead of the path to the asset map, for the FastBoot module. This way, we avoid needing to make any Ajax requests in FastBoot environment.
FastBoot will also generate a package.json file in the output, which needs to be excluded from fingerprinting. This PR will automatically adjust the fingerprinting options to work with ember-l10n now, including adding json to fingerprint.extensions for you. The user is informed about any changes made to the configuration in the console, e.g.:
ember-l10n automatically adjusted the fingerprinting settings to work properly:
* added 'json' to fingerprint.extensions
* added 'package.json' to fingerprint.exclude
Note that it does not actually add FastBoot as a dev dependency, and does not add any FastBoot tests for now. I did install FastBoot locally and tried it, to ensure it works as expected (which it did for me).
This PR restores FastBoot compatibility. It is heavily inspired by https://github.com/adopted-ember-addons/ember-cli-ifa/pull/57/files.
There are basically two main issues that need to be worked around for FastBoot:
document.querySelector(...)
, asdocument
is not available in Nodeen.json
) via XMLHttpRequest, as that is not available in NodeFor 1.), I used the same approach as the one in the references PR to ember-cli-ifa, to build a custom module for Node which can be requested in FastBoot environment (this is encapsulated in the new
utils/get-locale-asset-map.js
file).For 2.), we embed the actual locale file content in the asset map, instead of the path to the asset map, for the FastBoot module. This way, we avoid needing to make any Ajax requests in FastBoot environment.
FastBoot will also generate a
package.json
file in the output, which needs to be excluded from fingerprinting. This PR will automatically adjust the fingerprinting options to work with ember-l10n now, including addingjson
tofingerprint.extensions
for you. The user is informed about any changes made to the configuration in the console, e.g.:Note that it does not actually add FastBoot as a dev dependency, and does not add any FastBoot tests for now. I did install FastBoot locally and tried it, to ensure it works as expected (which it did for me).
Fixes #59