feat(module): devtools integration (#2196)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Romain Hamel
2024-11-05 22:17:56 +01:00
committed by GitHub
parent 7fc6b387b3
commit 701c75a2a8
100 changed files with 2062 additions and 59 deletions

View File

@@ -1,11 +1,4 @@
/* eslint-disable no-undef */
import('https://unpkg.com/prettier@3.3.3/standalone.js')
import('https://unpkg.com/prettier@3.3.3/plugins/babel.js')
import('https://unpkg.com/prettier@3.3.3/plugins/estree.js')
import('https://unpkg.com/prettier@3.3.3/plugins/html.js')
import('https://unpkg.com/prettier@3.3.3/plugins/markdown.js')
import('https://unpkg.com/prettier@3.3.3/plugins/typescript.js')
self.onmessage = async function (event) {
self.postMessage({
uid: event.data.uid,
@@ -21,8 +14,18 @@ function handleMessage(message) {
}
async function handleFormatMessage(message) {
const { options, source } = 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/babel.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/estree.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/html.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/markdown.js'),
import('https://unpkg.com/prettier@3.3.3/plugins/typescript.js')
])
}
const { options, source } = message
const formatted = await prettier.format(source, {
parser: 'markdown',
plugins: prettierPlugins,