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(vite-plugin-angular): extract templateUrls using AST #887

Merged

Conversation

rlmestre
Copy link
Contributor

@rlmestre rlmestre commented Feb 9, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

  • vite-plugin-angular
  • vite-plugin-nitro
  • astro-angular
  • create-analog
  • router
  • platform
  • content
  • nx-plugin
  • trpc

What is the current behavior?

Closes #797

What is the new behavior?

Uses AST instead of string matching/replacement to parse templateUrls

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

[optional] What gif best describes this PR or how it makes you feel?

Copy link

netlify bot commented Feb 9, 2024

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit 5121222
🔍 Latest deploy log https://app.netlify.com/sites/analog-docs/deploys/65c6d90fc748280008bfd420
😎 Deploy Preview https://deploy-preview-887--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 9, 2024

Deploy Preview for analog-ng-app ready!

Name Link
🔨 Latest commit 5121222
🔍 Latest deploy log https://app.netlify.com/sites/analog-ng-app/deploys/65c6d90fe9450b0008950f61
😎 Deploy Preview https://deploy-preview-887--analog-ng-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 9, 2024

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit 5121222
🔍 Latest deploy log https://app.netlify.com/sites/analog-app/deploys/65c6d90f47b89b00084ca0ac
😎 Deploy Preview https://deploy-preview-887--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 9, 2024

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit 5121222
🔍 Latest deploy log https://app.netlify.com/sites/analog-blog/deploys/65c6d910aad07100080233a9
😎 Deploy Preview https://deploy-preview-887--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

.getDescendantsOfKind(SyntaxKind.PropertyAssignment)
.filter((property) => property.getName() === 'templateUrl')
.map((property) =>
property.getInitializer()?.getText().replace(/['"]/g, '')
Copy link
Member

Choose a reason for hiding this comment

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

Does this handle this use case for the templateUrl if they use templateUrl: '[param].component.html' ?

#876

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this gets the property value as-is from the object. The replace is to remove the string delimiters which are part of it.

I can add a unit test for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're referring to the scenario in that issue linked, that's regarding styleUrls. I only modified the templateUrl resolver here

@brandonroberts brandonroberts merged commit f91ab02 into analogjs:main Feb 10, 2024
23 checks passed
@rlmestre rlmestre deleted the fix/797-templateurl-ast-parsing branch February 10, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash if //templateUrl: "" comment line exists in @Component() on page copmponent
2 participants