Skip to content

Commit

Permalink
Update sandboxes to use vite and typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMurphy committed Aug 29, 2023
1 parent 5e3cdbd commit df4729e
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 19 deletions.
2 changes: 1 addition & 1 deletion sandbox-templates/rehype-debug/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ <h2>result</h2>
<pre id="result"></pre>
<h2>error</h2>
<pre id="error">none</pre>
<script type="module" src="src/index.js"></script>
<script type="module" src="src/index.ts"></script>
</body>
</html>
13 changes: 7 additions & 6 deletions sandbox-templates/rehype-debug/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "rehype-debug",
"version": "1.0.0",
"license": "MIT",
"private": true,
"source": "index.html",
"license": "MIT",
"type": "module",
"main": "src/index.ts",
"scripts": {
"start": "parcel",
"build": "parcel build"
"start": "tsc && vite"
},
"dependencies": {
"rehype": "12.0.1"
"rehype": "^13.0.0"
},
"devDependencies": {
"parcel": "2.2.1"
"typescript": "^5.0.0",
"vite": "^4.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ const sourceHtml = `
`

async function main() {
document.querySelector('#source').textContent = sourceHtml
document.querySelector('#source')!.textContent = sourceHtml

rehype()
// Add any plugins here
.process(sourceHtml)
.then((file) => {
document.querySelector('#result').textContent = String(file)
document.querySelector('#result')!.textContent = String(file)
})
}

main().catch((error) => {
document.querySelector('#error').textContent = error
document.querySelector('#error')!.textContent = error
})
18 changes: 18 additions & 0 deletions sandbox-templates/rehype-debug/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "Node16",
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true
},
"include": ["src"],
"references": [{"path": "./tsconfig.node.json"}]
}
8 changes: 8 additions & 0 deletions sandbox-templates/rehype-debug/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "bundler"
},
"include": ["vite.config.ts"]
}
2 changes: 1 addition & 1 deletion sandbox-templates/rehype-dom-debug/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ <h2>result</h2>
<pre id="result"></pre>
<h2>error</h2>
<pre id="error">none</pre>
<script type="module" src="src/index.js"></script>
<script type="module" src="src/index.ts"></script>
</body>
</html>
11 changes: 6 additions & 5 deletions sandbox-templates/rehype-dom-debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"name": "rehype-dom-debug",
"version": "1.0.0",
"private": true,
"source": "index.html",
"main": "src/index.ts",
"type": "module",
"scripts": {
"start": "parcel",
"build": "parcel build"
"start": "tsc && vite"
},
"dependencies": {
"rehype-dom": "6.0.1"
"rehype-dom": "^6.0.0"
},
"devDependencies": {
"parcel": "2.2.1"
"typescript": "^5.0.0",
"vite": "^4.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ const sourceHtml = `
`

async function main() {
document.querySelector('#source').textContent = sourceHtml
document.querySelector('#source')!.textContent = sourceHtml

rehypeDom()
.use({settings: {fragment: false}})
// Add any plugins here
.process(sourceHtml)
.then((file) => {
document.querySelector('#result').textContent = String(file)
document.querySelector('#result')!.textContent = String(file)
})
}

main().catch((error) => {
document.querySelector('#error').textContent = error
document.querySelector('#error')!.textContent = error
})
18 changes: 18 additions & 0 deletions sandbox-templates/rehype-dom-debug/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "Node16",
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true
},
"include": ["src"],
"references": [{"path": "./tsconfig.node.json"}]
}
8 changes: 8 additions & 0 deletions sandbox-templates/rehype-dom-debug/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "bundler"
},
"include": ["vite.config.ts"]
}

0 comments on commit df4729e

Please sign in to comment.