Skip to content

Commit

Permalink
chore: merge main (resolve conflicts)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jan 8, 2024
2 parents 5ae3487 + 6ace32b commit c8c39a1
Show file tree
Hide file tree
Showing 51 changed files with 307 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@94549999469dbfa032becf298d95c87a14c34394 # v40.2.2
uses: tj-actions/changed-files@716b1e13042866565e00e85fd4ec490e186c4a2f # v41.0.1
with:
files: |
docs/**
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Starting from Vite 4.4, there is experimental support for [Lightning CSS](https:
npm add -D lightningcss
```

If enabled, CSS files will be processed by Lightning CSS instead of PostCSS. To configure it, you can pass Lightning CSS options to the [`css.lightingcss`](../config/shared-options.md#css-lightningcss) config option.
If enabled, CSS files will be processed by Lightning CSS instead of PostCSS. To configure it, you can pass Lightning CSS options to the [`css.lightningcss`](../config/shared-options.md#css-lightningcss) config option.

To configure CSS Modules, you'll use [`css.lightningcss.cssModules`](https://lightningcss.dev/css-modules.html) instead of [`css.modules`](../config/shared-options.md#css-modules) (which configures the way PostCSS handles CSS modules).

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async function createServer() {
// When the server restarts (for example after the user modifies
// vite.config.js), `vite.middlewares` is still going to be the same
// reference (with a new internal stack of Vite and plugin-injected
// middlewares. The following is valid even after restarts.
// middlewares). The following is valid even after restarts.
app.use(vite.middlewares)

app.use('*', async (req, res) => {
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"@types/micromatch": "^4.0.6",
"@types/node": "^20.10.4",
"@types/picomatch": "^2.3.3",
"@types/semver": "^7.5.6",
"@types/sass": "~1.43.1",
"@types/semver": "^7.5.6",
"@types/stylus": "^0.48.42",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^6.14.0",
Expand Down Expand Up @@ -118,13 +118,18 @@
"acorn-walk": {
"peerDependencies": {
"acorn": "*"
},
"peerDependenciesMeta": {
"acorn": {
"optional": true
}
}
}
},
"patchedDependencies": {
"chokidar@3.5.3": "patches/chokidar@3.5.3.patch",
"sirv@2.0.3": "patches/sirv@2.0.3.patch",
"dotenv-expand@10.0.0": "patches/dotenv-expand@10.0.0.patch"
"dotenv-expand@10.0.0": "patches/dotenv-expand@10.0.0.patch",
"sirv@2.0.4": "patches/sirv@2.0.4.patch"
},
"peerDependencyRules": {
"allowedVersions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vue": "^3.3.11"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.5.2",
"@vitejs/plugin-vue": "^5.0.2",
"typescript": "^5.2.2",
"vite": "^5.0.8",
"vue-tsc": "^1.8.25"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/template-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vue": "^3.3.11"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.5.2",
"@vitejs/plugin-vue": "^5.0.2",
"vite": "^5.0.8"
}
}
11 changes: 11 additions & 0 deletions packages/vite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## <small>5.0.11 (2024-01-05)</small>

* fix: don't pretransform classic script links (#15361) ([19e3c9a](https://github.com/vitejs/vite/commit/19e3c9a)), closes [#15361](https://github.com/vitejs/vite/issues/15361)
* fix: inject `__vite__mapDeps` code before sourcemap file comment (#15483) ([d2aa096](https://github.com/vitejs/vite/commit/d2aa096)), closes [#15483](https://github.com/vitejs/vite/issues/15483)
* fix(assets): avoid splitting `,` inside base64 value of `srcset` attribute (#15422) ([8de7bd2](https://github.com/vitejs/vite/commit/8de7bd2)), closes [#15422](https://github.com/vitejs/vite/issues/15422)
* fix(html): handle offset magic-string slice error (#15435) ([5ea9edb](https://github.com/vitejs/vite/commit/5ea9edb)), closes [#15435](https://github.com/vitejs/vite/issues/15435)
* chore(deps): update dependency strip-literal to v2 (#15475) ([49d21fe](https://github.com/vitejs/vite/commit/49d21fe)), closes [#15475](https://github.com/vitejs/vite/issues/15475)
* chore(deps): update tj-actions/changed-files action to v41 (#15476) ([2a540ee](https://github.com/vitejs/vite/commit/2a540ee)), closes [#15476](https://github.com/vitejs/vite/issues/15476)



## <small>5.0.10 (2023-12-15)</small>

* fix: omit protocol does not require pre-transform (#15355) ([d9ae1b2](https://github.com/vitejs/vite/commit/d9ae1b2)), closes [#15355](https://github.com/vitejs/vite/issues/15355)
Expand Down
51 changes: 29 additions & 22 deletions packages/vite/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,28 +463,6 @@ License: MIT
By: Luke Edwards
Repository: lukeed/polka

> The MIT License (MIT)
>
> Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (https://lukeed.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
---------------------------------------

## @rollup/plugin-alias
Expand Down Expand Up @@ -2186,6 +2164,35 @@ Repository: git+https://github.com/isaacs/isexe.git
---------------------------------------

## js-tokens
License: MIT
By: Simon Lydell
Repository: lydell/js-tokens

> The MIT License (MIT)
>
> Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
---------------------------------------

## json-stable-stringify
License: MIT
By: James Halliday
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ declare module '*.mov' {
const src: string
export default src
}
declare module '*.m4a' {
const src: string
export default src
}

// fonts
declare module '*.woff' {
Expand Down
10 changes: 5 additions & 5 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite",
"version": "5.0.10",
"version": "5.0.11",
"type": "module",
"license": "MIT",
"author": "Evan You",
Expand Down Expand Up @@ -118,7 +118,7 @@
"magic-string": "^0.30.5",
"micromatch": "^4.0.5",
"mlly": "^1.4.2",
"mrmime": "^1.0.1",
"mrmime": "^2.0.0",
"okie": "^1.0.1",
"open": "^8.4.2",
"parse5": "^7.1.2",
Expand All @@ -131,11 +131,11 @@
"resolve.exports": "^2.0.2",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-license": "^3.2.0",
"sirv": "^2.0.3",
"sirv": "^2.0.4",
"source-map-support": "^0.5.21",
"strip-ansi": "^7.1.0",
"strip-literal": "^1.3.0",
"tsconfck": "^3.0.0",
"strip-literal": "^2.0.0",
"tsconfck": "^3.0.1",
"tslib": "^2.6.2",
"types": "link:./types",
"ufo": "^1.3.2",
Expand Down
13 changes: 12 additions & 1 deletion packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,27 @@ const hmrClient = new HMRClient(console, async function importUpdatedModule({
acceptedPath,
timestamp,
explicitImportRequired,
isWithinCircularImport,
}) {
const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`)
return await import(
const importPromise = import(
/* @vite-ignore */
base +
acceptedPathWithoutQuery.slice(1) +
`?${explicitImportRequired ? 'import&' : ''}t=${timestamp}${
query ? `&${query}` : ''
}`
)
if (isWithinCircularImport) {
importPromise.catch(() => {
console.info(
`[hmr] ${acceptedPath} failed to apply HMR as it's within a circular import. Reloading page to reset the execution order. ` +
`To debug and break the circular import, you can run \`vite --debug hmr\` to log the circular dependency path if a file change triggered it.`,
)
pageReload()
})
}
return await importPromise
})

