Skip to content

Commit f76ddc5

Browse files
committed
workflow: sfc playground
1 parent 2424768 commit f76ddc5

28 files changed

+1654
-23
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module.exports = {
5656
},
5757
// Private package, browser only + no syntax restrictions
5858
{
59-
files: ['packages/template-explorer/**'],
59+
files: ['packages/template-explorer/**', 'packages/sfc-playground/**'],
6060
rules: {
6161
'no-restricted-globals': ['error', ...NodeGlobals],
6262
'no-restricted-syntax': 'off'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"rollup": "~2.38.5",
7070
"rollup-plugin-node-builtins": "^2.1.2",
7171
"rollup-plugin-node-globals": "^1.4.0",
72-
"rollup-plugin-node-polyfills": "^0.2.1",
72+
"rollup-plugin-polyfill-node": "^0.6.2",
7373
"rollup-plugin-terser": "^7.0.2",
7474
"rollup-plugin-typescript2": "^0.27.2",
7575
"semver": "^7.3.2",

packages/compiler-sfc/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "3.0.9",
44
"description": "@vue/compiler-sfc",
55
"main": "dist/compiler-sfc.cjs.js",
6+
"module": "dist/compiler-sfc.esm-browser.js",
67
"types": "dist/compiler-sfc.d.ts",
78
"files": [
89
"dist"
@@ -11,7 +12,7 @@
1112
"name": "VueCompilerSFC",
1213
"formats": [
1314
"cjs",
14-
"global"
15+
"esm-browser"
1516
],
1617
"prod": false,
1718
"enableNonBrowserBranches": true

packages/compiler-sfc/src/compileScript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ function markScopeIdentifier(
13671367
* but with some subtle differences as this needs to handle a wider range of
13681368
* possible syntax.
13691369
*/
1370-
function walkIdentifiers(
1370+
export function walkIdentifiers(
13711371
root: Node,
13721372
onIdentifier: (node: Identifier, parent: Node, parentStack: Node[]) => void
13731373
) {

packages/compiler-sfc/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ export { compileScript } from './compileScript'
66
export { rewriteDefault } from './rewriteDefault'
77
export { generateCodeFrame } from '@vue/compiler-core'
88

9+
// Utilities
10+
export { parse as babelParse } from '@babel/parser'
11+
export { walkIdentifiers } from './compileScript'
12+
import MagicString from 'magic-string'
13+
export { MagicString }
14+
915
// Types
1016
export {
1117
SFCParseOptions,

packages/compiler-sfc/src/warn.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export function warn(msg: string) {
1616
}
1717

1818
export function warnExperimental(feature: string, rfcId: number) {
19+
// eslint-disable-next-line
20+
if (typeof window !== 'undefined') {
21+
return
22+
}
1923
warnOnce(
2024
`${feature} is still an experimental proposal.\n` +
2125
`Follow its status at https://github.com/vuejs/rfcs/pull/${rfcId}.`

packages/global.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ declare namespace jest {
2222
toHaveBeenWarnedTimes(n: number): R
2323
}
2424
}
25+
26+
declare module '*.vue' {
27+
28+
}
29+
declare module '*?raw' {
30+
31+
}

packages/sfc-playground/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Vue SFC Playground</title>
8+
9+
<link rel="preconnect" href="https://fonts.gstatic.com">
10+
<link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap" rel="stylesheet">
11+
12+
<!-- process shim for @vue/compiler-sfc dependency -->
13+
<script>window.process = { env: {} }</script>
14+
<script type="module" src="/src/main.ts"></script>
15+
</head>
16+
<body>
17+
<div id="app"></div>
18+
</body>
19+
</html>

packages/sfc-playground/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@vue/sfc-playground",
3+
"version": "3.0.9",
4+
"private": true,
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "vite build",
8+
"serve": "vite preview"
9+
},
10+
"buildOptions": {
11+
"formats": [
12+
"global"
13+
],
14+
"env": "development",
15+
"enableNonBrowserBranches": true
16+
},
17+
"devDependencies": {
18+
"@types/codemirror": "^0.0.108",
19+
"@vitejs/plugin-vue": "^1.2.0",
20+
"codemirror": "^5.60.0",
21+
"vite": "^2.1.3"
22+
}
23+
}

packages/sfc-playground/src/App.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<template>
2+
<Header />
3+
<div class="wrapper">
4+
<SplitPane>
5+
<template #left>
6+
<Editor />
7+
</template>
8+
<template #right>
9+
<Output />
10+
</template>
11+
</SplitPane>
12+
</div>
13+
</template>
14+
15+
<script setup lang="ts">
16+
import Header from './Header.vue'
17+
import SplitPane from './SplitPane.vue'
18+
import Editor from './editor/Editor.vue'
19+
import Output from './output/Output.vue'
20+
</script>
21+
22+
<style>
23+
body {
24+
font-size: 13px;
25+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
26+
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
27+
color: #444;
28+
margin: 0;
29+
background-color: #f8f8f8;
30+
--nav-height: 50px;
31+
--font-code: 'Source Code Pro', monospace;
32+
}
33+
34+
.wrapper {
35+
height: calc(100vh - var(--nav-height));
36+
}
37+
</style>

0 commit comments

Comments
 (0)