File tree 8 files changed +388
-76
lines changed
8 files changed +388
-76
lines changed Original file line number Diff line number Diff line change 1
1
** /dist /*
2
- ** /site /bundles /
2
+ ** /site /*
3
3
* .js.map
4
4
* .pyc
5
5
.DS_Store
Original file line number Diff line number Diff line change 24
24
"@rollup/plugin-node-resolve" : " 11.2.1" ,
25
25
"@rollup/plugin-replace" : " 4.0.0" ,
26
26
"@squoosh/cli" : " 0.6.3" ,
27
- "concurrently" : " 7.1.0" ,
28
- "dhost" : " 0.3.5" ,
29
- "rollup" : " 2.75.7" ,
30
- "rollup-plugin-commonjs" : " 10.0.1" ,
31
- "rollup-plugin-esm-import-to-url" : " 2.1.0" ,
32
- "rollup-plugin-livereload" : " 2" ,
33
- "rollup-plugin-node-resolve" : " 5.2.0" ,
34
- "rollup-plugin-replace" : " 2.2.0" ,
35
27
"tslib" : " 2.1.0" ,
36
28
"typescript" : " 5.1.6" ,
29
+ "vite" : " ^4.5.0" ,
37
30
"wireit" : " 0.7.1"
38
31
},
39
32
"packageManager" : " yarn@3.2.1"
Original file line number Diff line number Diff line change 2
2
"name" : " trapeze" ,
3
3
"version" : " 1.2.0" ,
4
4
"description" : " A Preact library for paginated experiences, like slide decks and surveys." ,
5
+ "typescript" : " ./src/preact.tsx" ,
5
6
"module" : " ./dist/preact.js" ,
6
7
"types" : " ./dist/preact.d.ts" ,
7
8
"scripts" : {
Original file line number Diff line number Diff line change 3
3
"name" : " trapeze-demos" ,
4
4
"version" : " 0.0.0" ,
5
5
"scripts" : {
6
- "start" : " yarn run -TB concurrently \" yarn run build:tsc --watch \" \" rollup --config ./rollup.config.js --watch \" \" dhost site --bind-all \" " ,
6
+ "start" : " yarn run -TB wireit " ,
7
7
"build" : " yarn run -TB wireit" ,
8
8
"build:tsc" : " yarn run -TB wireit" ,
9
- "build:bundle" : " yarn run -TB wireit"
9
+ "build:gen-html" : " yarn run -TB wireit" ,
10
+ "build:site" : " yarn run -TB wireit"
10
11
},
11
12
"wireit" : {
13
+ "start" : {
14
+ "service" : true ,
15
+ "command" : " vite serve" ,
16
+ "files" : [
17
+ " vite.config.js"
18
+ ]
19
+ },
12
20
"build" : {
13
21
"dependencies" : [
14
22
" build:tsc" ,
15
- " build:bundle"
23
+ " build:gen-html" ,
24
+ " build:site"
16
25
]
17
26
},
18
27
"build:tsc" : {
24
33
" ../../tsconfig.common.json"
25
34
],
26
35
"output" : [
27
- " dist/**" ,
36
+ " dist/**/*.js " ,
28
37
" .tsbuildinfo"
29
38
],
30
39
"packageLocks" : [
34
43
" ../core:build"
35
44
]
36
45
},
37
- "build:bundle" : {
38
- "command" : " rollup --config ./rollup.config.js" ,
46
+ "build:gen-html" : {
47
+ "command" : " sed 's/mount.tsx/mount.js/' src/index.html > dist/index.html" ,
48
+ "files" : [
49
+ " src/index.html"
50
+ ],
51
+ "output" : [
52
+ " dist/index.html"
53
+ ]
54
+ },
55
+ "build:site" : {
56
+ "command" : " vite build" ,
39
57
"clean" : true ,
40
58
"files" : [
59
+ " dist/**/index.html" ,
41
60
" dist/**/*.js" ,
42
- " rollup .config.js"
61
+ " vite .config.js"
43
62
],
44
63
"output" : [
45
- " site/mount.js " ,
64
+ " site/**/* " ,
46
65
" .tsbuildinfo"
47
66
],
48
67
"packageLocks" : [
49
68
" yarn.lock"
50
69
],
51
70
"dependencies" : [
52
- " build:tsc"
71
+ " build:tsc" ,
72
+ " build:gen-html"
53
73
]
54
74
}
55
75
},
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 48
48
</ body >
49
49
< script
50
50
type = 'module '
51
- src = '/bundles/ mount.js '
51
+ src = 'mount.tsx '
52
52
> </ script >
53
53
</ html >
54
54
Original file line number Diff line number Diff line change
1
+ import { defineConfig } from 'vite'
2
+
3
+ // Before vite, we used wireit + tsc for building. Because tsc checks all the
4
+ // types before generating JS, the delay between editing a file and seeing a
5
+ // change in-browser got to be too long. vite short-circuits type checking,
6
+ // effectively stripping the types and presenting the result in the browser as
7
+ // quickly as possible.
8
+ //
9
+ // The config below provides vite with raw TypeScript for fast iteration cycles
10
+ // when running the dev server, but with tsc-checked JavaScript otherwise.
11
+ //
12
+ // This is my first try using vite. We may later find that there's a better way
13
+ // to incorporate type-checking (maybe wireit + tsc isn't needed anymore). For
14
+ // now, this gets us the speed of vite's dev cycles without changing how our
15
+ // packages are generated.
16
+
17
+ export default defineConfig (
18
+ ( { command } ) => ( {
19
+ // This allows us to colocate the HTML file with its scripts without getting
20
+ // the folder name baked into the HTML path.
21
+ root : command === 'serve'
22
+ ? 'src'
23
+ : 'dist' ,
24
+
25
+ resolve : {
26
+ mainFields : command === 'serve'
27
+ ? [ 'typescript' , 'browser' , 'module' ]
28
+ : [ 'browser' , 'module' ] ,
29
+ } ,
30
+ build : {
31
+ // ./dist/../site == ./site
32
+ outDir : '../site' ,
33
+ } ,
34
+ } )
35
+ ) ;
You can’t perform that action at this time.
0 commit comments