Skip to content
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

fix(schematics): add parse5 dep #11647

Merged
merged 4 commits into from Jun 28, 2018
Merged

fix(schematics): add parse5 dep #11647

merged 4 commits into from Jun 28, 2018

Conversation

amcdnl
Copy link
Contributor

@amcdnl amcdnl commented Jun 4, 2018

Adds parse5 as a dependency; fixes: #11341

@amcdnl amcdnl self-assigned this Jun 4, 2018
@amcdnl amcdnl requested a review from jelbourn June 4, 2018 15:22
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 4, 2018
package.json Outdated
@@ -38,6 +38,7 @@
"rxjs": "6.0.0",
"systemjs": "0.19.43",
"tsickle": "^0.27.2",
"parse5": "^5.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't solve the problem since this doesn't do anything for downstream apps. For people using schematics, they would need to have parse5 installed in their app. However, we don't want to include that as a real dependency in the distributed package.json. Maybe that's motivation to use something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, but shouldn't we be including this anyway? Its just out of chance this is working.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I assumed the main goal here was to fix #11341 (which I assumed is talking about downstream apps)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, that was the original goal but as you said it won't solve the problem. Let me know how you would like to proceed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Brocco @filipesilva do you have any thoughts on how we could do HTML parsing without making parse5 a peerDep of @angular/material?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not really sure. If this package uses parse5 then it should be a dependency. But I see the problem in adding when it's just used for the update schematics.

I suppose one solution is to separate the Material schematics into a separate package. Another is to provide html parsing facilities within schematics. But one way or another, Material would have parse5 somewhere in its dependency (or peer dependency) tree.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The little bit of HTML updating we've done is via regex, but we're also only adding some tags inside of the head tag for PWA.

@jelbourn
Copy link
Member

I was thinking it would make sense for the devkit to have html parsing APIs, tough obviously that would be down the road.

What about using optionalDependencies, and then checking for the presence of parse5 at run-time?

@filipesilva
Copy link
Contributor

filipesilva commented Jun 13, 2018

@jelbourn I feel optionalDependencies are a pretty good solution to this, yes.

It's easy for direct consumers to add both material and parse5. I would advise to always direct people that are updating to add parse5 though, instead of relying on hoisting. Hoisting behaviour varies a lot between package manager and is ultimately an implementation detail.

@jelbourn
Copy link
Member

@amcdnl let's go with adding an optional dependency and checking at run-time whether parse5 is available and throwing a friendly error if it isn't

@amcdnl
Copy link
Contributor Author

amcdnl commented Jun 15, 2018

@jelbourn - done

@@ -10,6 +10,10 @@ import {Project} from './devkit-utils/config';
* @param src the src path of the html file to parse
*/
export function getHeadTag(host: Tree, src: string) {
if (!parse5) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check be earlier? I want to make sure that we don't partially run the schematic before bailing out here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jun 25, 2018
@josephperrott josephperrott merged commit 2330c8b into angular:master Jun 28, 2018
josephperrott pushed a commit that referenced this pull request Jun 28, 2018
@filipesilva
Copy link
Contributor

I just want to highlight that optional deps will always try to be installed. The installation won't fall if they fail to install, but if they don't fail to install it will stay installed.

Sorry for the delay in looking at this again, have been on vacations.

@amcdnl amcdnl deleted the parse5 branch July 15, 2018 18:31
victoriaaa234 pushed a commit that referenced this pull request Jul 25, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Material Schematics missing external dependency
6 participants