Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
This PR fixes the
style-rawpipeline in@plasmohq/parcel-transformer-vue, which put the compiled Vue<style>CSS straight into a JS template literal. CSS that contains backslashes, backticks or${was read as template-literal syntax:content: "\2022"failed withSyntaxError: Octal escape sequences are not allowed in template stringscontent: "\f00c"was silently changed into a form feed followed by00c${foo}in CSS was evaluated as JSFixes #1361
Approach
The CSS string is now written with
JSON.stringify, the same way the transformer already writescssModules,__fileand custom blocks. The Vue CSUI mount template still gets the same default string export. It just keeps the exact CSS now. I chose this over escaping the template-literal characters by hand, which would add a second escaping routine, and over changing the mount code, which would touch more files for the same result.Testing
core/*has no test runner, so I tested with a script on Node 20.15.1 (run throughtsx). It parses a.vueSFC with this package'sparse, runs thestyle-rawpipeline and evaluates the generated module. It covers the four cases from the issue plus plain multiline CSS: 1/5 pass onmain(the four issue cases fail with the errors above), 5/5 with this change.I also ran the steps of the
test-examples.ymlworkflow locally on Node 20.15.1 with submodules checked out:pnpm i --no-frozen-lockfile,build:packages,build:apiandbuild:clipassed. One run ofbuild:exampleswith the examples building in parallel failed inexamples/with-google-analytics-measurementwithFailed to parse .parcelrc. That example has no Vue files, and a full run on cleanmain(9369e28) passed. When I reranbuild:examplesandtest:examplesone example at a time over the same projects, both passed, includingwith-vue.No UI change of its own: Vue CSUI styles that use CSS escapes or backticks are injected as written instead of breaking the build or being changed.
Known limitations
core/parcel-config/run.json, which everyplasmo buildrewrites before Parcel starts. That is separate from this fix.Code of Conduct
Contacts
If your PR is accepted, we will award you with the
Contributorrole on Discord server.To join the server, visit: https://www.plasmo.com/s/d