-
-
Notifications
You must be signed in to change notification settings - Fork 831
support parsing vue single-file-components using composition API #7271
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
Conversation
Caution Review failedThe pull request is closed. 📝 WalkthroughSummary by CodeRabbit
Summary by CodeRabbit
WalkthroughThe changes update the Vue Single File Component (SFC) parsing logic in the Changes
Sequence Diagram(s)sequenceDiagram
participant TestRunner
participant FileSystem
participant PluckFunction
participant VueCompiler
TestRunner->>FileSystem: Write TypeScript and Vue SFC files
TestRunner->>PluckFunction: Call pluck with fileData, filePath
PluckFunction->>VueCompiler: parseWithVue(fileData, filePath)
VueCompiler->>VueCompiler: Register TypeScript loader
VueCompiler->>VueCompiler: Parse SFC with filename context
VueCompiler-->>PluckFunction: Return parsed script content
PluckFunction-->>TestRunner: Return extracted GraphQL query
Assessment against linked issues
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/graphql-tag-pluck/src/index.tsOops! Something went wrong! :( ESLint: 9.30.1 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
* fix vue files * register-ts * test * self review * resolve github runner permissions issue * satisfy lint * revert package.json as per comments * adopt peerDependenciesMeta * revert package.json * resolve lint * Better module loading * Align --------- Co-authored-by: Arda TANRIKULU <ardatanrikulu@gmail.com>
Description
TL;DR: this package has a dependency on
@vue/compiler-sfc
which updated two years ago in a non-backwards compatible way. Minor changes are required so that this package conforms to the changes in vuejs/core#8083Fixes #6945 (cc @felixxxxxs)
Details
vue's composition API (most common syntax as of Vue 3) heavily leverages compiler macros. As part of the implementation of this feature, vue's SFC compiler requires two things:
typescript
to be registered with@vue/compiler-sfc
(code pointer)Currently this project satisfies neither of these requirements, meaning that any vue single-file-component using compiler macros (most of Vue 3 code) will crash the parser with an error like:
Though cryptic, this error can be traced back to
typescript
not being registered correctly (see @vue/compiler-sf#resolveFS). We have a few options to fix this.import 'vue/compiler-sfc';
to their codegen.ts file.registerTS
has been called.Of these two options I'd recommend the latter.
typescript
registration is a low-level concept which is handled for clients by most of thevue
ecosystem. It's easy for clients ofgraphql-codegen
to miss or be confused on whyimport 'vue/compiler-sfc';
is required especially given the cryptic error when it's missing.For this PR I've taken option (2) and ensured that this project correctly calls
registerTS
.For our second requirement, "file paths must be included for parsed files to resolve local imports" we can easily remedy this by plumbing file path information down to
@vue/compiler-sfc
which this PR also does.And one last note. I've moved
@vue/compiler-sfc
to optional dependencies as this package does actually include it at runtime and not just as a dev dependency. I've also reframed it's version constraint to^3.3.1
which is the first version which included the non-backwards compatible change this PR addresses.Type of change
Screenshots/Sandbox (if appropriate/relevant):
N/A
How Has This Been Tested?
Checklist:
CONTRIBUTING doc and the
style guidelines of this project