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

Migrate to Deno #32

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

stefnotch
Copy link
Contributor

@stefnotch stefnotch commented Nov 5, 2024

After having tried out the mini-parse migration, I thought of a few more tricks to make the migration easier. This is my WIP attempt to migrate everything.

Tasks to do:

  • Build CLI and packager with https://github.com/denoland/dnt
  • Build linker library with vite and publish that to npm? Unless dnt also transforms packages into a browser-compatible format?
  • Fix LinkPackage.test.ts. (moved to packager)

Mostly mechanical edits I did

  • Global replacing
    • .js" to .ts"
    • "mini-parse to "@wesl/mini-parse
    • ctx.task.name to ctx.name
    • test.skip to test.ignore
  • removed berry-pretty
  • Deno's testing utils don't support toMatchSnapshot. There is an async assertSnapshot function in @std/testing/snapshot instead. So I pulled out ast-grep to mostly mechanically do the edits sg --pattern 'expect($MATCH1).toMatchInlineSnapshot($MATCH2)' --rewrite 'await assertSnapshot(ctx, $MATCH1)' --lang ts --interactive and sg --pattern 'expect($MATCH1).toMatchSnapshot()' --rewrite 'await assertSnapshot(ctx, $MATCH1)' --lang ts --interactive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed LinkGlob.test.ts, since import.meta.glob is a vite-specific API. I wasn't sure what to do instead.

"@std/assert": "jsr:@std/assert@1",
"@std/expect": "jsr:@std/expect@1",
"@std/testing": "jsr:@std/testing@1",
"vitest": "./testlib/mod.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced vite with the Deno testing facilities, mostly to reduce our dependencies.
If vitest does have some nice advantages, we should switch back to it.

"dev": "deno run --watch main.ts"
},
"imports": {
"yargs": "https://deno.land/x/yargs@v17.7.2-deno/deno.ts"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could simply import most dependencies from npm, but Deno usually has a nicer built-in alternative. So I figured I'd properly do the migration.

Yargs is a pretty good dependency though. The only alternative worth considering that I could find is https://cliffy.io/ .

- `deno lint` for linting
- `deno fmt` for formatting
- `deno test --allow-read` to run the unit tests
- To update the snapshots, run `deno test --allow-all -- --update`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's all deno! 🦕

I guess that unified tooling aspect is reasonably nice. Hopefully the Node.js ecosystem will catch up and also get more unified tooling.

@stefnotch stefnotch marked this pull request as ready for review November 13, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Unprioritized
Development

Successfully merging this pull request may close these issues.

1 participant