-
Notifications
You must be signed in to change notification settings - Fork 159
[WIP] embroider work does not currently support rebuilds, this … #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c5fff39 to
474a680
Compare
| const fs = require('fs'); | ||
| const findScriptSrcs = require('find-scripts-srcs-in-document'); | ||
| // TODO: review this | ||
| const FILES_TO_SKIP = /vendor|vendor-static/gi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look at this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cneed to have specific attributes we look for that indicate "vendor" vs "app code" vs "ignore this script".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does fastboot need to distinguish vendor vs app?
As far as "ignore this script", we already have the ability to put fastboot guards around any code that shouldn't run in fastboot. I would rather stick with one technique like that than add yet another API here. And guards are more like the proposed @embroider/macros, which has the nice property of letting us produce a single build that works in-browser and in-fastboot during development, while producing optimized separate builds in prod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't dug in yet, still investigating this one. (This was a port of the existing code, with fixes and tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "look at this" comment was more for myself, sorry I should have been clear.
| const pkg = JSON.parse(fs.readFileSync(root + '/package.json', 'UTF8')); | ||
|
|
||
| // bail if not embroider (let's chat if this is appropriate); | ||
| if (!('version' in pkg['ember-addon'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to continue to use any existing content in pkg.fastboot.manifest.appFiles (this supports non-embroider users) and only parse from index.html in Embroider builds. We can work towards removing that (conceptually), but it seems safer for now for existing consumers that are not experimenting with Embroider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is, we mutate said file' appFiles (and the build may choose to as well). So it's contents cannot be trusted.
|
|
||
| // otherwise, we must parse the index.html file to figure out what's next | ||
| const indexHtml = fs.readFileSync(root + '/index.html', 'UTF8') | ||
| // TODO: fix simple-html-tokenizer: https://github.com/tildeio/simple-html-tokenizer/pulls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
474a680 to
9a366aa
Compare
* ensure rebuilds work correctly * use simple-html-tokenizer instead of cheerio (less dependencies, same parser as we use everywhere else, and faster) * detect embroider usage more directly (we should discuss) * tests
9a366aa to
b262446
Compare
|
|
||
| // otherwise, we must parse the index.html file to figure out what's next | ||
| const indexHtml = fs.readFileSync(root + '/index.html', 'UTF8') | ||
| // TODO: fix simple-html-tokenizer: https://github.com/tildeio/simple-html-tokenizer/pull/71 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix simple-html-tokenizer: tildeio/simple-html-tokenizer#71
|
|
||
| const appFiles = findScriptSrcs(indexHtml, findScriptSrcs.ignoreWithAttribute('data-embroider-ignore')) | ||
| // TODO: these FILES_TO_SKIP things seem over zealous | ||
| .filter( src => !FILES_TO_SKIP.test(src)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels overzealous
| // TODO: these FILES_TO_SKIP things seem over zealous | ||
| .filter( src => !FILES_TO_SKIP.test(src)) | ||
| // TODO: handle prefixed / custom origin paths / or files | ||
| .filter(src => fs.existsSync(`${root}/${src}`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle prefixed/custom origin path etc.
| .filter(src => fs.existsSync(`${root}/${src}`)); | ||
|
|
||
| // TODO: this feels super janky, we need to figure out a better approach | ||
| const fastbootFile = pkg.fastboot.manifest.appFiles.find(x => /-fastboot.js$/.test(x)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels risky, we should find a better approach
| 'use strict'; | ||
|
|
||
| const fs = require('fs'); | ||
| const findScriptSrcs = require('find-scripts-srcs-in-document'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested lib that uses simply-html-tokenizer
| const fs = require('fs'); | ||
| const updateManifestFromHtml = require('../../lib/embroider/update-manifest-from-html') | ||
|
|
||
| describe('embroider/update-manifest-from-html', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: more tests
| const addon = pkg['ember-addon']; | ||
|
|
||
| // bail if not embroider (let's chat if this is appropriate); | ||
| if (typeof addon !== 'object' || !('version' in addon)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also, curious to know if there is a better option for the check regarding embroider or classic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addons doing different things under embroider is a bad idea.
The whole point of @embroider/compat is to support addons that don't know about embroider. If an addon wants to actually support embroider, it needs to ship as a v2 addon, thus avoiding @embroider/compat entirely and only using supported APIs in @embroider/core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an addon wants to actually support embroider, it needs to ship as a v2 addon
Which is actually impossible since V2 isn't actually shipped yet 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
. If an addon wants to actually support embroider, it needs to ship as a v2 addon, thus avoiding
@embroider/compatentirely and only using supported APIs in@embroider/core
Could be a dumb question, but just curious - what can be done to use V2 but still be backward compatible. I think Updating ember-cli-fastboot AddOn to use V2 would need Major version bump. And have to maintain both versions. I don't think that is scalable.
@rwjblue please correct me if I am wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very tempted to use process.env.EMBROIDER and update the documentation to indicate, if we have to use embroider with fastboot then run EMBROIDER=true ember s. And use that property to differentiate embroider and classic flow.
I am not happy with this approach but will cover our requirement and since embroider is an experimental build I think this will be ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR - #729, with changes related to using process.env.EMBROIDER property to check if this is embroider flow or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnalagatla it won't require a major bump, v2 addons can also be valid v1 addons because ember-cli respects the ember-addon.main key in package.json, which lets us distinguish the v1 entrypoint from the v2 build entrypoint (ember-addon.build) and the v2 runtime entrpoint (main).
@rwjblue there's nobody better positioned than the people in this thread to make v2 addons become fully implemented. There's not a lot of work required, since the whole system is already designed around their needs. But that is all beside my point: these changes aren't breaking as far as I know, if they're breaking show me how and we can adjust until they're not breaking. If you just want a feature flag inside ember-cli-fastboot to manage the rollout, fine, but don't name it "EMBROIDER" because that's just confusing. It's an ember-cli-fastboot specific feature flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ef4 There is a difference between the classic build and embroider build flow, as a result I was interested in having that flag:
In Classic build flow the following are the steps occurs in ember-cli-fastboot build -
- Ember-cli gives a flag to turn off autoBoot by setting this property
app.options.autoRunand is set to false by default in include hook inember-cli-fastboot- https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/index.js#L73 - Then in
contentForhookapp-boottype is used to define custom app-boot logic that can support Browser and Fastboot (using appFactory). - https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/index.js#L110
Embroider build doesn't support app-boot hook in contentFor to include custom app-boot logic needed for ember-cli-fastboot. - embroider-build/embroider#183
As app-boot is not supported, we introduced a flag to disable-auto-boot in fastboot, but for that flag to be effective we would have to set app.options.autoRun to true. That change is only compatible with embroider flow but not with classic build flow of ember-cli-fastboot.
cc: @stefanpenner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ef4, are there any plans to support app-boot in embroider.
|
This PR can be closed as all the necessary changes for fixing embroider flow is in this PR - #729 Also, above PR fixes embroider related tests not running as part of |
|
Yes, I think it would be a good idea to implement app-boot.
…On Tue, Sep 24, 2019 at 1:48 PM Dinesh Nalagatla ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lib/embroider/update-manifest-from-html.js
<#727 (comment)>
:
> @@ -0,0 +1,39 @@
+'use strict';
+
+const fs = require('fs');
+const findScriptSrcs = require('find-scripts-srcs-in-document');
+
+// TODO: hard coding these seem unfortunate, especially vendor-static which is non-standard
+const FILES_TO_SKIP = /vendor|vendor-static/gi;
+
+module.exports = function updateManifestFromHtml(root) {
+ const pkg = JSON.parse(fs.readFileSync(root + '/package.json', 'UTF8'));
+ const addon = pkg['ember-addon'];
+
+ // bail if not embroider (let's chat if this is appropriate);
+ if (typeof addon !== 'object' || !('version' in addon)) {
Hi @ef4 <https://github.com/ef4>, are there any plans to support app-boot
in embroider.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#727?email_source=notifications&email_token=AACN6MTLZNBMGFXU7RYQ3WTQLJHF5A5CNFSM4IV42BM2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCFYLEPQ#discussion_r327750242>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AACN6MQMUOFLIKJHKATW57LQLJHF5ANCNFSM4IV42BMQ>
.
|
Uh oh!
There was an error while loading. Please reload this page.