Skip to content

Commit 15bdadb

Browse files
authored
chore: playground (#8648)
* initialize playground * pnpm up * tidy up git ignore * remove fluff * format * rm readme * fix jsconfig error * add skip-worktree instructions * reload hack * simplify * use rollup * ughh * add flag for SSR * ... * simplify further * configure launch.json * add debugger info to readme * remove vm modules flag * use replaceAll instead of replace * tidy up * fix: make it run * add watch to launch config
1 parent 5902cca commit 15bdadb

File tree

13 files changed

+272
-1
lines changed

13 files changed

+272
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.idea
22
.DS_Store
3-
.vscode
3+
.vscode/*
4+
!.vscode/launch.json
45
node_modules
56
.eslintcache

.vscode/launch.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "chrome",
6+
"request": "launch",
7+
"name": "Playground: Browser",
8+
"url": "http://localhost:10001"
9+
},
10+
{
11+
"type": "node",
12+
"request": "launch",
13+
"runtimeArgs": ["--watch"],
14+
"name": "Playground: Server",
15+
"outputCapture": "std",
16+
"program": "start.js",
17+
"cwd": "${workspaceFolder}/packages/playground",
18+
"cascadeTerminateToConfigurations": ["Playground: Browser"]
19+
}
20+
],
21+
"compounds": [
22+
{
23+
"name": "Playground: Full",
24+
"configurations": ["Playground: Server", "Playground: Browser"]
25+
}
26+
]
27+
}

packages/playground/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
dist-ssr
3+
*.local

packages/playground/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
You may use this package to experiment with your changes to Svelte.
2+
3+
To prevent any changes you make in this directory from being accidentally committed, run `git update-index --skip-worktree ./**/*.*` in this directory.
4+
5+
If you would actually like to make some changes to the files here for everyone then run `git update-index --no-skip-worktree ./**/*.*` before committing.
6+
7+
If you're using VS Code, you can use the "Playground: Full" launch configuration to run the playground and attach the debugger to both the compiler and the browser.

packages/playground/jsconfig.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "Node",
4+
"target": "ESNext",
5+
"module": "ESNext",
6+
/**
7+
* svelte-preprocess cannot figure out whether you have
8+
* a value or a type, so tell TypeScript to enforce using
9+
* `import type` instead of `import` for Types.
10+
*/
11+
"verbatimModuleSyntax": true,
12+
"isolatedModules": true,
13+
"resolveJsonModule": true,
14+
/**
15+
* To have warnings / errors of the Svelte compiler at the
16+
* correct position, enable source maps by default.
17+
*/
18+
"sourceMap": true,
19+
"esModuleInterop": true,
20+
"skipLibCheck": true,
21+
"forceConsistentCasingInFileNames": true,
22+
/**
23+
* Typecheck JS in `.svelte` and `.js` files by default.
24+
* Disable this if you'd like to use dynamic types.
25+
*/
26+
"checkJs": true
27+
},
28+
/**
29+
* Use global.d.ts instead of compilerOptions.types
30+
* to avoid limiting type declarations.
31+
*/
32+
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
33+
}

packages/playground/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "playground",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "node --watch start.js"
8+
},
9+
"devDependencies": {
10+
"rollup": "^3.20.2",
11+
"rollup-plugin-serve": "^2.0.2",
12+
"svelte": "workspace:*"
13+
}
14+
}

packages/playground/src/App.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
Hello world!
3+
</div>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import App from './App.svelte';
2+
3+
new App({
4+
target: document.getElementById('app'),
5+
hydrate: true
6+
});
7+
8+
function get_version() {
9+
return fetch('/version.json').then((r) => r.json());
10+
}
11+
12+
let prev = await get_version();
13+
14+
// Mom: We have live reloading at home
15+
// Live reloading at home:
16+
while (true) {
17+
await new Promise((r) => setTimeout(r, 2500));
18+
try {
19+
const version = await get_version();
20+
if (prev !== version) {
21+
window.location.reload();
22+
}
23+
} catch {}
24+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import App from './App.svelte';
2+
3+
export function render() {
4+
// @ts-ignore
5+
return App.render();
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
let count = 0
3+
const increment = () => {
4+
count += 1
5+
}
6+
</script>
7+
8+
<button on:click={increment}>
9+
count is {count}
10+
</button>

0 commit comments

Comments
 (0)