async function handleMessage(payload: HMRPayload) {
Expand Down
6 changes: 6 additions & 0 deletions packages/vite/src/node/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ describe('processSrcSetSync', () => {
),
).toBe('/base/nested/asset.png 1x, /base/nested/asset.png 2x')
})

test('should not split the comma inside base64 value', async () => {
const base64 =
'data:image/avif;base64,aA+/0= 400w, data:image/avif;base64,bB+/9= 800w'
expect(processSrcSetSync(base64, ({ url }) => url)).toBe(base64)
})
})

describe('flattenId', () => {
Expand Down
11 changes: 4 additions & 7 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { buildReporterPlugin } from './plugins/reporter'
import { buildEsbuildPlugin } from './plugins/esbuild'
import { type TerserOptions, terserPlugin } from './plugins/terser'
import {
arraify,
asyncFlatten,
copyDir,
emptyDir,
Expand Down Expand Up @@ -427,13 +428,9 @@ export async function resolveBuildPlugins(config: ResolvedConfig): Promise<{
completeSystemWrapPlugin(),
...(usePluginCommonjs ? [commonjsPlugin(options.commonjsOptions)] : []),
dataURIPlugin(),
...((
await asyncFlatten(
Array.isArray(rollupOptionsPlugins)
? rollupOptionsPlugins
: [rollupOptionsPlugins],
)
).filter(Boolean) as Plugin[]),
...((await asyncFlatten(arraify(rollupOptionsPlugins))).filter(
Boolean,
) as Plugin[]),
...(config.isWorker ? [webWorkerPostPlugin()] : []),
],
post: [
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export async function resolveConfig(
const configEnv: ConfigEnv = {
mode,
command,
isSsrBuild: !!config.build?.ssr,
isSsrBuild: command === 'build' && !!config.build?.ssr,
isPreview,
}

Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/node/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const KNOWN_ASSET_TYPES = [
'aac',
'opus',
'mov',
'm4a',

// fonts
'woff2?',
Expand Down
5 changes: 3 additions & 2 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
normalizePath,
removeLeadingSlash,
tryStatSync,
unique,
} from '../utils'
import { transformWithEsbuild } from '../plugins/esbuild'
import { ESBUILD_MODULES_TARGET } from '../constants'
Expand Down Expand Up @@ -1226,10 +1227,10 @@ function getConfigHash(config: ResolvedConfig, ssr: boolean): string {
plugins: config.plugins.map((p) => p.name),
optimizeDeps: {
include: optimizeDeps?.include
? Array.from(new Set(optimizeDeps.include)).sort()
? unique(optimizeDeps.include).sort()
: undefined,
exclude: optimizeDeps?.exclude
? Array.from(new Set(optimizeDeps.exclude)).sort()
? unique(optimizeDeps.exclude).sort()
: undefined,
esbuildOptions: {
...optimizeDeps?.esbuildOptions,
Expand Down
4 changes: 0 additions & 4 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ export function registerCustomMime(): void {
mrmime.mimes['ico'] = 'image/x-icon'
// https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#flac
mrmime.mimes['flac'] = 'audio/flac'
// mrmime and mime-db is not released yet: https://github.com/jshttp/mime-db/commit/c9242a9b7d4bb25d7a0c9244adec74aeef08d8a1
mrmime.mimes['aac'] = 'audio/aac'
// https://wiki.xiph.org/MIME_Types_and_File_Extensions#.opus_-_audio/ogg
mrmime.mimes['opus'] = 'audio/ogg'
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
mrmime.mimes['eot'] = 'application/vnd.ms-fontobject'
}
Expand Down
9 changes: 1 addition & 8 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,7 @@ async function loadTsconfigJsonForFile(
filename: string,
): Promise<TSConfigJSON> {
try {
if (tsconfckCache) {
// shortcut, the cache stores resolved TSConfckParseResult
// so getting it from the cache directly we bypass async fn call wrapping it in a promise again
if (tsconfckCache.hasParseResult(filename)) {
const result = await tsconfckCache.getParseResult(filename)
return result.tsconfig
}
} else {
if (!tsconfckCache) {
tsconfckCache = new TSConfckCache<TSConfckParseResult>()
}
const result = await parse(filename, {
Expand Down
24 changes: 13 additions & 11 deletions packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,18 +345,13 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
const nodeStartWithLeadingWhitespace = (
node: DefaultTreeAdapterMap['node'],
) => {
if (node.sourceCodeLocation!.startOffset === 0)
return node.sourceCodeLocation!.startOffset
const startOffset = node.sourceCodeLocation!.startOffset
if (startOffset === 0) return 0

// Gets the offset for the start of the line including the
// newline trailing the previous node
const lineStartOffset =
node.sourceCodeLocation!.startOffset -
node.sourceCodeLocation!.startCol
const line = s.slice(
Math.max(0, lineStartOffset),
node.sourceCodeLocation!.startOffset,
)
startOffset - node.sourceCodeLocation!.startCol

// <previous-line-node></previous-line-node>
// <target-node></target-node>
Expand All @@ -369,9 +364,16 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
//
// However, if there is content between our target node start and the
// previous newline, we cannot strip it out without risking content deletion.
return line.trim()
? node.sourceCodeLocation!.startOffset
: lineStartOffset
let isLineEmpty = false
try {
const line = s.slice(Math.max(0, lineStartOffset), startOffset)
isLineEmpty = !line.trim()
} catch {
// magic-string may throw if there's some content removed in the sliced string,
// which we ignore and assume the line is not empty
}

return isLineEmpty ? lineStartOffset : startOffset
}

// pre-transform
Expand Down
13 changes: 11 additions & 2 deletions packages/vite/src/node/plugins/importAnalysisBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,13 +634,22 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
)
.join(',')}]`

s.append(`\
const mapDepsCode = `\
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = ${fileDepsCode}
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}`)
}\n`

// inject extra code before sourcemap comment
const mapFileCommentMatch =
convertSourceMap.mapFileCommentRegex.exec(code)
if (mapFileCommentMatch) {
s.appendRight(mapFileCommentMatch.index, mapDepsCode)
} else {
s.append(mapDepsCode)
}

// there may still be markers due to inlined dynamic imports, remove
// all the markers regardless
Expand Down
Loading

0 comments on commit c8c39a1

Please sign in to comment.