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 annotateSourceFile option #375

Merged
merged 6 commits into from
Nov 8, 2023
Merged

Add annotateSourceFile option #375

merged 6 commits into from
Nov 8, 2023

Conversation

natemoo-re
Copy link
Member

Changes

  • Allows Astro compiler to annotate elements with information about their source file and location
  • Planned for improving DX in Astro core during dev

Testing

  • Tests added

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Apr 27, 2022

🦋 Changeset detected

Latest commit: 705951c

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

This PR includes changesets to release 1 package
Name Type
@astrojs/compiler Minor

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

Comment on lines 210 to 439
name: "basic",
source: `<div>Hello world!</div>`,
want: `<div data-astro-source-file="/test.astro">Hello world!</div>`,
Copy link
Member Author

Choose a reason for hiding this comment

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

We inject data-astro-source-file={transformOpts.Pathname} to any elements.

Comment on lines +215 to +490
name: "no components",
source: `<Component>Hello world!</Component>`,
want: `<Component>Hello world!</Component>`,
Copy link
Member Author

Choose a reason for hiding this comment

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

We ignore components

Comment on lines 220 to 449
name: "injects root",
source: `<html></html>`,
want: `<html data-astro-source-root="file://"></html>`,
Copy link
Member Author

Choose a reason for hiding this comment

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

We inject data-astro-source-root={transformOpts.ProjectRoot} to the html element

ProjectRoot string
PreprocessStyle interface{}
StaticExtraction bool
AnnotateSourceFile bool
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a new annotateSourceFile: boolean option for the compiler

@Princesseuh
Copy link
Member

Tested it with withastro/astro#9016, and it works!

Copy link
Member Author

@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.

Approved!

internal/printer/print-to-js.go Show resolved Hide resolved
@Princesseuh Princesseuh merged commit 0c24ea1 into main Nov 8, 2023
5 checks passed
@Princesseuh Princesseuh deleted the feat/annotate-source branch November 8, 2023 09:24
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.

3 participants