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: export all of @astrojs/image dist #4146

Merged
merged 3 commits into from
Aug 6, 2022
Merged

fix: export all of @astrojs/image dist #4146

merged 3 commits into from
Aug 6, 2022

Conversation

crutchcorn
Copy link
Contributor

Changes

I'm attempting to build a remark plugin that takes all img tags from a non-MDX Markdown file and pass them to getImages. However, there's a problem in doing so with this line of code, which attempts to import from virtual:image-loader.

This is a problem, however, since virtual: plugins are only available within a Vite context, which the astro.config.ts file is not within.

As such, I've found a workaround by creating global.astroImage manually:

globalThis.astroImage = {
  loader: sharp_service
}

To avoid this if condition. This solution works well enough for my needs for now.

This change was suggested in part by @FredKSchott to export all of dist instead of explicitly importing individual parts of dist.

Testing

This was pulled into my project, which fixed the issue at hand.

Docs

No docs should be needed, this is more for folks living on the edge and writing internal-hooking plugins.

@changeset-bot
Copy link

changeset-bot bot commented Aug 4, 2022

🦋 Changeset detected

Latest commit: de48387

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

This PR includes changesets to release 1 package
Name Type
@astrojs/image 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: integration Related to any renderer integration (scope) label Aug 4, 2022
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—thanks for the PR!

@natemoo-re natemoo-re merged commit 97cf0cd into withastro:main Aug 6, 2022
@astrobot-houston astrobot-houston mentioned this pull request Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants