Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

fix: Better support for .vue. and .svelte files using jscodeshift-adapters #71

Merged
merged 2 commits into from
Aug 6, 2024
Merged

fix: Better support for .vue. and .svelte files using jscodeshift-adapters #71

merged 2 commits into from
Aug 6, 2024

Conversation

fnimick
Copy link
Contributor

@fnimick fnimick commented Jul 25, 2024

Resolves #70

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Hey @fnimick thanks for opening this PR and thanks for going through the trouble of publishing this library! I had a quick look at the source code and think the idea of using the framework-specific tools to parse and extract scripts is generally good!

To be transparent, we're a bit hesitant about adding new dependencies to our tools, so before merging this PR in, I'll bring it up with the team to ensure we're on the same page.

Also, just to confirm since the diffs look a bit wild: the general pattern for the changes is:

  1. remove wrapJscodeshift calls
  2. replace with adapt calls
  3. remove any resulting unnecessary variables (like fileName)

The rest is just auto-formatting, right?

@Lms24 Lms24 self-assigned this Aug 5, 2024
@Lms24
Copy link
Member

Lms24 commented Aug 5, 2024

Also, just as a heads-up: I'm assigning myself to this issue to track internally that I'm reviewing it. No worries though, I'm not gonna take over or anything. Happy to let you continue if we need to make further changes.

@fnimick
Copy link
Contributor Author

fnimick commented Aug 5, 2024

@Lms24 yep, that's all I did. There was one other incredibly minor change to make typescript happy (adding an optional chain) but I will flag that for you specifically.

If you want an easier diff, turn 'ignore whitespace' on, which will hide all the lines where the only changes was the indentation from removing the wrapJscodeshift callback wrapper.

edit: I also added names to most of the formerly anonymous transform functions, matching their directory names, so they show up in stack traces for easier debugging (and so I could module.exports = adapt(functionName) rather than needing to write that inline)

@@ -30,7 +32,7 @@ module.exports = function transform(fileInfo, api, options) {

/** { @type import('jscodeshift').ASTPath<import('jscodeshift').ImportDeclaration> | undefined */
const sentryNamespaceImport = sentryNamespaceImports.length ? sentryNamespaceImports.get() : undefined;
const sentryNameSpace = sentryNamespaceImport?.node.specifiers?.[0].local?.name;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Lms24 this is the only other code change, adding ? to [0]?.local because typescript was unhappy without it.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Man I had no idea about "Hide Whitespaces" thanks a lot for the hint!

As for this change, I'm gonna make the call and say adding the dependency is okay. Given the change is well isolated in this PR, we could (not saying we will) easily revert if we received bug reports.

Thanks for contributing, I'll make sure you're mentioned in the changelog :)

@Lms24 Lms24 changed the title Better support for .vue. and .svelte files using jscodeshift-adapters fix: Better support for .vue. and .svelte files using jscodeshift-adapters Aug 6, 2024
@Lms24 Lms24 merged commit 1b25226 into getsentry:main Aug 6, 2024
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle .svelte files correctly
2 participants