mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
Merge branch 'main' into feat/revamped-css-modules
This commit is contained in:
commit
0b13c294b6
@ -1,3 +1,13 @@
|
||||
## <small>5.2.3 (2024-03-20)</small>
|
||||
|
||||
* docs: update volar name and remove takeover mode related docs (#16171) ([0a56177](https://github.com/vitejs/vite/commit/0a56177)), closes [#16171](https://github.com/vitejs/vite/issues/16171)
|
||||
* fix(create-vite): remove vue3 deprecated plugin (TypeScript Vue Plugin) (#16158) ([1645fc0](https://github.com/vitejs/vite/commit/1645fc0)), closes [#16158](https://github.com/vitejs/vite/issues/16158)
|
||||
* fix(create-vite): switch to default Remix template (#16203) ([ea480df](https://github.com/vitejs/vite/commit/ea480df)), closes [#16203](https://github.com/vitejs/vite/issues/16203)
|
||||
* chore(deps): update all non-major dependencies (#16186) ([842643d](https://github.com/vitejs/vite/commit/842643d)), closes [#16186](https://github.com/vitejs/vite/issues/16186)
|
||||
* chore(deps): update dependency vue-tsc to v2 (#16187) ([72104f6](https://github.com/vitejs/vite/commit/72104f6)), closes [#16187](https://github.com/vitejs/vite/issues/16187)
|
||||
|
||||
|
||||
|
||||
## <small>5.2.2 (2024-03-11)</small>
|
||||
|
||||
* chore(deps): update all non-major dependencies (#16028) ([7cfe80d](https://github.com/vitejs/vite/commit/7cfe80d)), closes [#16028](https://github.com/vitejs/vite/issues/16028)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "create-vite",
|
||||
"version": "5.2.2",
|
||||
"version": "5.2.3",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"author": "Evan You",
|
||||
|
@ -115,8 +115,7 @@ const FRAMEWORKS: Framework[] = [
|
||||
name: 'custom-remix',
|
||||
display: 'Remix ↗',
|
||||
color: cyan,
|
||||
customCommand:
|
||||
'npm create remix@latest TARGET_DIR -- --template remix-run/remix/templates/vite',
|
||||
customCommand: 'npm create remix@latest TARGET_DIR',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -13,6 +13,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@
|
||||
"lit": "^3.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@
|
||||
"devDependencies": {
|
||||
"@preact/preset-vite": "^2.8.2",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@preact/preset-vite": "^2.8.2",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
"devDependencies": {
|
||||
"serve": "^14.2.1",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@builder.io/qwik": "^1.5.1"
|
||||
|
@ -10,7 +10,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"serve": "^14.2.1",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@builder.io/qwik": "^1.5.1"
|
||||
|
@ -23,6 +23,6 @@
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.6",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,6 @@
|
||||
"eslint-plugin-react": "^7.34.1",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.6",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.6",
|
||||
"vite": "^5.2.0",
|
||||
"vite-plugin-solid": "^2.10.2"
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
"solid-js": "^1.8.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^5.1.6",
|
||||
"vite": "^5.2.0",
|
||||
"vite-plugin-solid": "^2.10.2"
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,6 @@
|
||||
"svelte-check": "^3.6.7",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
||||
"svelte": "^4.2.12",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,8 @@
|
||||
|
||||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
|
||||
## Recommended IDE Setup
|
||||
## Recommended Setup
|
||||
|
||||
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
||||
- [VS Code](https://code.visualstudio.com/) + [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously Volar) and disable Vetur
|
||||
|
||||
## Type Support For `.vue` Imports in TS
|
||||
|
||||
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
|
||||
|
||||
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
|
||||
|
||||
1. Disable the built-in TypeScript Extension
|
||||
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
|
||||
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
|
||||
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
|
||||
- Use [vue-tsc](https://github.com/vuejs/language-tools/tree/master/packages/tsc) for performing the same type checking from the command line, or for generating d.ts files for SFCs.
|
||||
|
@ -14,7 +14,7 @@
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.0.4",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.6",
|
||||
"vite": "^5.2.0",
|
||||
"vue-tsc": "^2.0.6"
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,4 @@ This template should help get you started developing with Vue 3 in Vite. The tem
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
||||
- [VS Code](https://code.visualstudio.com/) + [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously Volar) and disable Vetur
|
||||
|
@ -13,6 +13,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.0.4",
|
||||
"vite": "^5.1.6"
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,25 @@
|
||||
## <small>5.2.2 (2024-03-20)</small>
|
||||
|
||||
* fix(importAnalysis): skip encode in ssr (#16213) ([e4d2d60](https://github.com/vitejs/vite/commit/e4d2d60)), closes [#16213](https://github.com/vitejs/vite/issues/16213)
|
||||
|
||||
|
||||
|
||||
## <small>5.2.1 (2024-03-20)</small>
|
||||
|
||||
* fix: encode path uri only (#16212) ([0b2e40b](https://github.com/vitejs/vite/commit/0b2e40b)), closes [#16212](https://github.com/vitejs/vite/issues/16212)
|
||||
|
||||
|
||||
|
||||
## 5.2.0 (2024-03-20)
|
||||
|
||||
* fix: update client.ts@cleanUrl to accomodate blob protocol (#16182) ([1a3b1d7](https://github.com/vitejs/vite/commit/1a3b1d7)), closes [#16182](https://github.com/vitejs/vite/issues/16182)
|
||||
* fix(assets): avoid splitting `,` inside query parameter of image URI in srcset property (#16081) ([50caf67](https://github.com/vitejs/vite/commit/50caf67)), closes [#16081](https://github.com/vitejs/vite/issues/16081)
|
||||
* chore(deps): update all non-major dependencies (#16186) ([842643d](https://github.com/vitejs/vite/commit/842643d)), closes [#16186](https://github.com/vitejs/vite/issues/16186)
|
||||
* perf(transformRequest): fast-path watch and sourcemap handling (#16170) ([de60f1e](https://github.com/vitejs/vite/commit/de60f1e)), closes [#16170](https://github.com/vitejs/vite/issues/16170)
|
||||
* docs: add `@shikiji/vitepress-twoslash` (#16168) ([6f8a320](https://github.com/vitejs/vite/commit/6f8a320)), closes [#16168](https://github.com/vitejs/vite/issues/16168)
|
||||
|
||||
|
||||
|
||||
## 5.2.0-beta.1 (2024-03-14)
|
||||
|
||||
* feat: csp nonce support (#16052) ([1d5eec4](https://github.com/vitejs/vite/commit/1d5eec4)), closes [#16052](https://github.com/vitejs/vite/issues/16052)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vite",
|
||||
"version": "5.2.0-beta.1",
|
||||
"version": "5.2.2",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"author": "Evan You",
|
||||
|
@ -111,7 +111,7 @@ function setupWebSocket(
|
||||
}
|
||||
|
||||
function cleanUrl(pathname: string): string {
|
||||
const url = new URL(pathname, location.toString())
|
||||
const url = new URL(pathname, 'http://vitejs.dev')
|
||||
url.searchParams.delete('direct')
|
||||
return url.pathname + url.search
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import {
|
||||
emptyDir,
|
||||
joinUrlSegments,
|
||||
normalizePath,
|
||||
partialEncodeURI,
|
||||
partialEncodeURIPath,
|
||||
requireResolveFromRootWithFallback,
|
||||
} from './utils'
|
||||
import { manifestPlugin } from './plugins/manifest'
|
||||
@ -1093,7 +1093,7 @@ const getResolveUrl = (path: string, URL = 'URL') => `new ${URL}(${path}).href`
|
||||
|
||||
const getRelativeUrlFromDocument = (relativePath: string, umd = false) =>
|
||||
getResolveUrl(
|
||||
`'${escapeId(partialEncodeURI(relativePath))}', ${
|
||||
`'${escapeId(partialEncodeURIPath(relativePath))}', ${
|
||||
umd ? `typeof document === 'undefined' ? location.href : ` : ''
|
||||
}document.currentScript && document.currentScript.src || document.baseURI`,
|
||||
)
|
||||
@ -1120,13 +1120,13 @@ const relativeUrlMechanisms: Record<
|
||||
)} : ${getRelativeUrlFromDocument(relativePath)})`,
|
||||
es: (relativePath) =>
|
||||
getResolveUrl(
|
||||
`'${escapeId(partialEncodeURI(relativePath))}', import.meta.url`,
|
||||
`'${escapeId(partialEncodeURIPath(relativePath))}', import.meta.url`,
|
||||
),
|
||||
iife: (relativePath) => getRelativeUrlFromDocument(relativePath),
|
||||
// NOTE: make sure rollup generate `module` params
|
||||
system: (relativePath) =>
|
||||
getResolveUrl(
|
||||
`'${escapeId(partialEncodeURI(relativePath))}', module.meta.url`,
|
||||
`'${escapeId(partialEncodeURIPath(relativePath))}', module.meta.url`,
|
||||
),
|
||||
umd: (relativePath) =>
|
||||
`(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(
|
||||
@ -1139,7 +1139,7 @@ const customRelativeUrlMechanisms = {
|
||||
...relativeUrlMechanisms,
|
||||
'worker-iife': (relativePath) =>
|
||||
getResolveUrl(
|
||||
`'${escapeId(partialEncodeURI(relativePath))}', self.location.href`,
|
||||
`'${escapeId(partialEncodeURIPath(relativePath))}', self.location.href`,
|
||||
),
|
||||
} as const satisfies Record<string, (relativePath: string) => string>
|
||||
|
||||
|
@ -18,6 +18,7 @@ import type { Plugin } from '../plugin'
|
||||
import type { ResolvedConfig } from '../config'
|
||||
import { checkPublicFile } from '../publicDir'
|
||||
import {
|
||||
encodeURIPath,
|
||||
getHash,
|
||||
injectQuery,
|
||||
joinUrlSegments,
|
||||
@ -100,7 +101,7 @@ export function renderAssetUrlInJS(
|
||||
)
|
||||
const replacementString =
|
||||
typeof replacement === 'string'
|
||||
? JSON.stringify(encodeURI(replacement)).slice(1, -1)
|
||||
? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
|
||||
: `"+${replacement.runtime}+"`
|
||||
s.update(match.index, match.index + full.length, replacementString)
|
||||
}
|
||||
@ -123,7 +124,7 @@ export function renderAssetUrlInJS(
|
||||
)
|
||||
const replacementString =
|
||||
typeof replacement === 'string'
|
||||
? JSON.stringify(encodeURI(replacement)).slice(1, -1)
|
||||
? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
|
||||
: `"+${replacement.runtime}+"`
|
||||
s.update(match.index, match.index + full.length, replacementString)
|
||||
}
|
||||
@ -207,7 +208,7 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
|
||||
|
||||
return {
|
||||
code: `export default ${JSON.stringify(
|
||||
url.startsWith('data:') ? url : encodeURI(url),
|
||||
url.startsWith('data:') ? url : encodeURIPath(url),
|
||||
)}`,
|
||||
// Force rollup to keep this module from being shared between other entry points if it's an entrypoint.
|
||||
// If the resulting chunk is empty, it will be removed in generateBundle.
|
||||
|
@ -49,6 +49,7 @@ import {
|
||||
combineSourcemaps,
|
||||
createSerialPromiseQueue,
|
||||
emptyCssComments,
|
||||
encodeURIPath,
|
||||
generateCodeFrame,
|
||||
getHash,
|
||||
getPackageManagerCommand,
|
||||
@ -580,7 +581,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
|
||||
chunkCSS = chunkCSS.replace(assetUrlRE, (_, fileHash, postfix = '') => {
|
||||
const filename = this.getFileName(fileHash) + postfix
|
||||
chunk.viteMetadata!.importedAssets.add(cleanUrl(filename))
|
||||
return encodeURI(
|
||||
return encodeURIPath(
|
||||
toOutputFilePathInCss(
|
||||
filename,
|
||||
'asset',
|
||||
@ -599,7 +600,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
|
||||
)
|
||||
chunkCSS = chunkCSS.replace(publicAssetUrlRE, (_, hash) => {
|
||||
const publicUrl = publicAssetUrlMap.get(hash)!.slice(1)
|
||||
return encodeURI(
|
||||
return encodeURIPath(
|
||||
toOutputFilePathInCss(
|
||||
publicUrl,
|
||||
'public',
|
||||
@ -702,7 +703,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
|
||||
)
|
||||
const replacementString =
|
||||
typeof replacement === 'string'
|
||||
? JSON.stringify(encodeURI(replacement)).slice(1, -1)
|
||||
? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
|
||||
: `"+${replacement.runtime}+"`
|
||||
s.update(start, end, replacementString)
|
||||
}
|
||||
|
@ -13,12 +13,13 @@ import { stripLiteral } from 'strip-literal'
|
||||
import type { Plugin } from '../plugin'
|
||||
import type { ViteDevServer } from '../server'
|
||||
import {
|
||||
encodeURIPath,
|
||||
generateCodeFrame,
|
||||
getHash,
|
||||
isDataUrl,
|
||||
isExternalUrl,
|
||||
normalizePath,
|
||||
partialEncodeURI,
|
||||
partialEncodeURIPath,
|
||||
processSrcSet,
|
||||
removeLeadingSlash,
|
||||
urlCanParse,
|
||||
@ -439,7 +440,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
|
||||
overwriteAttrValue(
|
||||
s,
|
||||
sourceCodeLocation!,
|
||||
partialEncodeURI(toOutputPublicFilePath(url)),
|
||||
partialEncodeURIPath(toOutputPublicFilePath(url)),
|
||||
)
|
||||
}
|
||||
|
||||
@ -498,7 +499,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
|
||||
if (!isExcludedUrl(decodedUrl)) {
|
||||
const result = await processAssetUrl(url)
|
||||
return result !== decodedUrl
|
||||
? encodeURI(result)
|
||||
? encodeURIPath(result)
|
||||
: url
|
||||
}
|
||||
return url
|
||||
@ -519,7 +520,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
|
||||
overwriteAttrValue(
|
||||
s,
|
||||
getAttrSourceCodeLocation(node, attrKey),
|
||||
partialEncodeURI(toOutputPublicFilePath(url)),
|
||||
partialEncodeURIPath(toOutputPublicFilePath(url)),
|
||||
)
|
||||
} else if (!isExcludedUrl(url)) {
|
||||
if (
|
||||
@ -563,7 +564,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
|
||||
overwriteAttrValue(
|
||||
s,
|
||||
getAttrSourceCodeLocation(node, attrKey),
|
||||
partialEncodeURI(processedUrl),
|
||||
partialEncodeURIPath(processedUrl),
|
||||
)
|
||||
}
|
||||
})(),
|
||||
@ -636,12 +637,16 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
|
||||
// emit <script>import("./aaa")</script> asset
|
||||
for (const { start, end, url } of scriptUrls) {
|
||||
if (checkPublicFile(url, config)) {
|
||||
s.update(start, end, partialEncodeURI(toOutputPublicFilePath(url)))
|
||||
s.update(
|
||||
start,
|
||||
end,
|
||||
partialEncodeURIPath(toOutputPublicFilePath(url)),
|
||||
)
|
||||
} else if (!isExcludedUrl(url)) {
|
||||
s.update(
|
||||
start,
|
||||
end,
|
||||
partialEncodeURI(await urlToBuiltUrl(url, id, config, this)),
|
||||
partialEncodeURIPath(await urlToBuiltUrl(url, id, config, this)),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -904,7 +909,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
|
||||
if (chunk) {
|
||||
chunk.viteMetadata!.importedAssets.add(cleanUrl(file))
|
||||
}
|
||||
return encodeURI(toOutputAssetFilePath(file)) + postfix
|
||||
return encodeURIPath(toOutputAssetFilePath(file)) + postfix
|
||||
})
|
||||
|
||||
result = result.replace(publicAssetUrlRE, (_, fileHash) => {
|
||||
@ -912,7 +917,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
|
||||
getPublicAssetFilename(fileHash, config)!,
|
||||
)
|
||||
|
||||
return encodeURI(
|
||||
return encodeURIPath(
|
||||
urlCanParse(publicAssetPath)
|
||||
? publicAssetPath
|
||||
: normalizePath(publicAssetPath),
|
||||
|
@ -40,7 +40,7 @@ import {
|
||||
joinUrlSegments,
|
||||
moduleListContains,
|
||||
normalizePath,
|
||||
partialEncodeURI,
|
||||
partialEncodeURIPath,
|
||||
prettifyUrl,
|
||||
removeImportQuery,
|
||||
removeTimestampQuery,
|
||||
@ -594,7 +594,9 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
|
||||
rewriteDone = true
|
||||
}
|
||||
if (!rewriteDone) {
|
||||
const rewrittenUrl = JSON.stringify(partialEncodeURI(url))
|
||||
const rewrittenUrl = JSON.stringify(
|
||||
ssr ? url : partialEncodeURIPath(url),
|
||||
)
|
||||
const s = isDynamicImport ? start : start - 1
|
||||
const e = isDynamicImport ? end : end + 1
|
||||
str().overwrite(s, e, rewrittenUrl, {
|
||||
|
@ -5,7 +5,13 @@ import type { ResolvedConfig } from '../config'
|
||||
import type { Plugin } from '../plugin'
|
||||
import type { ViteDevServer } from '../server'
|
||||
import { ENV_ENTRY, ENV_PUBLIC_PATH } from '../constants'
|
||||
import { getHash, injectQuery, prettifyUrl, urlRE } from '../utils'
|
||||
import {
|
||||
encodeURIPath,
|
||||
getHash,
|
||||
injectQuery,
|
||||
prettifyUrl,
|
||||
urlRE,
|
||||
} from '../utils'
|
||||
import {
|
||||
createToImportMetaURLBasedRelativeRuntime,
|
||||
onRollupWarning,
|
||||
@ -411,7 +417,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
|
||||
)
|
||||
const replacementString =
|
||||
typeof replacement === 'string'
|
||||
? JSON.stringify(encodeURI(replacement)).slice(1, -1)
|
||||
? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
|
||||
: `"+${replacement.runtime}+"`
|
||||
s.update(match.index, match.index + full.length, replacementString)
|
||||
}
|
||||
|
@ -1418,9 +1418,20 @@ export function displayTime(time: number): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* Like `encodeURI`, but only replacing `%` as `%25`. This is useful for environments
|
||||
* Encodes the URI path portion (ignores part after ? or #)
|
||||
*/
|
||||
export function encodeURIPath(uri: string): string {
|
||||
const filePath = cleanUrl(uri)
|
||||
const postfix = filePath !== uri ? uri.slice(filePath.length) : ''
|
||||
return encodeURI(filePath) + postfix
|
||||
}
|
||||
|
||||
/**
|
||||
* Like `encodeURIPath`, but only replacing `%` as `%25`. This is useful for environments
|
||||
* that can handle un-encoded URIs, where `%` is the only ambiguous character.
|
||||
*/
|
||||
export function partialEncodeURI(uri: string): string {
|
||||
return uri.replaceAll('%', '%25')
|
||||
export function partialEncodeURIPath(uri: string): string {
|
||||
const filePath = cleanUrl(uri)
|
||||
const postfix = filePath !== uri ? uri.slice(filePath.length) : ''
|
||||
return filePath.replaceAll('%', '%25') + postfix
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user