Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

fix: enable dprint dep to be used offline #622

Merged
merged 8 commits into from
Feb 22, 2023
Merged

Conversation

harrysolovay
Copy link
Contributor

@harrysolovay harrysolovay commented Feb 21, 2023

Fixes #423

... sadly, we now depend on Shiki, which also stands in the way of offline runs :/ to-be-addressed in a another PR

@harrysolovay harrysolovay marked this pull request as ready for review February 21, 2023 04:21
@harrysolovay harrysolovay requested a review from tjjfvi as a code owner February 21, 2023 04:21
@tjjfvi
Copy link
Contributor

tjjfvi commented Feb 21, 2023

This won't work when loaded from deno.land. We need to hex- or base64- encode the wasm and export it from a ts file.

@harrysolovay
Copy link
Contributor Author

We need to hex- or base64- encode the wasm and export it from a ts file.

I've updated the _tasks/downloads.ts script to generate a util/tsFormatter.ts, which includes the text-encoded, hex-encoded string of wasm... it's quite large (10_299_088 characters)... browsers will likely panic given that it's not instantiated via streaming. Feels like I'm complicating things. Gonna table this for now and return to it at a later date.

@tjjfvi
Copy link
Contributor

tjjfvi commented Feb 21, 2023

browsers will likely panic given that it's not instantiated via streaming

We only use dprint in the codegen server, so this shouldn't be an issue. Similar with shiki (hence why we're using npm:shiki for it).

@harrysolovay
Copy link
Contributor Author

We only use dprint in the codegen server, so this shouldn't be an issue

Very good point... we can revisit the browser-compat concern if we ever want to utilize the formatter for anything in capi.dev's front end.

Meanwhile, shiki attempts to fetch the theme asset from a unpkg; this is a blocker to running the server offline. Any ideas for temporary fixes? (I'd imagine we'll think about alternative highlighting tools / potentially monaco in the longer term?)

Copy link
Contributor

@tjjfvi tjjfvi left a comment

Choose a reason for hiding this comment

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

Looks good, but the deps/dprint_ts.wasm should be deleted.

tjjfvi
tjjfvi previously approved these changes Feb 22, 2023
@harrysolovay harrysolovay added this pull request to the merge queue Feb 22, 2023
Merged via the queue into main with commit 9a1648c Feb 22, 2023
@harrysolovay harrysolovay deleted the dprint-offline branch February 22, 2023 18:00
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.

import dprint dependency without runtime fetch
2 participants