docs(prettier): update usage

This commit is contained in:
Benjamin Canac
2024-10-21 10:55:10 +02:00
parent 4bf81be364
commit b14afbebe9
2 changed files with 27 additions and 24 deletions

View File

@@ -1,8 +1,4 @@
/* eslint-disable no-undef */
import('https://unpkg.com/prettier@3.0.3/standalone.js')
import('https://unpkg.com/prettier@3.0.3/plugins/html.js')
import('https://unpkg.com/prettier@3.0.3/plugins/markdown.js')
self.onmessage = async function (event) {
self.postMessage({
uid: event.data.uid,
@@ -18,6 +14,14 @@ function handleMessage (message) {
}
async function handleFormatMessage (message) {
if (!globalThis.prettier) {
await Promise.all([
import('https://unpkg.com/prettier@3.3.3/standalone.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/html.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/markdown.js')
])
}
const { options, source } = message
const formatted = await prettier.format(source, {
parser: 'markdown',