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

Astro.resolve #1085

Merged
merged 9 commits into from
Aug 16, 2021
Merged

Astro.resolve #1085

merged 9 commits into from
Aug 16, 2021

Conversation

matthewp
Copy link
Contributor

Closes #310 and #1071

Changes

This adds support for Astro.resolve as described in the #1071 RFC.

Testing

Tests added.

Docs

Docs added.

@vercel
Copy link

vercel bot commented Aug 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

astro-www – ./www

🔍 Inspect: https://vercel.com/pikapkg/astro-www/B73eneqzciAAmDDpxKpXX8e96ugv
✅ Preview: https://astro-www-git-jnresolve-function-pikapkg.vercel.app

[Deployment for 9fc2aad canceled]

astro-docs – ./docs

🔍 Inspect: https://vercel.com/pikapkg/astro-docs/9ndL4qAnqudzxRMka9BdnJrVDvYR
✅ Preview: https://astro-docs-git-jnresolve-function-pikapkg.vercel.app

@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2021

🦋 Changeset detected

Latest commit: 9fc2aad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
docs Patch
astro Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Looking good! A few comments.

packages/astro/src/compiler/codegen/utils.ts Outdated Show resolved Hide resolved
result[attr.name] = JSON.stringify(getTextFromAttribute(val));
case 'Text': {
let text = getTextFromAttribute(val);
warnIfRelativeStringLiteral(nodeName, attr, text);
Copy link
Member

Choose a reason for hiding this comment

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

It's worth calling out—if we're warning for every relative string literal, does the user have a way to say "Don't warn me, I know what I'm doing?"

Copy link
Member

Choose a reason for hiding this comment

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

If not... why wouldn't we just automatically run Astro.resolve?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great points! First, this should definitely be using the logger so users log level choice gets honored.

Also, I should probably soften the language a little so it doesn't come across like an error. I definitely feel the annoyance of getting a warning repeatedly for something that you did on purpose. Any suggestions here? Would a link to docs be less annoying?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I've updated this to use the logger so you can turn it off the same way you can turn off other warnings. I don't think we have a flag to set a specific log level so we should add that in another issue. A way to turn off specific warnings sounds like a nice add as well but I can't think of a great solution to that at the moment (maybe a config file or something)

@vercel vercel bot temporarily deployed to Preview – astro-www August 16, 2021 15:22 Inactive
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

LGTM!

@matthewp matthewp merged commit 78b5bde into main Aug 16, 2021
@matthewp matthewp deleted the jn.resolve-function branch August 16, 2021 20:43
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* add: Astro.resolve

* Add docs and tests for Astro.resolve

* Add warnings when using string literals

* Prevent windows errors

* Adds a changeset

* Use the astro logger to log the warning

* Use the .js extension

* Dont warn for data urls

* Rename nonRelative and better match

Co-authored-by: Jonathan Neal <[email protected]>
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.

💡 RFC: Astro.imageAsset(...)
3 participants