mirror of
https://github.com/hanzoai/vite.git
synced 2026-10-30 19:36:16 +00:00
* fix: glob import parsing (#10949) (#11056) closes https://github.com/vitejs/vite/issues/10949 closes https://github.com/vitejs/vite/pull/11051 * fix: import.meta.env and process.env undefined variable replacement (fix #8663) (#10958) Co-authored-by: bluwy <[email protected]> fix https://github.com/vitejs/vite/issues/8663 * fix(esbuild): handle inline sourcemap option (#11120) * fix(importGlob): preserve line count for sourcemap (#11122) * fix: Dev SSR dep optimization + respect optimizeDeps.include (#11123) * fix: reset global regex before match (#11132) * chore: fix test Co-authored-by: gtmnayan <[email protected]> Co-authored-by: julienv3 <[email protected]> Co-authored-by: 翠 / green <[email protected]>
73 lines
2.6 KiB
HTML
73 lines
2.6 KiB
HTML
<h1>Define</h1>
|
|
|
|
<p>Raw Expression <code class="exp"></code></p>
|
|
<p>String <code class="string"></code></p>
|
|
<p>Number <code class="number"></code></p>
|
|
<p>Boolean <code class="boolean"></code></p>
|
|
<p>Object <span class="pre object"></span></p>
|
|
<p>Env Var <code class="env-var"></code></p>
|
|
<p>process node env: <code class="process-node-env"></code></p>
|
|
<p>process as property: <code class="process-as-property"></code></p>
|
|
<p>spread object: <code class="spread-object"></code></p>
|
|
<p>spread array: <code class="spread-array"></code></p>
|
|
<p>dollar identifier: <code class="dollar-identifier"></code></p>
|
|
<p>unicode identifier: <code class="unicode-identifier"></code></p>
|
|
<p>no property: <code class="no-property"></code></p>
|
|
<p>no identifier substring: <span class="no-identifier-substring"></span></p>
|
|
<p>define variable in html: <code class="exp-define">__EXP__</code></p>
|
|
<p>import json: <code class="import-json"></code></p>
|
|
<p>define in dep: <code class="define-in-dep"></code></p>
|
|
<p>
|
|
import.meta.env.UNDEFINED: <code class="import-meta-env-undefined"></code>
|
|
</p>
|
|
<p>process.env.UNDEFINED: <code class="process-env-undefined"></code></p>
|
|
|
|
<script type="module">
|
|
const __VAR_NAME__ = true // ensure define doesn't replace var name
|
|
text('.exp', typeof __EXP__) // typeof __EXP__ would be `boolean` instead of `string`
|
|
text('.string', __STRING__)
|
|
text('.number', __NUMBER__)
|
|
text('.boolean', __BOOLEAN__)
|
|
text('.object', JSON.stringify(__OBJ__, null, 2))
|
|
text('.process-node-env', process.env.NODE_ENV)
|
|
text('.env-var', process.env.SOMEVAR)
|
|
text('.process-as-property', __OBJ__.process.env.SOMEVAR)
|
|
text(
|
|
'.spread-object',
|
|
JSON.stringify({
|
|
...(process.env.SOMEVAR ? { SOMEVAR: `"${process.env.SOMEVAR}"` } : {})
|
|
})
|
|
)
|
|
text('.spread-array', JSON.stringify([...`"${__STRING__}"`]))
|
|
text('.dollar-identifier', $DOLLAR)
|
|
text('.unicode-identifier', ÖUNICODE_LETTERɵ)
|
|
|
|
// make sure these kinds of use are NOT replaced:
|
|
const obj = { [`${'_'}_EXP__`]: true }
|
|
text('.no-property', obj.__EXP__)
|
|
|
|
window[`${'_'}_EXP__SUBSTR__`] = true
|
|
text('.no-identifier-substring', __EXP__SUBSTR__)
|
|
|
|
import dataJson from './data.json'
|
|
text('.import-json', dataJson.foo)
|
|
|
|
function text(el, text) {
|
|
document.querySelector(el).textContent = text
|
|
}
|
|
|
|
import { defined, importMetaEnvUndefined, processEnvUndefined } from 'dep'
|
|
text('.define-in-dep', JSON.stringify(defined))
|
|
text('.import-meta-env-undefined', importMetaEnvUndefined)
|
|
text('.process-env-undefined', processEnvUndefined)
|
|
</script>
|
|
|
|
<style>
|
|
.pre {
|
|
display: block;
|
|
unicode-bidi: embed;
|
|
font-family: monospace;
|
|
white-space: pre;
|
|
}
|
|
</style>
|