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

Add Astro.resolve deprecation warning for the static build #2416

Merged
merged 2 commits into from
Jan 19, 2022

Conversation

matthewp
Copy link
Contributor

Changes

  • If astroConfig.buildOptions.experimentalStaticBuild is true, a deprecation warning is added for Astro.resolve. It will always return an empty string so that there is no confusion about it working.

  • Special warning for CSS with recommendation to use style imports instead:

    03:20 PM [deprecation] Astro.resolve() is deprecated. We see that you are trying to resolve ./styles/foo.css.
    It looks like you are resolving styles. If you are adding a link tag, replace with this:
    
    <style global>
    @import "./styles/foo.css";
    </style>
    
  • Regular warning:

    03:22 PM [deprecation] Astro.resolve() is deprecated. We see that you are trying to resolve ./images/penguin.png.
    This can be replaced with a dynamic import like so: await import("./images/penguin.png")
    

@changeset-bot
Copy link

changeset-bot bot commented Jan 18, 2022

🦋 Changeset detected

Latest commit: bf140b6

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

This PR includes changesets to release 1 package
Name Type
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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 18, 2022
@netlify
Copy link

netlify bot commented Jan 18, 2022

✔️ Deploy Preview for astro-docs-2 ready!

🔨 Explore the source changes: 6746122

🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-docs-2/deploys/61e722e6722eb50008a023fc

😎 Browse the preview: https://deploy-preview-2416--astro-docs-2.netlify.app

@netlify
Copy link

netlify bot commented Jan 18, 2022

✔️ Deploy Preview for astro-docs-2 ready!

🔨 Explore the source changes: bf140b6

🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-docs-2/deploys/61e7233ca0ef91000740b0ee

😎 Browse the preview: https://deploy-preview-2416--astro-docs-2.netlify.app

@boehs
Copy link
Contributor

boehs commented Jan 18, 2022

closes #2315

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.

One question, otherwise LGTM!

@@ -34,6 +38,26 @@ export function createResult(args: CreateResultArgs): SSRResult {
params,
url,
},
resolve(path: string) {
if(astroConfig.buildOptions.experimentalStaticBuild) {
let extra = `This can be replaced with a dynamic import like so: await import("${path}")`;
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 need ?url?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not for images at least. I'm not sure when it's needed or not, actually. I guess we could look for common image extensions and a more specific warning like with CSS, and then fallback to using ?url.

Copy link
Member

Choose a reason for hiding this comment

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

Up to you, not blocking!

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 think we'll leave it like this for now as I'm not certain what situations require using ?url. Can add that later.

Copy link
Contributor

@jonathantneal jonathantneal left a comment

Choose a reason for hiding this comment

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

Was slightly distracted by the isCSSRequest optimization and the addition of logging, but otherwise good.

`
}

warn(args.logging, `deprecation`, `${bold('Astro.resolve()')} is deprecated. We see that you are trying to resolve ${path}.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is where logging gets used, yea?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep

@matthewp matthewp merged commit 5208c88 into main Jan 19, 2022
@matthewp matthewp deleted the sb-astro-resolve-deprecate branch January 19, 2022 13:25
@github-actions github-actions bot mentioned this pull request Jan 19, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
…#2416)

* Add Astro.resolve deprecation warning for the static build

* Adds a changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants