Skip to content

Add annotateSourceFile option#375

Merged
Princesseuh merged 6 commits intomainfrom
feat/annotate-source
Nov 8, 2023
Merged

Add annotateSourceFile option#375
Princesseuh merged 6 commits intomainfrom
feat/annotate-source

Conversation

@natemoo-re
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@natemoo-re natemoo-re force-pushed the feat/annotate-source branch from 9fe1c45 to f19c778 Compare June 30, 2022 01:46
@natemoo-re natemoo-re force-pushed the feat/annotate-source branch from f19c778 to 92288f7 Compare August 17, 2022 15:46
@natemoo-re natemoo-re force-pushed the feat/annotate-source branch from 92288f7 to 4924894 Compare December 2, 2022 19:33
@natemoo-re natemoo-re force-pushed the feat/annotate-source branch from 4924894 to 87b13d4 Compare January 25, 2023 01:55
@Princesseuh
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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!

@Princesseuh Princesseuh merged commit 0c24ea1 into main Nov 8, 2023
@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