Skip to content

Commit 2ed476b

Browse files
authored
refactor: playground (vue-terminal#4)
1 parent 4688bcf commit 2ed476b

33 files changed

+1501
-1039
lines changed

.npmrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
shamefully-hoist=true
21
strict-peer-dependencies=false

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__build__
2+
dist
3+
coverage
4+
auto-imports.d.ts

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
},
1010
"scripts": {
1111
"release": "node scripts/release.mjs",
12+
"dev": "pnpm run -r --filter './packages/{core,vite-plugin-vue-termui,cli}' dev",
1213
"build": "pnpm run -r --filter './packages/{core,vite-plugin-vue-termui,cli}' build",
13-
"lint": "pnpm run -r lint",
14+
"play:dev": "pnpm run --filter './packages/playground' dev",
15+
"lint": "prettier --check packages README.md",
16+
"lint:fix": "prettier --write packages README.md",
1417
"types": "pnpm run -r types",
1518
"test": "pnpm run --parallel -r test --coverage",
1619
"docs": "pnpm run -r dev --filter ./packages/docs",
@@ -21,7 +24,7 @@
2124
},
2225
"devDependencies": {
2326
"@types/node": "^16.11.29",
24-
"@vitejs/plugin-vue": "^2.3.1",
27+
"@vitejs/plugin-vue": "^3.0.3",
2528
"@vue/compiler-sfc": "^3.2.33",
2629
"@vue/runtime-core": "^3.2.33",
2730
"c8": "^7.11.2",
@@ -36,11 +39,12 @@
3639
"semver": "^7.3.7",
3740
"tsup": "^5.12.6",
3841
"typescript": "^4.6.3",
39-
"unplugin-auto-import": "^0.7.1",
40-
"unplugin-vue-components": "^0.19.5",
41-
"vite": "^2.9.6",
42+
"unplugin-auto-import": "^0.11.2",
43+
"unplugin-vue-components": "^0.22.4",
44+
"vite": "^3.0.9",
4245
"vitest": "^0.10.0",
4346
"vue": "^3.2.33",
44-
"vue-tsc": "^0.34.10"
47+
"vue-tsc": "^0.34.10",
48+
"unbuild": "^0.8.9"
4549
}
4650
}

packages/cli/package.json

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@
77
"type": "module",
88
"version": "0.0.14",
99
"scripts": {
10-
"dev": "esmo src/cli.ts dev demo/main.ts",
11-
"demo:build": "esmo src/cli.ts build demo/main.ts",
12-
"build": "rimraf dist && rollup -c --environment NODE_ENV:production",
13-
"build:dev": "rimraf dist && rollup -c -w",
10+
"dev": "unbuild --stub",
11+
"build": "tsup",
1412
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . -l @vue-termui/cli -r 1"
1513
},
1614
"exports": {
1715
".": {
18-
"import": "./dist/index.js",
16+
"import": "./dist/index.mjs",
17+
"require": "./dist/index.cjs",
1918
"types": "./dist/index.d.ts"
2019
},
2120
"./*": "./*"
2221
},
23-
"main": "./dist/index.js",
24-
"module": "./dist/index.js",
22+
"main": "./dist/index.cjs",
23+
"module": "./dist/index.mjs",
2524
"types": "./dist/index.d.ts",
2625
"bin": {
2726
"vtui": "./vtui.mjs"
@@ -56,11 +55,11 @@
5655
"homepage": "https://github.com/posva-sponsors/vue-termui#readme",
5756
"dependencies": {
5857
"picocolors": "^1.0.0",
59-
"vite-node": "^0.10.0",
58+
"vite-node": "^0.22.1",
6059
"ws": "^8.5.0"
6160
},
6261
"peerDependencies": {
63-
"vite": "^2.8.6",
62+
"vite": "^3.0.9",
6463
"vite-plugin-vue-termui": ">=0.0.8",
6564
"vue-termui": ">=0.0.10"
6665
},
@@ -83,5 +82,15 @@
8382
"vite-plugin-inspect": "^0.5.0",
8483
"vite-plugin-vue-termui": "workspace:*",
8584
"vue-termui": "workspace:*"
85+
},
86+
"unbuild": {
87+
"entries": [
88+
"src/cli",
89+
"src/index"
90+
],
91+
"rollup": {
92+
"emitCJS": true
93+
},
94+
"clean": true
8695
}
8796
}

packages/cli/rollup.config.mjs

Lines changed: 0 additions & 196 deletions
This file was deleted.

packages/cli/src/commands/dev/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ export async function runDevServer(entryFile: string = 'src/main.ts') {
1313
})
1414
await server.pluginContainer.buildStart({})
1515

16-
const node = new ViteNodeServer(server, {})
16+
const node = new ViteNodeServer(server, {
17+
deps: {
18+
fallbackCJS: true,
19+
},
20+
})
1721

1822
const runner = new ViteNodeRunner({
1923
root: server.config.root,
@@ -122,7 +126,7 @@ export async function runDevServer(entryFile: string = 'src/main.ts') {
122126
const entryPointId = `/${entryFile}`
123127
const entryPoint = resolve('.' + entryPointId)
124128

125-
server.watcher.on('change', async (fullPath) => {
129+
server.watcher.on('change', async (fullPath: string) => {
126130
const existingModule = hotModulesMap.get(fullPath)
127131

128132
// full reload, tell the app to stop

packages/cli/tsup.config.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { defineConfig } from 'tsup'
2+
3+
export default defineConfig({
4+
clean: true,
5+
target: 'node14',
6+
format: ['esm', 'cjs'],
7+
dts: true,
8+
esbuildOptions(options) {
9+
if (options.format === 'esm') options.outExtension = { '.js': '.mjs' }
10+
},
11+
entry: [
12+
// commands because why not
13+
'src/index.ts',
14+
// cli app
15+
'src/cli.ts',
16+
],
17+
external: [
18+
'vite-node/server',
19+
'vite-node/client',
20+
'vite-node/utils',
21+
'path', // huh?
22+
],
23+
})

packages/cli/vite.config.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/cli/vtui.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env node
2-
import('./dist/cli.js')
2+
import('./dist/cli.mjs')

packages/core/auto-imports.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Generated by 'unplugin-auto-import'
2-
// We suggest you to commit this file into source control
2+
export {}
33
declare global {
44
const afterAll: typeof import('vitest')['afterAll']
55
const afterEach: typeof import('vitest')['afterEach']
@@ -15,4 +15,3 @@ declare global {
1515
const vi: typeof import('vitest')['vi']
1616
const vitest: typeof import('vitest')['vitest']
1717
}
18-
export {}

0 commit comments

Comments
 (0)