Closed lolmaus closed 7 years ago
It's crazy that a separate app.js and vendor.js bundle is generated for every exposed URL.
Separate JS files should not be generated. If you are seeing that behaviour then it is a bug.
Could you post the structure of your dist/staticboot
directory and your ember-cli-staticboot config?
It defeats caching when a user visits a different URL. They shouldn't be forced to redownload the whole thing.
This should not be the case, the src
for scripts in a default Ember index.html are relative to the root, so each generated page should serve the same file and the browser can cache it.
Ah, indeed all the pages reuse the same bundle.
My misunderstanding was caused by this terminal output:
$ ember b -prod
DEPRECATION: ember-addon.fastBootDependencies has been replaced with ember-addon.fastbootDependencies [addon: ember-cli-moment-shim]
DEPRECATION: ember-addon.fastBootDependencies has been replaced with ember-addon.fastbootDependencies [addon: ember-network]
cleaning up...
Built project successfully. Stored in "dist/".
File sizes:
- lolma-us-521a3459bdd3c3edbd65428396571564.js: 103.22 KB (20.74 KB gzipped)
- lolma-us-e1424afba76dc849d6775ecb2f06f096.css: 18.9 KB (4.45 KB gzipped)
- vendor-9fed400a86fc642248a42d610e52cda6.js: 1.1 MB (290.34 KB gzipped)
- vendor-d41d8cd98f00b204e9800998ecf8427e.css: 0 B
- lolma-us-a00f88a3ac1b297e2c88eca82dc49c49.js: 103.61 KB (20.83 KB gzipped)
- vendor-6f4357a28e1e58229ee0edd51a9dc0c7.js: 1.02 MB (264.07 KB gzipped)
- lolma-us-521a3459bdd3c3edbd65428396571564.js: 103.22 KB (20.74 KB gzipped)
- lolma-us-e1424afba76dc849d6775ecb2f06f096.css: 18.9 KB (4.45 KB gzipped)
- vendor-9fed400a86fc642248a42d610e52cda6.js: 1.1 MB (290.34 KB gzipped)
- vendor-d41d8cd98f00b204e9800998ecf8427e.css: 0 B
I have three pages defined and the above lists exactly three unique pairs of app.js
and vendor.js
.
I now understand that only pair ends up in the dist/staticboot/
folder. Still, is it possible to reuse a single pair rather than building a new one for every page? I'm gonna start a blog, and as I define more pages build time is gonna get unreasonable.
PS Happy to attempt contributing into this fantastic addon, but need some guidance.
Interestingly I just ran ember b -prod
with 1,2,3 and 4 routes and it built 3 sets of assets each time. So I think it may a coincidence that you have 3 routes and are getting three sets of assets.
I'm not sure why but the inclusion of ember-cli-fastboot and then ember-cli-staticboot each are building another set of assets. You can test this out on a fresh Ember CLI app, first run ember b -prod
with no addons, then again after installing ember-cli-fastboot, then again after installing ember-cli-staticboot.
Any contribution is gratefully accepted! If I can help in anyway let me know via issues of PR's.
Thank you @robwebdev, this explains it so far.
Just an FYI, I decided to look at this as it happened to me and I remembered seeing this issue previously.
The reason it happens it because to assets you are seeing are actually all duplicated but located in different directories and are used for different reasons:
dist/assets
), are used by ember when running ember serve
dist/fastboot
), are used by Fastboot when running ember fastboot
dist/staticboot/assets
) are the ones that are used by ember-cli-staticbootYou can see how EmberCLI builds up this output here.
It's crazy that a separate
app.js
andvendor.js
bundle is generated for every exposed URL.It defeats caching when a user visits a different URL. They shouldn't be forced to redownload the whole thing.