forked from vitejs/vite
/
index.html
183 lines (139 loc) · 5.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<h1>Optimize Deps</h1>
<h2>CommonJS w/ named imports (react)</h2>
<div class="cjs"></div>
<h2>CommonJS w/ named imports (phoenix)</h2>
<div class="cjs-phoenix">fail</div>
<h2>CommonJS w/ default export (clipboard)</h2>
<div class="cjs-clipboard">fail</div>
<script type="module" src="./cjs.js"></script>
<h2>CommonJS dynamic import default + named (react)</h2>
<div class="cjs-dynamic"></div>
<h2>CommonJS dynamic import named (phoenix)</h2>
<div class="cjs-dynamic-phoenix"></div>
<h2>CommonJS dynamic import default (clipboard)</h2>
<div class="cjs-dynamic-clipboard"></div>
<h2>CommonJS dynamic import default (dep-cjs-compiled-from-esm)</h2>
<div class="cjs-dynamic-dep-cjs-compiled-from-esm"></div>
<h2>CommonJS dynamic import default (dep-cjs-compiled-from-cjs)</h2>
<div class="cjs-dynamic-dep-cjs-compiled-from-cjs"></div>
<script type="module" src="./cjs-dynamic.js"></script>
<h2>Dedupe (dep in linked & optimized package)</h2>
<div class="dedupe"></div>
<script type="module" src="./dedupe.js"></script>
<h2>CommonJS w/ browser field mapping (axios)</h2>
<div>This should show pong: <span class="cjs-browser-field"></span></div>
<h2>Detecting linked src package and optimizing its deps (lodash-es)</h2>
<div>This should show fooBarBaz: <span class="deps-linked"></span></div>
<h2>Optimizing force included dep even when it's linked</h2>
<div class="force-include"></div>
<h2>Dep with CSS</h2>
<div class="dep-linked-include">This should be red</div>
<h2>CJS Dep with CSS</h2>
<div class="cjs-with-assets">This should be blue</div>
<h2>import * as ...</h2>
<div class="import-star"></div>
<h2>Import from dependency with process.env.NODE_ENV</h2>
<div class="node-env"></div>
<h2>Import from dependency with .notjs files</h2>
<div class="not-js"></div>
<h2>Import from dependency with dynamic import</h2>
<div class="dep-with-dynamic-import"></div>
<h2>Dep w/ special file format supported via plugins</h2>
<div class="plugin"></div>
<h2>Vue & Vuex</h2>
<div class="vue"></div>
<h2>Dep with changes from esbuild plugin</h2>
<div>This should show a greeting: <span class="esbuild-plugin"></span></div>
<h2>Dep from hidden dir</h2>
<div>This should show hello!: <span class="hidden-dir"></span></div>
<h2>Nested include</h2>
<div>Module path: <span class="nested-include"></span></div>
<h2>Alias with colon</h2>
<div>URL: <span class="url"></span></div>
<h2>Reused variable names</h2>
<div>This should show reused: <span class="reused-variable-names"></span></div>
<h2>Flatten Id</h2>
<div class="clonedeep-slash"></div>
<div class="clonedeep-dot"></div>
<script>
function text(el, text) {
document.querySelector(el).textContent = text
}
</script>
<script type="module">
// test dep detection in globbed files
const globbed = import.meta.glob('./glob/*.js', { eager: true })
import { camelCase } from 'dep-linked'
text('.deps-linked', camelCase('foo-bar-baz'))
import { msg, VueSFC } from 'dep-linked-include'
text('.force-include', msg)
text('.plugin', VueSFC.render())
import * as linked from 'dep-linked-include'
const keys = Object.keys(linked)
if (keys.length) {
text('.import-star', `[success] ${keys.join(', ')}`)
}
import 'dep-cjs-with-assets'
import { env } from 'dep-node-env'
text('.node-env', env)
import { notjsValue } from 'dep-not-js'
text('.not-js', notjsValue)
import { lazyFoo } from 'dep-with-dynamic-import'
lazyFoo().then((foo) => {
text('.dep-with-dynamic-import', foo)
})
import { createApp } from 'vue'
import { createStore } from 'vuex'
if (typeof createApp === 'function' && typeof createStore === 'function') {
text('.vue', '[success]')
}
import { hello } from 'dep-esbuild-plugin-transform'
text('.esbuild-plugin', hello())
import { greeting } from './.hidden-dir/foo.js'
text('.hidden-dir', greeting)
import { nestedInclude } from 'nested-exclude'
text('.nested-include', nestedInclude)
import { parse } from 'node:url'
text('.url', parse('https://vitejs.dev').hostname)
import './index.astro'
</script>
<script type="module">
const reusedName = 1
</script>
<script type="module">
const reusedName = 'reused'
text('.reused-variable-names', reusedName)
</script>
<script type="module">
// should error on builtin modules (named import)
import { Buffer } from 'buffer'
// named imports error immediately
</script>
<script type="module">
// should error on builtin modules (default import)
import cp from 'child_process'
// must access property to error
if (import.meta.env.DEV) {
cp.execSync()
}
</script>
<script type="module">
// should error on builtin modules from dep
import { read } from 'dep-with-builtin-module-esm'
if (import.meta.env.DEV) {
read()
}
</script>
<script type="module">
// should error on builtin modules from dep
import { read } from 'dep-with-builtin-module-cjs'
if (import.meta.env.DEV) {
read()
}
</script>
<script type="module">
import cloneDeepSlash from 'lodash/cloneDeep'
import cloneDeepDot from 'lodash.clonedeep'
text('.clonedeep-slash', cloneDeepSlash({ name: 'clonedeep-slash' }).name)
text('.clonedeep-dot', cloneDeepDot({ name: 'clonedeep-dot' }).name)
</script>