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

feat!: add unwasm condition in exports #72

Merged
merged 5 commits into from
Jan 14, 2024
Merged

feat!: add unwasm condition in exports #72

merged 5 commits into from
Jan 14, 2024

Conversation

antfu
Copy link
Owner

@antfu antfu commented Jan 2, 2024

resolve #71, awaits unjs/unwasm#10

Breaking Changes

  • shikiji/wasm and shikiji-core/wasm now only have default exports, name export getWasmInlined is removed
  • shikiji-core/wasm renamed to shikiji-core/wasm-inlined

Copy link

netlify bot commented Jan 2, 2024

Deploy Preview for shikiji ready!

Name Link
🔨 Latest commit a6c1ba4
🔍 Latest deploy log https://app.netlify.com/sites/shikiji/deploys/6594abbaebbd14000925efc0
😎 Deploy Preview https://deploy-preview-72--shikiji.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

packages/shikiji/package.json Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a1db7e7) 96.92% compared to head (a6c1ba4) 96.92%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #72      +/-   ##
==========================================
- Coverage   96.92%   96.92%   -0.01%     
==========================================
  Files          49       49              
  Lines        4196     4193       -3     
  Branches      521      522       +1     
==========================================
- Hits         4067     4064       -3     
  Misses        127      127              
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@antfu antfu changed the title feat: try export auto.wasm entry feat!: add unwasm entry in exports Jan 2, 2024
Copy link

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks for quickly collabrating on this! Will try to push import maps ASAP to align with shikiji changes (i guess PR title could be unwasm condition no?)

packages/shikiji/package.json Outdated Show resolved Hide resolved
@@ -43,7 +43,7 @@ const highlighter = await getHighlighterCore({
langs: [
import('shikiji/langs/javascript.mjs'),
],
loadWasm: getWasmInlined
loadWasm: getWasm
Copy link

Choose a reason for hiding this comment

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

Totally up to you, but wouldn't using loadWasm as import name allow loadWasm shorthand syntax?

Copy link
Owner Author

Choose a reason for hiding this comment

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

The reason we have a different name here is that loadWasm is an exported function, and we could have usage like:

import { loadWasm } from 'shikiji/core'
import getWasm from 'shikiji/wasm'

await loadWasm(getWasm)

const getWasm: WebAssemblyInstantiator = async (info) => {
// @ts-expect-error this will be compiled to ArrayBuffer
const binray: ArrayBuffer = await import('vscode-oniguruma/release/onig.wasm').then(m => m.default)
return WebAssembly.instantiate(binray, info).then(wasm => wasm.instance.exports)
Copy link

Choose a reason for hiding this comment

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

Thanks ❤️

@antfu antfu changed the title feat!: add unwasm entry in exports feat!: add unwasm condition in exports Jan 3, 2024
@antfu antfu merged commit 9630092 into main Jan 14, 2024
13 checks passed
@antfu antfu deleted the feat/auto-wasm branch January 14, 2024 11:34
@antfu antfu mentioned this pull request Jan 15, 2024
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.

Compatibility with unwasm
2 participants