Added support to update manifest appfiles from index.html#701
Conversation
a6167f8 to
41e3da9
Compare
|
Cheerio is a pretty large dependency for FastBoot to take on. Want to get feedback from @stefanpenner @ef4 @rwjblue that the correct architecture is for us to parse the HTML file (vs. emitting some kind of JSON manifest), and that cheerio is the simplest way to do that. |
41e3da9 to
7f0e8b2
Compare
|
We should be able to parse with |
|
Yes, parsing the HTML file is the way to go. It aligns fastboot with web standards instead of our own ember-only standard. It means that the output from Parcel or Webpack can go directly to fastboot and fastboot will be able to know how to boot it. (The other piece of this story is that any browser-only or fastboot-only code will be guarded by the macro system. In development we can do a single build that keeps both branches in, while running correctly in both environments. In prod we can produce both optimized builds.) |
I am open to using any other library here for parsing the HTML. As this a build time parsing and cheerio being the dev dependency I don't see this causing issue during runtime. One drawback of parsing HTML would be related to production builds replacing asset URLs with hashed CDN URLs. In that case, this postBuild processing would fail as hashed assets wouldn't be present in app's package on the disk. Any thoughts about this scenario @tomdale @stefanpenner @ef4 @rwjblue |
@ef4 - Have you considered this case? Is this something that we would have to track and reverse the work of the fingerprinter? |
|
CDN prefixing and fingerprinting are two different concerns. Fingerprinting does not need to be reversed (and can't be, in the case of embroider, because it's up to the stage3 packager to do whatever it wants with filenames). The way we do CDN prefixing today, yes, it would need to be reversed. But that is much easier (it only requires one argument to fastboot, the prefix it's allowed to strip off URLs to make them local again). Arguably we don't even need that, because fastboot can see all the assets on disk and can correlate URL suffixes with filenames, allowing it to discover any CDN prefixes on the fly. |
7f0e8b2 to
29e27b9
Compare
|
Now that #702 is landed, can you rebase? |
806dc92 to
20fb86a
Compare
| postBuild(result) { | ||
| let appFilePath = stripLeadingSlash(this.app.options.outputPaths.app.js); | ||
| this._appendAppBoot(result.directory, appFilePath); | ||
| this._updateAppFilesInManifest(result.directory); |
There was a problem hiding this comment.
Is there a way for us to only do this in Embroider land?
There was a problem hiding this comment.
There's no obvious way and I don't really want to give one to people. Running Embroider and a classic build within the same broccoli system is a valid thing to want to do.
There was a problem hiding this comment.
@ef4 any reasons for not to provide a way to check the embroider land. It will make it easier for Fastboot build to switch between classic build flow and changes needed to be made for embroider. Also, will help in isolating the build issue specific to embroider.
There was a problem hiding this comment.
There's really no such thing as "outside" vs "inside" embroider. The addons all get instantiated before any embroider code even runs, and that is intentional. Also, the last time we exposed a global flag like this inside broccoli (the one for checking for fastboot) we regretted it, because it's just not really how broccoli works.
So no, I really don't want v1-formatted addons to start adding code to behave special under embroider. The only supported way to do that is to ship as a native V2 addon, after we merge RFC 507.
Also, this change is an improvement for all builds, not just embroider. It moves us in a better architectural direction.
index.js
Outdated
| const p = require('ember-cli-preprocess-registry/preprocessors'); | ||
| const fastbootTransform = require('fastboot-transform'); | ||
| const existsSync = fs.existsSync; | ||
| const cheerio = require('cheerio'); |
There was a problem hiding this comment.
We should swap to using simple-html-tokenizer to parse, I'll try to whip up a demo to show what I mean.
282d6da to
a0bcd90
Compare
|
Hi @kratiahuja @tomdale @rwjblue @ef4, There is a test failure related to this test - https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/test/package-json-test.js#L232. This test is related to custom output paths configured in Here is the configuration of custom output path used for above test - https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/test/fixtures/customized-outputpaths/ember-cli-build.js#L5 Not sure how this scenario be handled in terms of index.html, should we expect the custom paths to be present in index.html. As I am not familiar with ember-cli set up for that. please let me know your thoughts. |
|
Chatted with @dnalagatla and @mansona in today's FastBoot meeting, in order to work around that failing test we will need to keep the existing behaviors around as a fallback. |
a0bcd90 to
b3619fe
Compare
@rwjblue I made updates to keep the current low intact and only get the app files from index.html when .js file doesn't exist. Test related custom output paths is passing now. |
7b8c564 to
c277043
Compare
|
Rebased with master and resolved conflicts. @rwjblue please review when you get a chance |
c277043 to
b3646cf
Compare
* Only update manifest when the current app file doesn't exist. * Providing flexibility to support embroider build and current build.
b3646cf to
0a12a6f
Compare
|
@dnalagatla / @rwjblue this appears to have no tests, are there tests elsewhere? |
| "chai": "^4.1.2", | ||
| "chai-fs": "^2.0.0", | ||
| "chai-string": "^1.4.0", | ||
| "cheerio": "^1.0.0-rc.3", |
There was a problem hiding this comment.
I believe this should be a dependency not a devDependency
|
This code does not appear to support rebuilds, when a rebuild occurs it appears to go back to not reading the |
In order to support Embroider buld:
assetFilesproperty in the fastboot manifest to load in the sandbox.* Also, as autoRun is false in fastboot and- Merged as part of this pr - #702app-boottype not supported incontentForhook. Moved the logic to postBuild. Used postBuild hook for appending fastboot module and a check to create app when not in fastboot environment.#700 - embroider-build/embroider#184
Tested Application using embroider build and application not using embroider build.