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 source maps issue resulting in a crash #11319

Merged
merged 13 commits into from
May 31, 2023
Merged

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented May 30, 2023

This PR fixes an issue where source maps weren't properly working. This is because we started using Lightning CSS in between our PostCSS plugins.

The implementation of Lightning CSS currently re-parses the CSS therefore losing the original information from the root tree. After that we reset the result.root based on the result of Lightning CSS.

This PR should resolve the source map issues by passing the previous source maps to Lightning CSS, and passing the resulting source maps from Lightning CSS back to PostCSS.

@RobinMalfait RobinMalfait force-pushed the fix/source-maps branch 2 times, most recently from b707d61 to 4c85145 Compare May 30, 2023 19:36
'13:8 -> 22:8',
'13:31 -> 23:0',
])
expect(annotations).toMatchInlineSnapshot(`
Copy link
Member Author

Choose a reason for hiding this comment

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

Now that we don't use crosscheck anymore, we can use toMatchInlineSnapshot again!

Copy link
Contributor

Choose a reason for hiding this comment

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

🎉🎉🎉

@RobinMalfait RobinMalfait force-pushed the fix/source-maps branch 4 times, most recently from ecf472c to 293dd8a Compare May 30, 2023 20:29
@RobinMalfait RobinMalfait changed the title Fix source maps Fix source map support May 30, 2023
@@ -38,33 +38,34 @@ test.skip('apply generates source maps', async () => {
// All CSS generated by Tailwind CSS should be annotated with source maps
// And always be able to point to the original source file
expect(sources).not.toContain('<no source>')
expect(sources.length).toBe(1)
expect(sources.length).toBe(2)
Copy link
Member Author

Choose a reason for hiding this comment

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

All of these are increased by 1. If you (temporarily) set the minify: false to minify: true in the lightningCssPlugin then it goes down by 1 again.

Copy link
Contributor

Choose a reason for hiding this comment

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

the number of sources should definitely just be 1

Introducing additional sources that disappear during minification sounds like a lightningcss bug. I'll set up an isolated test case for that and file a bug report.

RobinMalfait and others added 5 commits May 31, 2023 18:17
This will get rid of special characters that can cause issues /
confusion when debugging tests.
…rect source

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
@RobinMalfait RobinMalfait changed the title Fix source map support Fix source maps resulting in a crash May 31, 2023
@RobinMalfait RobinMalfait changed the title Fix source maps resulting in a crash Fix source maps issue resulting in a crash May 31, 2023
Copy link
Contributor

@thecrypticace thecrypticace left a comment

Choose a reason for hiding this comment

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

aside from the source path issues which is probs a lightning bug this LGTM. We can merge it and take care of those later.

@RobinMalfait RobinMalfait marked this pull request as ready for review May 31, 2023 16:26
@RobinMalfait RobinMalfait merged commit 352c563 into master May 31, 2023
@RobinMalfait RobinMalfait deleted the fix/source-maps branch May 31, 2023 16:28
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.

2 participants