Skip to content

Migrate to Deno#32

Draft
stefnotch wants to merge 21 commits into
webgpu-tools:mainfrom
stefnotch:feat/deno
Draft

Migrate to Deno#32
stefnotch wants to merge 21 commits into
webgpu-tools:mainfrom
stefnotch:feat/deno

Conversation

@stefnotch
Copy link
Copy Markdown
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?
    • Or just publish it to the JSR

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
Copy Markdown
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.

Comment thread deno.json
"@std/assert": "jsr:@std/assert@1",
"@std/expect": "jsr:@std/expect@1",
"@std/testing": "jsr:@std/testing@1",
"vitest": "./testlib/mod.ts",
Copy link
Copy Markdown
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.

Comment thread packager/deno.json
"dev": "deno run --watch main.ts"
},
"imports": {
"yargs": "https://deno.land/x/yargs@v17.7.2-deno/deno.ts"
Copy link
Copy Markdown
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/ .

Comment thread README.md
- `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` No newline at end of file
Copy link
Copy Markdown
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
@stefnotch
Copy link
Copy Markdown
Contributor Author

stefnotch commented Feb 11, 2025

For the plugin test project, we can probably use https://www.npmjs.com/package/@deno/vite-plugin

Actually nevermind,

Deno specific resolution cannot be used in vite.config.ts because it's not possible to intercept the bundling process of the config file in vite.

@mighdoll mighdoll marked this pull request as draft February 19, 2025 03:23
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