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

Our build/CI formatting scripts can't handle modern Svelte syntax #3649

Closed
dae opened this issue Dec 18, 2024 · 5 comments
Closed

Our build/CI formatting scripts can't handle modern Svelte syntax #3649

dae opened this issue Dec 18, 2024 · 5 comments
Milestone

Comments

@dae
Copy link
Member

dae commented Dec 18, 2024

#3640 (comment)

I'll try to dig into this in the next few days. A temporary solution might be to execute prettier via a dprint exec plugin, instead of using the wasm version.

@dae
Copy link
Member Author

dae commented Jan 12, 2025

Some other things have come up, so if you are interested in digging in to this @abdnh, you're most welcome. I see dprint-prettier-plugin just got an update, so that might be worth trying first, followed by dprint-plugin-exec to invoke prettier (so dprint still takes care of scanning through folders and locating changed files). If neither of those approaches work, then as a last resort we could invoke prettier directly and exclude those files from dprint.

@abdnh
Copy link
Collaborator

abdnh commented Jan 13, 2025

Here's what I tried:

  1. Updating dprint-plugin-prettier didn't help. The plugin is actually using recent versions of prettier and prettier-plugin-svelte but it's failing to recognize new syntax, while running prettier directly with the same versions works interestingly...
  2. I had trouble getting dprint-plugin-exec to work properly on Windows. It's not recognizing npx prettier even though it's in my path. Probably related to issues in std::process::Command (see Command::spawn has weird rules for finding binaries on Windows rust-lang/rust#37519)
  3. Invoking Prettier directly works as expected: abdnh@d1c504c

@dae
Copy link
Member Author

dae commented Jan 13, 2025

What about invoking node_modules/.bin/prettier directly? I don't think we use npx in the rest of our code. If you can't figure it out after a few minutes, would you be able to push your changes to a branch so I can have a brief play? Don't want to spend long on it, but figured it might be worth one more try before we go with 3.

@abdnh
Copy link
Collaborator

abdnh commented Jan 13, 2025

What about invoking node_modules/.bin/prettier directly?

It actually works, but we have to append .cmd on Windows: https://github.com/ankitects/anki/tree/prettier

would you be able to push your changes to a branch so I can have a brief play?

https://github.com/ankitects/anki/tree/dprint-exec

@dae
Copy link
Member Author

dae commented Jan 13, 2025

Sorry Abdo, I think I made a bad call above. The exec plugin is likely going to result in a node startup for every file that's processed, which is likely going to be expensive. Approach 3 might be a best course forward.

@dae dae closed this as completed in 2c1a489 Jan 13, 2025
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

No branches or pull requests

2 participants