From 8596dfdb927c76bb09797e7ff2932763914ec63f Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 16:45:46 +0900
Subject: [PATCH 01/34] wip: bump rollup
---
packages/vite/package.json | 2 +-
pnpm-lock.yaml | 227 ++++++++++++++++++++++++++++++++++---
2 files changed, 213 insertions(+), 16 deletions(-)
diff --git a/packages/vite/package.json b/packages/vite/package.json
index e72cbe00a7c441..2b2c4bc753dbca 100644
--- a/packages/vite/package.json
+++ b/packages/vite/package.json
@@ -78,7 +78,7 @@
"dependencies": {
"esbuild": "^0.19.3",
"postcss": "^8.4.30",
- "rollup": "^3.29.2"
+ "rollup": "4.0.0-23"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 20255fcd8773d1..1e20adc8ef4d5f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -230,8 +230,8 @@ importers:
specifier: ^8.4.30
version: 8.4.30
rollup:
- specifier: ^3.29.2
- version: 3.29.2
+ specifier: 4.0.0-23
+ version: 4.0.0-23
optionalDependencies:
fsevents:
specifier: ~2.3.3
@@ -251,25 +251,25 @@ importers:
version: 0.3.19
'@rollup/plugin-alias':
specifier: ^5.0.0
- version: 5.0.0(rollup@3.29.2)
+ version: 5.0.0(rollup@4.0.0-23)
'@rollup/plugin-commonjs':
specifier: ^25.0.4
- version: 25.0.4(rollup@3.29.2)
+ version: 25.0.4(rollup@4.0.0-23)
'@rollup/plugin-dynamic-import-vars':
specifier: ^2.0.5
- version: 2.0.5(rollup@3.29.2)
+ version: 2.0.5(rollup@4.0.0-23)
'@rollup/plugin-json':
specifier: ^6.0.0
- version: 6.0.0(rollup@3.29.2)
+ version: 6.0.0(rollup@4.0.0-23)
'@rollup/plugin-node-resolve':
specifier: 15.2.1
- version: 15.2.1(rollup@3.29.2)
+ version: 15.2.1(rollup@4.0.0-23)
'@rollup/plugin-typescript':
specifier: ^11.1.3
- version: 11.1.3(rollup@3.29.2)(tslib@2.6.2)(typescript@5.2.2)
+ version: 11.1.3(rollup@4.0.0-23)(tslib@2.6.2)(typescript@5.2.2)
'@rollup/pluginutils':
specifier: ^5.0.4
- version: 5.0.4(rollup@3.29.2)
+ version: 5.0.4(rollup@4.0.0-23)
'@types/escape-html':
specifier: ^1.0.2
version: 1.0.2
@@ -389,7 +389,7 @@ importers:
version: 2.0.2
rollup-plugin-license:
specifier: ^3.1.0
- version: 3.1.0(rollup@3.29.2)
+ version: 3.1.0(rollup@4.0.0-23)
sirv:
specifier: ^2.0.3
version: 2.0.3(patch_hash=z45f224eewh2pgpijxcc3aboqm)
@@ -1095,6 +1095,10 @@ importers:
normalize.css:
specifier: ^8.0.1
version: 8.0.1
+ devDependencies:
+ rollup:
+ specifier: 4.0.0-23
+ version: 4.0.0-23
playground/resolve-config: {}
@@ -3554,6 +3558,19 @@ packages:
slash: 4.0.0
dev: true
+ /@rollup/plugin-alias@5.0.0(rollup@4.0.0-23):
+ resolution: {integrity: sha512-l9hY5chSCjuFRPsnRm16twWBiSApl2uYFLsepQYwtBuAxNMQ/1dJqADld40P0Jkqm65GRTLy/AC6hnpVebtLsA==}
+ engines: {node: '>=14.0.0'}
+ peerDependencies:
+ rollup: ^1.20.0||^2.0.0||^3.0.0
+ peerDependenciesMeta:
+ rollup:
+ optional: true
+ dependencies:
+ rollup: 4.0.0-23
+ slash: 4.0.0
+ dev: true
+
/@rollup/plugin-commonjs@25.0.4(rollup@3.29.2):
resolution: {integrity: sha512-L92Vz9WUZXDnlQQl3EwbypJR4+DM2EbsO+/KOcEkP4Mc6Ct453EeDB2uH9lgRwj4w5yflgNpq9pHOiY8aoUXBQ==}
engines: {node: '>=14.0.0'}
@@ -3572,7 +3589,25 @@ packages:
rollup: 3.29.2
dev: true
- /@rollup/plugin-dynamic-import-vars@2.0.5(rollup@3.29.2):
+ /@rollup/plugin-commonjs@25.0.4(rollup@4.0.0-23):
+ resolution: {integrity: sha512-L92Vz9WUZXDnlQQl3EwbypJR4+DM2EbsO+/KOcEkP4Mc6Ct453EeDB2uH9lgRwj4w5yflgNpq9pHOiY8aoUXBQ==}
+ engines: {node: '>=14.0.0'}
+ peerDependencies:
+ rollup: ^2.68.0||^3.0.0
+ peerDependenciesMeta:
+ rollup:
+ optional: true
+ dependencies:
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
+ commondir: 1.0.1
+ estree-walker: 2.0.2
+ glob: 8.1.0
+ is-reference: 1.2.1
+ magic-string: 0.27.0
+ rollup: 4.0.0-23
+ dev: true
+
+ /@rollup/plugin-dynamic-import-vars@2.0.5(rollup@4.0.0-23):
resolution: {integrity: sha512-YNKbZ5Y08DwWHbcqcn5BOxf/X9lVV2fYiL0247k76rL/XNx6xQX0Tti6cCoA2jXhBQdBcDjsFTFoT3nl4QJmWg==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -3581,12 +3616,12 @@ packages:
rollup:
optional: true
dependencies:
- '@rollup/pluginutils': 5.0.4(rollup@3.29.2)
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
astring: 1.8.6
estree-walker: 2.0.2
fast-glob: 3.3.1
magic-string: 0.27.0
- rollup: 3.29.2
+ rollup: 4.0.0-23
dev: true
/@rollup/plugin-json@6.0.0(rollup@3.29.2):
@@ -3602,6 +3637,19 @@ packages:
rollup: 3.29.2
dev: true
+ /@rollup/plugin-json@6.0.0(rollup@4.0.0-23):
+ resolution: {integrity: sha512-i/4C5Jrdr1XUarRhVu27EEwjt4GObltD7c+MkCIpO2QIbojw8MUs+CCTqOphQi3Qtg1FLmYt+l+6YeoIf51J7w==}
+ engines: {node: '>=14.0.0'}
+ peerDependencies:
+ rollup: ^1.20.0||^2.0.0||^3.0.0
+ peerDependenciesMeta:
+ rollup:
+ optional: true
+ dependencies:
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
+ rollup: 4.0.0-23
+ dev: true
+
/@rollup/plugin-node-resolve@15.2.1(rollup@3.29.2):
resolution: {integrity: sha512-nsbUg588+GDSu8/NS8T4UAshO6xeaOfINNuXeVHcKV02LJtoRaM1SiOacClw4kws1SFiNhdLGxlbMY9ga/zs/w==}
engines: {node: '>=14.0.0'}
@@ -3620,6 +3668,24 @@ packages:
rollup: 3.29.2
dev: true
+ /@rollup/plugin-node-resolve@15.2.1(rollup@4.0.0-23):
+ resolution: {integrity: sha512-nsbUg588+GDSu8/NS8T4UAshO6xeaOfINNuXeVHcKV02LJtoRaM1SiOacClw4kws1SFiNhdLGxlbMY9ga/zs/w==}
+ engines: {node: '>=14.0.0'}
+ peerDependencies:
+ rollup: ^2.78.0||^3.0.0
+ peerDependenciesMeta:
+ rollup:
+ optional: true
+ dependencies:
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
+ '@types/resolve': 1.20.2
+ deepmerge: 4.2.2
+ is-builtin-module: 3.2.1
+ is-module: 1.0.0
+ resolve: 1.22.4
+ rollup: 4.0.0-23
+ dev: true
+
/@rollup/plugin-replace@5.0.2(rollup@3.29.2):
resolution: {integrity: sha512-M9YXNekv/C/iHHK+cvORzfRYfPbq0RDD8r0G+bMiTXjNGKulPnCT9O3Ss46WfhI6ZOCgApOP7xAdmCQJ+U2LAA==}
engines: {node: '>=14.0.0'}
@@ -3654,6 +3720,26 @@ packages:
typescript: 5.2.2
dev: true
+ /@rollup/plugin-typescript@11.1.3(rollup@4.0.0-23)(tslib@2.6.2)(typescript@5.2.2):
+ resolution: {integrity: sha512-8o6cNgN44kQBcpsUJTbTXMTtb87oR1O0zgP3Dxm71hrNgparap3VujgofEilTYJo+ivf2ke6uy3/E5QEaiRlDA==}
+ engines: {node: '>=14.0.0'}
+ peerDependencies:
+ rollup: ^2.14.0||^3.0.0
+ tslib: '*'
+ typescript: '>=3.7.0'
+ peerDependenciesMeta:
+ rollup:
+ optional: true
+ tslib:
+ optional: true
+ dependencies:
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
+ resolve: 1.22.4
+ rollup: 4.0.0-23
+ tslib: 2.6.2
+ typescript: 5.2.2
+ dev: true
+
/@rollup/pluginutils@5.0.4(rollup@3.29.2):
resolution: {integrity: sha512-0KJnIoRI8A+a1dqOYLxH8vBf8bphDmty5QvIm2hqm7oFCFYKCAZWWd2hXgMibaPsNDhI0AtpYfQZJG47pt/k4g==}
engines: {node: '>=14.0.0'}
@@ -3669,6 +3755,98 @@ packages:
rollup: 3.29.2
dev: true
+ /@rollup/pluginutils@5.0.4(rollup@4.0.0-23):
+ resolution: {integrity: sha512-0KJnIoRI8A+a1dqOYLxH8vBf8bphDmty5QvIm2hqm7oFCFYKCAZWWd2hXgMibaPsNDhI0AtpYfQZJG47pt/k4g==}
+ engines: {node: '>=14.0.0'}
+ peerDependencies:
+ rollup: ^1.20.0||^2.0.0||^3.0.0
+ peerDependenciesMeta:
+ rollup:
+ optional: true
+ dependencies:
+ '@types/estree': 1.0.1
+ estree-walker: 2.0.2
+ picomatch: 2.3.1
+ rollup: 4.0.0-23
+ dev: true
+
+ /@rollup/rollup-android-arm-eabi@4.0.0-23:
+ resolution: {integrity: sha512-bFVjyz+f4ICADXH6NmEthwLa6LeP0oHSlh5UGDZnGptPzAjMH/gQ3Bo1kFzG0p9xUNW22/uwHb9gnrLGQjgSBA==}
+ cpu: [arm]
+ os: [android]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-android-arm64@4.0.0-23:
+ resolution: {integrity: sha512-iyygT9P3wLXqVnKFE7OpteL32ijdZOnDbJhQ4vsOMfyZyE7ce0fEDMM/VsLirUMHqCH8sQO6lxFq/qBkj3sPLQ==}
+ cpu: [arm64]
+ os: [android]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-darwin-arm64@4.0.0-23:
+ resolution: {integrity: sha512-2Vnxl0XiBxgyk8BDgkZF/AkP17bB8YpfUg73MjLVHzv4Kls9MHUAQLaanDZzqrsyXZpJb0f2+2oALoDK9+lRuA==}
+ cpu: [arm64]
+ os: [darwin]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-darwin-x64@4.0.0-23:
+ resolution: {integrity: sha512-xyZ1WHFgp3xttutYFnk5AMqEGK42uSW6elI11tGi6x3OcQG8WkE6Vq2GQnFNoA8dv0QlZZjldFMBYEQ/ksvBPw==}
+ cpu: [x64]
+ os: [darwin]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-linux-arm-gnueabihf@4.0.0-23:
+ resolution: {integrity: sha512-+eCcJMaejbxvKSBTGMAlYVRk/qYnKENJUvrDVSQGALZPuqALWgI7kdI/MJkfV4aUTyvf5ejb5lkX6/wPoMp38w==}
+ cpu: [arm]
+ os: [linux]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-linux-arm64-gnu@4.0.0-23:
+ resolution: {integrity: sha512-R4ffdK1hkjqqh8RSYOi06tztZPnbExh8ppNL1m5HgwaQhrmcUd3wgBJScaZXmetHUrunWfShxtbQCdZoTp8A2A==}
+ cpu: [arm64]
+ os: [linux]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-linux-x64-gnu@4.0.0-23:
+ resolution: {integrity: sha512-ZB7Sl94bhM4sg5ZVOWKg0MfakJ6W4kDTZNUufteK83eTVHDMtGqCDTxBfMOAT3lDgkK+H6b1txaKgSht72Ss8A==}
+ cpu: [x64]
+ os: [linux]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-linux-x64-musl@4.0.0-23:
+ resolution: {integrity: sha512-LKpQT5+PsXrOUyeuVVvPC1PC0lhSNeBYPF6Q9FgjYosxE+cdFSisU+rCxkRJwYX8fXmcK8/vuMkqPpUP6xCuog==}
+ cpu: [x64]
+ os: [linux]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-win32-arm64-msvc@4.0.0-23:
+ resolution: {integrity: sha512-pEWZzHhioEt8HrM5PV7YiDbPmrZ8ceWtmoL/7xhvOgQ4xD3SCr5kych1gv1YKuWxLNKVl2S3SanARSvPQVcdog==}
+ cpu: [arm64]
+ os: [win32]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-win32-ia32-msvc@4.0.0-23:
+ resolution: {integrity: sha512-oPbbAitsulZ1czKOp7KTOdOVgMw9rFt1AC5+vKXCwEp+7rBFDuehX7dWEGyogsgMevW8oMfrQHBjxIj9tdKIkg==}
+ cpu: [ia32]
+ os: [win32]
+ requiresBuild: true
+ optional: true
+
+ /@rollup/rollup-win32-x64-msvc@4.0.0-23:
+ resolution: {integrity: sha512-O4vk4bBXS5Hnla8Mmx1rP+X1SerP0Obl4HqgeluKqon1b8l6kHvS4sXSQuSMw7+VH4NFOEqfV7ES6cObwhSjSA==}
+ cpu: [x64]
+ os: [win32]
+ requiresBuild: true
+ optional: true
+
/@rushstack/node-core-library@3.60.0(@types/node@18.17.19):
resolution: {integrity: sha512-PcyrqhILvzU+65wMFybQ2VeGNnU5JzhDq2OvUi3j6jPUxyllM7b2hrRUwCuVaYboewYzIbpzXFzgxe2K7ii1nw==}
peerDependencies:
@@ -8715,7 +8893,7 @@ packages:
'@babel/code-frame': 7.22.13
dev: true
- /rollup-plugin-license@3.1.0(rollup@3.29.2):
+ /rollup-plugin-license@3.1.0(rollup@4.0.0-23):
resolution: {integrity: sha512-Cny2H2hJ7K+VdcJkH1pNcYRVhqIhZNu/fPusedW53fNZQOIwpXiznJ220EFvDkJbFUEkLqIDsDB5bEr/N9qfqw==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -8728,7 +8906,7 @@ packages:
mkdirp: 3.0.1
moment: 2.29.3
package-name-regex: 2.0.6
- rollup: 3.29.2
+ rollup: 4.0.0-23
spdx-expression-validate: 2.0.0
spdx-satisfies: 5.0.1
dev: true
@@ -8739,6 +8917,25 @@ packages:
hasBin: true
optionalDependencies:
fsevents: 2.3.3
+ dev: true
+
+ /rollup@4.0.0-23:
+ resolution: {integrity: sha512-a5YMr7oRSMsslt101mwitUo1RR2IcS/3tnWB4GZ4zMSg4NskKu6b7HEe6uZdsTGz2JUWL0ahBpdJ/WOz0lyJ1Q==}
+ engines: {node: '>=18.0.0', npm: '>=8.0.0'}
+ hasBin: true
+ optionalDependencies:
+ '@rollup/rollup-android-arm-eabi': 4.0.0-23
+ '@rollup/rollup-android-arm64': 4.0.0-23
+ '@rollup/rollup-darwin-arm64': 4.0.0-23
+ '@rollup/rollup-darwin-x64': 4.0.0-23
+ '@rollup/rollup-linux-arm-gnueabihf': 4.0.0-23
+ '@rollup/rollup-linux-arm64-gnu': 4.0.0-23
+ '@rollup/rollup-linux-x64-gnu': 4.0.0-23
+ '@rollup/rollup-linux-x64-musl': 4.0.0-23
+ '@rollup/rollup-win32-arm64-msvc': 4.0.0-23
+ '@rollup/rollup-win32-ia32-msvc': 4.0.0-23
+ '@rollup/rollup-win32-x64-msvc': 4.0.0-23
+ fsevents: 2.3.3
/run-parallel@1.2.0:
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
From b907e6e315b31db389c7bba3e4514435259716c7 Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 16:46:37 +0900
Subject: [PATCH 02/34] wip: remove `acorn`/`acornInjectPlugins` option, remove
additional options to `this.parse`
---
packages/vite/src/node/server/pluginContainer.ts | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts
index 76985d93b0cf5d..23af7deea20c60 100644
--- a/packages/vite/src/node/server/pluginContainer.ts
+++ b/packages/vite/src/node/server/pluginContainer.ts
@@ -67,7 +67,6 @@ import colors from 'picocolors'
import type * as postcss from 'postcss'
import type { Plugin } from '../plugin'
import {
- arraify,
cleanUrl,
combineSourcemaps,
createDebugger,
@@ -152,7 +151,7 @@ type PluginContext = Omit<
| 'moduleIds'
>
-export let parser = acorn.Parser.extend(importAssertions)
+export const parser = acorn.Parser.extend(importAssertions)
export async function createPluginContainer(
config: ResolvedConfig,
@@ -628,17 +627,7 @@ export async function createPluginContainer(
optionsHook.call(minimalContext, options),
)) || options
}
- if (options.acornInjectPlugins) {
- parser = acorn.Parser.extend(
- importAssertions,
- ...(arraify(options.acornInjectPlugins) as any),
- )
- }
- return {
- acorn,
- acornInjectPlugins: [],
- ...options,
- }
+ return options
})(),
getModuleInfo,
From e6474baa5ffcecd31d157f2fb7daaf150e0fcc67 Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 16:48:41 +0900
Subject: [PATCH 03/34] wip: replace "assertions" with "attributes"
---
packages/vite/LICENSE.md | 26 +++++++++++++++++--
packages/vite/package.json | 2 +-
packages/vite/src/node/plugin.ts | 2 +-
.../vite/src/node/plugins/importAnalysis.ts | 6 ++---
.../src/node/plugins/importAnalysisBuild.ts | 6 ++---
.../vite/src/node/plugins/importMetaGlob.ts | 2 +-
.../vite/src/node/server/pluginContainer.ts | 12 ++++-----
.../node/ssr/__tests__/ssrTransform.spec.ts | 6 ++---
pnpm-lock.yaml | 14 ++++------
9 files changed, 47 insertions(+), 29 deletions(-)
diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md
index 0817e158172a56..c58f090a77bdd7 100644
--- a/packages/vite/LICENSE.md
+++ b/packages/vite/LICENSE.md
@@ -566,10 +566,32 @@ Repository: https://github.com/acornjs/acorn.git
---------------------------------------
-## acorn-import-assertions
+## acorn-import-attributes
License: MIT
By: Sven Sauleau
-Repository: https://github.com/xtuc/acorn-import-assertions
+Repository: https://github.com/xtuc/acorn-import-attributes
+
+> MIT License
+>
+> Copyright (c) 2023 Sven Sauleau
+>
+> 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.
---------------------------------------
diff --git a/packages/vite/package.json b/packages/vite/package.json
index 2b2c4bc753dbca..06b618ee51da2e 100644
--- a/packages/vite/package.json
+++ b/packages/vite/package.json
@@ -98,7 +98,7 @@
"@types/escape-html": "^1.0.2",
"@types/pnpapi": "^0.0.3",
"acorn": "^8.10.0",
- "acorn-import-assertions": "^1.9.0",
+ "acorn-import-attributes": "^1.9.2",
"acorn-walk": "^8.2.0",
"cac": "^6.7.14",
"chokidar": "^3.5.3",
diff --git a/packages/vite/src/node/plugin.ts b/packages/vite/src/node/plugin.ts
index c58749b58479c9..e6e5e4d80f701d 100644
--- a/packages/vite/src/node/plugin.ts
+++ b/packages/vite/src/node/plugin.ts
@@ -150,7 +150,7 @@ export interface Plugin extends RollupPlugin {
source: string,
importer: string | undefined,
options: {
- assertions: Record
+ attributes: Record
custom?: CustomPluginOptions
ssr?: boolean
/**
diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts
index a416f9bf98ea95..84a8b873172c61 100644
--- a/packages/vite/src/node/plugins/importAnalysis.ts
+++ b/packages/vite/src/node/plugins/importAnalysis.ts
@@ -425,7 +425,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
ss: expStart,
se: expEnd,
d: dynamicIndex,
- a: assertIndex,
+ a: attributeIndex,
} = importSpecifier
// #2083 User may use escape path,
@@ -481,8 +481,8 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
const isDynamicImport = dynamicIndex > -1
- // strip import assertions as we can process them ourselves
- if (!isDynamicImport && assertIndex > -1) {
+ // strip import attributes as we can process them ourselves
+ if (!isDynamicImport && attributeIndex > -1) {
str().remove(end + 1, expEnd)
}
diff --git a/packages/vite/src/node/plugins/importAnalysisBuild.ts b/packages/vite/src/node/plugins/importAnalysisBuild.ts
index b54c3705b879aa..53cfb51a587108 100644
--- a/packages/vite/src/node/plugins/importAnalysisBuild.ts
+++ b/packages/vite/src/node/plugins/importAnalysisBuild.ts
@@ -296,13 +296,13 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
se: expEnd,
n: specifier,
d: dynamicIndex,
- a: assertIndex,
+ a: attributeIndex,
} = imports[index]
const isDynamicImport = dynamicIndex > -1
- // strip import assertions as we can process them ourselves
- if (!isDynamicImport && assertIndex > -1) {
+ // strip import attributes as we can process them ourselves
+ if (!isDynamicImport && attributeIndex > -1) {
str().remove(end + 1, expEnd)
}
diff --git a/packages/vite/src/node/plugins/importMetaGlob.ts b/packages/vite/src/node/plugins/importMetaGlob.ts
index c3633ac83d15b8..695e6fada9d713 100644
--- a/packages/vite/src/node/plugins/importMetaGlob.ts
+++ b/packages/vite/src/node/plugins/importMetaGlob.ts
@@ -486,7 +486,7 @@ type IdResolver = (
id: string,
importer?: string,
options?: {
- assertions?: Record
+ attributes?: Record
custom?: CustomPluginOptions
isEntry?: boolean
skipSelf?: boolean
diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts
index 23af7deea20c60..eb09be391e644e 100644
--- a/packages/vite/src/node/server/pluginContainer.ts
+++ b/packages/vite/src/node/server/pluginContainer.ts
@@ -60,7 +60,7 @@ import * as acorn from 'acorn'
import type { RawSourceMap } from '@ampproject/remapping'
import { TraceMap, originalPositionFor } from '@jridgewell/trace-mapping'
// @ts-expect-error untyped
-import { importAssertions } from 'acorn-import-assertions'
+import { importAttributes } from 'acorn-import-attributes'
import MagicString from 'magic-string'
import type { FSWatcher } from 'chokidar'
import colors from 'picocolors'
@@ -115,7 +115,7 @@ export interface PluginContainer {
id: string,
importer?: string,
options?: {
- assertions?: Record
+ attributes?: Record
custom?: CustomPluginOptions
skip?: Set
ssr?: boolean
@@ -151,7 +151,7 @@ type PluginContext = Omit<
| 'moduleIds'
>
-export const parser = acorn.Parser.extend(importAssertions)
+export const parser = acorn.Parser.extend(importAttributes)
export async function createPluginContainer(
config: ResolvedConfig,
@@ -306,7 +306,7 @@ export async function createPluginContainer(
id: string,
importer?: string,
options?: {
- assertions?: Record
+ attributes?: Record
custom?: CustomPluginOptions
isEntry?: boolean
skipSelf?: boolean
@@ -318,7 +318,7 @@ export async function createPluginContainer(
skip.add(this._activePlugin)
}
let out = await container.resolveId(id, importer, {
- assertions: options?.assertions,
+ attributes: options?.attributes,
custom: options?.custom,
isEntry: !!options?.isEntry,
skip,
@@ -667,7 +667,7 @@ export async function createPluginContainer(
: plugin.resolveId
const result = await handleHookPromise(
handler.call(ctx as any, rawId, importer, {
- assertions: options?.assertions ?? {},
+ attributes: options?.attributes ?? {},
custom: options?.custom,
isEntry: !!options?.isEntry,
ssr,
diff --git a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts
index b2414752ab0444..1afcb3ed5599dd 100644
--- a/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts
+++ b/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts
@@ -938,14 +938,14 @@ const Baz = class extends Foo {}
test('import assertion attribute', async () => {
expect(
await ssrTransformSimpleCode(`
- import * as foo from './foo.json' assert { type: 'json' };
- import('./bar.json', { assert: { type: 'json' } });
+ import * as foo from './foo.json' with { type: 'json' };
+ import('./bar.json', { with: { type: 'json' } });
`),
).toMatchInlineSnapshot(`
"const __vite_ssr_import_0__ = await __vite_ssr_import__(\\"./foo.json\\");
- __vite_ssr_dynamic_import__('./bar.json', { assert: { type: 'json' } });
+ __vite_ssr_dynamic_import__('./bar.json', { with: { type: 'json' } });
"`)
})
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1e20adc8ef4d5f..eac1bb58949471 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -279,9 +279,9 @@ importers:
acorn:
specifier: ^8.10.0
version: 8.10.0
- acorn-import-assertions:
- specifier: ^1.9.0
- version: 1.9.0(acorn@8.10.0)
+ acorn-import-attributes:
+ specifier: ^1.9.2
+ version: 1.9.2(acorn@8.10.0)
acorn-walk:
specifier: ^8.2.0
version: 8.2.0(acorn@8.10.0)
@@ -1095,10 +1095,6 @@ importers:
normalize.css:
specifier: ^8.0.1
version: 8.0.1
- devDependencies:
- rollup:
- specifier: 4.0.0-23
- version: 4.0.0-23
playground/resolve-config: {}
@@ -4450,8 +4446,8 @@ packages:
mime-types: 2.1.35
negotiator: 0.6.3
- /acorn-import-assertions@1.9.0(acorn@8.10.0):
- resolution: {integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==}
+ /acorn-import-attributes@1.9.2(acorn@8.10.0):
+ resolution: {integrity: sha512-O+nfJwNolEA771IYJaiLWK1UAwjNsQmZbTRqqwBYxCgVQTmpFEMvBw6LOIQV0Me339L5UMVYFyRohGnGlQDdIQ==}
peerDependencies:
acorn: ^8
dependencies:
From 00e0ece9a087cf1f7649be93208c02f5f2c92519 Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 16:50:54 +0900
Subject: [PATCH 04/34] wip: replace RollupWarning with RollupLog
removed by https://github.com/rollup/rollup/pull/5147
---
packages/vite/src/node/build.ts | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts
index c1f5821e4a7b40..da33345b44c3a8 100644
--- a/packages/vite/src/node/build.ts
+++ b/packages/vite/src/node/build.ts
@@ -14,7 +14,6 @@ import type {
RollupLog,
RollupOptions,
RollupOutput,
- RollupWarning,
RollupWatcher,
WatcherOptions,
} from 'rollup'
@@ -858,7 +857,7 @@ const dynamicImportWarningIgnoreList = [
]
export function onRollupWarning(
- warning: RollupWarning,
+ warning: RollupLog,
warn: LoggingFunction,
config: ResolvedConfig,
): void {
From 0c488c7472786bb1723a100da9d05123c2b69c86 Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 16:53:28 +0900
Subject: [PATCH 05/34] wip: remove omit `moduleIds`
---
packages/vite/src/node/server/pluginContainer.ts | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts
index eb09be391e644e..eb93c64850768e 100644
--- a/packages/vite/src/node/server/pluginContainer.ts
+++ b/packages/vite/src/node/server/pluginContainer.ts
@@ -146,9 +146,7 @@ export interface PluginContainer {
type PluginContext = Omit<
RollupPluginContext,
// not documented
- | 'cache'
- // deprecated
- | 'moduleIds'
+ 'cache'
>
export const parser = acorn.Parser.extend(importAttributes)
From d9085f7b249ee059e6ab2462e86c50b57af16278 Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 18:20:02 +0900
Subject: [PATCH 06/34] wip: call `this.addWatchFile` in vite:load-fallback
plugin
---
packages/vite/src/node/plugins/loadFallback.ts | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/packages/vite/src/node/plugins/loadFallback.ts b/packages/vite/src/node/plugins/loadFallback.ts
index b806f8b93ac201..9274622dff5528 100644
--- a/packages/vite/src/node/plugins/loadFallback.ts
+++ b/packages/vite/src/node/plugins/loadFallback.ts
@@ -10,10 +10,14 @@ export function loadFallbackPlugin(): Plugin {
name: 'vite:load-fallback',
async load(id) {
try {
- // if we don't add `await` here, we couldn't catch the error in readFile
- return await fsp.readFile(cleanUrl(id), 'utf-8')
+ const cleanedId = cleanUrl(id)
+ const content = await fsp.readFile(cleanedId, 'utf-8')
+ this.addWatchFile(cleanedId)
+ return content
} catch (e) {
- return fsp.readFile(id, 'utf-8')
+ const content = await fsp.readFile(id, 'utf-8')
+ this.addWatchFile(id)
+ return content
}
},
}
From 4d4929278c45dd71c19e66a87c06f01508202efa Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 18:20:13 +0900
Subject: [PATCH 07/34] wip: remove utf8 BOM for now
---
playground/resolve/utf8-bom/main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/playground/resolve/utf8-bom/main.js b/playground/resolve/utf8-bom/main.js
index 6273e5ac04e016..dbb4932fd56b91 100644
--- a/playground/resolve/utf8-bom/main.js
+++ b/playground/resolve/utf8-bom/main.js
@@ -1,3 +1,3 @@
-import '@babel/runtime/helpers/esm/slicedToArray'
+import '@babel/runtime/helpers/esm/slicedToArray'
export const msg = '[success]'
From f161d22fbb1b066d212f756327c45303832ce31c Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 23:29:29 +0900
Subject: [PATCH 08/34] wip: use parse function from rollup
---
packages/vite/LICENSE.md | 29 ------------
packages/vite/package.json | 1 -
.../vite/src/node/server/pluginContainer.ts | 44 ++++++++++++++-----
packages/vite/src/node/ssr/ssrTransform.ts | 37 +++++++++-------
pnpm-lock.yaml | 11 -----
5 files changed, 54 insertions(+), 68 deletions(-)
diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md
index c58f090a77bdd7..7883989d38f576 100644
--- a/packages/vite/LICENSE.md
+++ b/packages/vite/LICENSE.md
@@ -566,35 +566,6 @@ Repository: https://github.com/acornjs/acorn.git
---------------------------------------
-## acorn-import-attributes
-License: MIT
-By: Sven Sauleau
-Repository: https://github.com/xtuc/acorn-import-attributes
-
-> MIT License
->
-> Copyright (c) 2023 Sven Sauleau
->
-> 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.
-
----------------------------------------
-
## acorn-walk
License: MIT
By: Marijn Haverbeke, Ingvar Stepanyan, Adrian Heine
diff --git a/packages/vite/package.json b/packages/vite/package.json
index 06b618ee51da2e..5c5cc0981c32b7 100644
--- a/packages/vite/package.json
+++ b/packages/vite/package.json
@@ -98,7 +98,6 @@
"@types/escape-html": "^1.0.2",
"@types/pnpapi": "^0.0.3",
"acorn": "^8.10.0",
- "acorn-import-attributes": "^1.9.2",
"acorn-walk": "^8.2.0",
"cac": "^6.7.14",
"chokidar": "^3.5.3",
diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts
index eb93c64850768e..d880ec6936c0b9 100644
--- a/packages/vite/src/node/server/pluginContainer.ts
+++ b/packages/vite/src/node/server/pluginContainer.ts
@@ -32,8 +32,9 @@ SOFTWARE.
import fs from 'node:fs'
import { join } from 'node:path'
import { performance } from 'node:perf_hooks'
-import { VERSION as rollupVersion } from 'rollup'
+import { rollup, VERSION as rollupVersion } from 'rollup'
import type {
+ AstNode,
AsyncPluginHooks,
CustomPluginOptions,
EmittedFile,
@@ -56,11 +57,8 @@ import type {
SourceMap,
TransformResult,
} from 'rollup'
-import * as acorn from 'acorn'
import type { RawSourceMap } from '@ampproject/remapping'
import { TraceMap, originalPositionFor } from '@jridgewell/trace-mapping'
-// @ts-expect-error untyped
-import { importAttributes } from 'acorn-import-attributes'
import MagicString from 'magic-string'
import type { FSWatcher } from 'chokidar'
import colors from 'picocolors'
@@ -149,7 +147,32 @@ type PluginContext = Omit<
'cache'
>
-export const parser = acorn.Parser.extend(importAttributes)
+export type RollupParseFunc = (
+ input: string,
+ options?: { allowReturnOutsideFunction?: boolean },
+) => AstNode
+
+export const getRollupParseFunc = async (): Promise => {
+ let rollupParse!: RollupParseFunc
+ await rollup({
+ input: 'dummy',
+ plugins: [
+ {
+ name: 'get-parse',
+ resolveId(id) {
+ return id
+ },
+ load(id) {
+ return ''
+ },
+ transform(code, id) {
+ rollupParse = this.parse
+ },
+ },
+ ],
+ })
+ return rollupParse
+}
export async function createPluginContainer(
config: ResolvedConfig,
@@ -274,6 +297,8 @@ export async function createPluginContainer(
}
}
+ const rollupParseFunc = await getRollupParseFunc()
+
// we should create a new context for each async hook pipeline so that the
// active plugin in that pipeline can be tracked in a concurrency-safe manner.
// using a class to make creating new contexts more efficient
@@ -291,13 +316,8 @@ export async function createPluginContainer(
this._activePlugin = initialPlugin || null
}
- parse(code: string, opts: any = {}) {
- return parser.parse(code, {
- sourceType: 'module',
- ecmaVersion: 'latest',
- locations: true,
- ...opts,
- })
+ parse(code: string, opts: any) {
+ return rollupParseFunc(code, opts)
}
async resolve(
diff --git a/packages/vite/src/node/ssr/ssrTransform.ts b/packages/vite/src/node/ssr/ssrTransform.ts
index e13e2dec37d624..ac1373c0dded35 100644
--- a/packages/vite/src/node/ssr/ssrTransform.ts
+++ b/packages/vite/src/node/ssr/ssrTransform.ts
@@ -13,7 +13,8 @@ import { extract_names as extractNames } from 'periscopic'
import { walk as eswalk } from 'estree-walker'
import type { RawSourceMap } from '@ampproject/remapping'
import type { TransformResult } from '../server/transformRequest'
-import { parser } from '../server/pluginContainer'
+import type { RollupParseFunc } from '../server/pluginContainer'
+import { getRollupParseFunc } from '../server/pluginContainer'
import { combineSourcemaps } from '../utils'
import { isJSONRequest } from '../plugins/json'
@@ -61,6 +62,8 @@ async function ssrTransformJSON(
}
}
+let rollupParseFunc: RollupParseFunc | undefined
+
async function ssrTransformScript(
code: string,
inMap: SourceMap | { mappings: '' } | null,
@@ -69,14 +72,13 @@ async function ssrTransformScript(
): Promise {
const s = new MagicString(code)
+ if (!rollupParseFunc) {
+ rollupParseFunc = await getRollupParseFunc()
+ }
+
let ast: any
try {
- ast = parser.parse(code, {
- sourceType: 'module',
- ecmaVersion: 'latest',
- locations: true,
- allowHashBang: true,
- })
+ ast = rollupParseFunc(code)
} catch (err) {
if (!err.loc || !err.loc.line) throw err
const line = err.loc.line
@@ -377,7 +379,7 @@ function walk(
}
;(eswalk as any)(root, {
- enter(node: Node, parent: Node | null) {
+ enter(node: Node, parent: Node | null, prop: string) {
if (node.type === 'ImportDeclaration') {
return this.skip()
}
@@ -405,7 +407,7 @@ function walk(
if (node.type === 'Identifier') {
if (
!isInScope(node.name, parentStack) &&
- isRefIdentifier(node, parent!, parentStack)
+ isRefIdentifier(node, parent!, parentStack, prop)
) {
// record the identifier, for DFS -> BFS
identifiers.push([node, parentStack.slice(0)])
@@ -427,7 +429,7 @@ function walk(
return
}
;(eswalk as any)(p.type === 'AssignmentPattern' ? p.left : p, {
- enter(child: Node, parent: Node) {
+ enter(child: Node, parent: Node, prop: string) {
// skip params default value of destructure
if (
parent?.type === 'AssignmentPattern' &&
@@ -437,7 +439,7 @@ function walk(
}
if (child.type !== 'Identifier') return
// do not record as scope variable if is a destructuring keyword
- if (isStaticPropertyKey(child, parent)) return
+ if (isStaticPropertyKey(child, parent, prop)) return
// do not record if this is a default value
// assignment of a destructuring variable
if (
@@ -489,7 +491,12 @@ function walk(
})
}
-function isRefIdentifier(id: Identifier, parent: _Node, parentStack: _Node[]) {
+function isRefIdentifier(
+ id: Identifier,
+ parent: _Node,
+ parentStack: _Node[],
+ prop: string,
+) {
// declaration id
if (
parent.type === 'CatchClause' ||
@@ -517,7 +524,7 @@ function isRefIdentifier(id: Identifier, parent: _Node, parentStack: _Node[]) {
}
// property key
- if (isStaticPropertyKey(id, parent)) {
+ if (isStaticPropertyKey(id, parent, prop)) {
return false
}
@@ -558,8 +565,8 @@ function isRefIdentifier(id: Identifier, parent: _Node, parentStack: _Node[]) {
const isStaticProperty = (node: _Node): node is Property =>
node && node.type === 'Property' && !node.computed
-const isStaticPropertyKey = (node: _Node, parent: _Node) =>
- isStaticProperty(parent) && parent.key === node
+const isStaticPropertyKey = (node: _Node, parent: _Node, prop: string) =>
+ isStaticProperty(parent) && prop === 'key' && parent.key === node
const functionNodeTypeRE = /Function(?:Expression|Declaration)$|Method$/
function isFunction(node: _Node): node is FunctionNode {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index eac1bb58949471..cf6813c2ba6fe3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -279,9 +279,6 @@ importers:
acorn:
specifier: ^8.10.0
version: 8.10.0
- acorn-import-attributes:
- specifier: ^1.9.2
- version: 1.9.2(acorn@8.10.0)
acorn-walk:
specifier: ^8.2.0
version: 8.2.0(acorn@8.10.0)
@@ -4446,14 +4443,6 @@ packages:
mime-types: 2.1.35
negotiator: 0.6.3
- /acorn-import-attributes@1.9.2(acorn@8.10.0):
- resolution: {integrity: sha512-O+nfJwNolEA771IYJaiLWK1UAwjNsQmZbTRqqwBYxCgVQTmpFEMvBw6LOIQV0Me339L5UMVYFyRohGnGlQDdIQ==}
- peerDependencies:
- acorn: ^8
- dependencies:
- acorn: 8.10.0
- dev: true
-
/acorn-jsx@5.3.2(acorn@8.10.0):
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
peerDependencies:
From ddde37fbd93986808c1a4a00cf8f6e25a56509b2 Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 23:47:27 +0900
Subject: [PATCH 09/34] wip: bump rollup for plugin-legacy
---
package.json | 2 +-
pnpm-lock.yaml | 26 +++-----------------------
2 files changed, 4 insertions(+), 24 deletions(-)
diff --git a/package.json b/package.json
index 098001edbc31a5..c056d24c031cd2 100644
--- a/package.json
+++ b/package.json
@@ -77,7 +77,7 @@
"playwright-chromium": "^1.38.1",
"prettier": "3.0.3",
"rimraf": "^5.0.1",
- "rollup": "^3.29.2",
+ "rollup": "4.0.0-23",
"simple-git-hooks": "^2.9.0",
"tslib": "^2.6.2",
"tsx": "^3.13.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index cf6813c2ba6fe3..fc6d53248a45a0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -32,7 +32,7 @@ importers:
version: 7.37.0(@types/node@18.17.19)
'@rollup/plugin-typescript':
specifier: ^11.1.3
- version: 11.1.3(rollup@3.29.2)(tslib@2.6.2)(typescript@5.2.2)
+ version: 11.1.3(rollup@4.0.0-23)(tslib@2.6.2)(typescript@5.2.2)
'@types/babel__core':
specifier: ^7.20.2
version: 7.20.2
@@ -133,8 +133,8 @@ importers:
specifier: ^5.0.1
version: 5.0.1
rollup:
- specifier: ^3.29.2
- version: 3.29.2
+ specifier: 4.0.0-23
+ version: 4.0.0-23
simple-git-hooks:
specifier: ^2.9.0
version: 2.9.0
@@ -3693,26 +3693,6 @@ packages:
rollup: 3.29.2
dev: true
- /@rollup/plugin-typescript@11.1.3(rollup@3.29.2)(tslib@2.6.2)(typescript@5.2.2):
- resolution: {integrity: sha512-8o6cNgN44kQBcpsUJTbTXMTtb87oR1O0zgP3Dxm71hrNgparap3VujgofEilTYJo+ivf2ke6uy3/E5QEaiRlDA==}
- engines: {node: '>=14.0.0'}
- peerDependencies:
- rollup: ^2.14.0||^3.0.0
- tslib: '*'
- typescript: '>=3.7.0'
- peerDependenciesMeta:
- rollup:
- optional: true
- tslib:
- optional: true
- dependencies:
- '@rollup/pluginutils': 5.0.4(rollup@3.29.2)
- resolve: 1.22.4
- rollup: 3.29.2
- tslib: 2.6.2
- typescript: 5.2.2
- dev: true
-
/@rollup/plugin-typescript@11.1.3(rollup@4.0.0-23)(tslib@2.6.2)(typescript@5.2.2):
resolution: {integrity: sha512-8o6cNgN44kQBcpsUJTbTXMTtb87oR1O0zgP3Dxm71hrNgparap3VujgofEilTYJo+ivf2ke6uy3/E5QEaiRlDA==}
engines: {node: '>=14.0.0'}
From 49dafa016e6ab23482b9fe529b9bceeff63906af Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 23:56:02 +0900
Subject: [PATCH 10/34] wip: default of skipSelf is now true
---
packages/vite/src/node/plugins/importAnalysisBuild.ts | 4 +++-
packages/vite/src/node/plugins/optimizedDeps.ts | 5 +----
packages/vite/src/node/plugins/preAlias.ts | 1 -
packages/vite/src/node/server/pluginContainer.ts | 2 +-
4 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/packages/vite/src/node/plugins/importAnalysisBuild.ts b/packages/vite/src/node/plugins/importAnalysisBuild.ts
index 53cfb51a587108..6272ae4b1eef96 100644
--- a/packages/vite/src/node/plugins/importAnalysisBuild.ts
+++ b/packages/vite/src/node/plugins/importAnalysisBuild.ts
@@ -252,7 +252,9 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
}
}
- const resolved = await this.resolve(url, importerFile)
+ const resolved = await this.resolve(url, importerFile, {
+ skipSelf: false,
+ })
if (!resolved) {
// in ssr, we should let node handle the missing modules
diff --git a/packages/vite/src/node/plugins/optimizedDeps.ts b/packages/vite/src/node/plugins/optimizedDeps.ts
index 7bb1e040517320..1086ab73d10046 100644
--- a/packages/vite/src/node/plugins/optimizedDeps.ts
+++ b/packages/vite/src/node/plugins/optimizedDeps.ts
@@ -102,10 +102,7 @@ export function optimizedDepsBuildPlugin(config: ResolvedConfig): Plugin {
// When a optimized dep is aliased, we need to avoid waiting for it before optimizing
return
}
- const resolved = await this.resolve(id, importer, {
- ...options,
- skipSelf: true,
- })
+ const resolved = await this.resolve(id, importer, options)
if (resolved && !resolved.external) {
depsOptimizer.delayDepsOptimizerUntil(resolved.id, async () => {
await this.load(resolved)
diff --git a/packages/vite/src/node/plugins/preAlias.ts b/packages/vite/src/node/plugins/preAlias.ts
index cd86bac770d823..029bca0ac9f067 100644
--- a/packages/vite/src/node/plugins/preAlias.ts
+++ b/packages/vite/src/node/plugins/preAlias.ts
@@ -56,7 +56,6 @@ export function preAliasPlugin(config: ResolvedConfig): Plugin {
const resolved = await this.resolve(id, importer, {
...options,
custom: { ...options.custom, 'vite:pre-alias': true },
- skipSelf: true,
})
if (resolved && !depsOptimizer.isOptimizedDepFile(resolved.id)) {
const optimizeDeps = depsOptimizer.options
diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts
index d880ec6936c0b9..4b891102a4fcf3 100644
--- a/packages/vite/src/node/server/pluginContainer.ts
+++ b/packages/vite/src/node/server/pluginContainer.ts
@@ -331,7 +331,7 @@ export async function createPluginContainer(
},
) {
let skip: Set | undefined
- if (options?.skipSelf && this._activePlugin) {
+ if (options?.skipSelf !== false && this._activePlugin) {
skip = new Set(this._resolveSkips)
skip.add(this._activePlugin)
}
From 176f6d52e281ec26047861fdc2efada15bcb618c Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Sat, 30 Sep 2023 23:57:46 +0900
Subject: [PATCH 11/34] wip: ignore rollup version mismatch type error
---
packages/create-vite/build.config.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/create-vite/build.config.ts b/packages/create-vite/build.config.ts
index 71d1ba88717d6d..03907ba7e0d809 100644
--- a/packages/create-vite/build.config.ts
+++ b/packages/create-vite/build.config.ts
@@ -23,6 +23,7 @@ export default defineBuildConfig({
'rollup:options'(ctx, options) {
options.plugins = [
options.plugins,
+ // @ts-expect-error TODO: unbuild uses rollup v3 and Vite uses rollup v4
licensePlugin(
path.resolve(__dirname, './LICENSE'),
'create-vite license',
From 9f36ca350de932388c245e853d1235ecaf8d3d4e Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Tue, 3 Oct 2023 18:23:47 +0900
Subject: [PATCH 12/34] wip: bump rollup
---
package.json | 2 +-
packages/vite/package.json | 2 +-
pnpm-lock.yaml | 138 ++++++++++++++++++-------------------
3 files changed, 71 insertions(+), 71 deletions(-)
diff --git a/package.json b/package.json
index c056d24c031cd2..9e22a4bedc115c 100644
--- a/package.json
+++ b/package.json
@@ -77,7 +77,7 @@
"playwright-chromium": "^1.38.1",
"prettier": "3.0.3",
"rimraf": "^5.0.1",
- "rollup": "4.0.0-23",
+ "rollup": "4.0.0-24",
"simple-git-hooks": "^2.9.0",
"tslib": "^2.6.2",
"tsx": "^3.13.0",
diff --git a/packages/vite/package.json b/packages/vite/package.json
index 5c5cc0981c32b7..bb685c36b305b3 100644
--- a/packages/vite/package.json
+++ b/packages/vite/package.json
@@ -78,7 +78,7 @@
"dependencies": {
"esbuild": "^0.19.3",
"postcss": "^8.4.30",
- "rollup": "4.0.0-23"
+ "rollup": "4.0.0-24"
},
"optionalDependencies": {
"fsevents": "~2.3.3"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index fc6d53248a45a0..5bad315c8ced27 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -32,7 +32,7 @@ importers:
version: 7.37.0(@types/node@18.17.19)
'@rollup/plugin-typescript':
specifier: ^11.1.3
- version: 11.1.3(rollup@4.0.0-23)(tslib@2.6.2)(typescript@5.2.2)
+ version: 11.1.3(rollup@4.0.0-24)(tslib@2.6.2)(typescript@5.2.2)
'@types/babel__core':
specifier: ^7.20.2
version: 7.20.2
@@ -133,8 +133,8 @@ importers:
specifier: ^5.0.1
version: 5.0.1
rollup:
- specifier: 4.0.0-23
- version: 4.0.0-23
+ specifier: 4.0.0-24
+ version: 4.0.0-24
simple-git-hooks:
specifier: ^2.9.0
version: 2.9.0
@@ -230,8 +230,8 @@ importers:
specifier: ^8.4.30
version: 8.4.30
rollup:
- specifier: 4.0.0-23
- version: 4.0.0-23
+ specifier: 4.0.0-24
+ version: 4.0.0-24
optionalDependencies:
fsevents:
specifier: ~2.3.3
@@ -251,25 +251,25 @@ importers:
version: 0.3.19
'@rollup/plugin-alias':
specifier: ^5.0.0
- version: 5.0.0(rollup@4.0.0-23)
+ version: 5.0.0(rollup@4.0.0-24)
'@rollup/plugin-commonjs':
specifier: ^25.0.4
- version: 25.0.4(rollup@4.0.0-23)
+ version: 25.0.4(rollup@4.0.0-24)
'@rollup/plugin-dynamic-import-vars':
specifier: ^2.0.5
- version: 2.0.5(rollup@4.0.0-23)
+ version: 2.0.5(rollup@4.0.0-24)
'@rollup/plugin-json':
specifier: ^6.0.0
- version: 6.0.0(rollup@4.0.0-23)
+ version: 6.0.0(rollup@4.0.0-24)
'@rollup/plugin-node-resolve':
specifier: 15.2.1
- version: 15.2.1(rollup@4.0.0-23)
+ version: 15.2.1(rollup@4.0.0-24)
'@rollup/plugin-typescript':
specifier: ^11.1.3
- version: 11.1.3(rollup@4.0.0-23)(tslib@2.6.2)(typescript@5.2.2)
+ version: 11.1.3(rollup@4.0.0-24)(tslib@2.6.2)(typescript@5.2.2)
'@rollup/pluginutils':
specifier: ^5.0.4
- version: 5.0.4(rollup@4.0.0-23)
+ version: 5.0.4(rollup@4.0.0-24)
'@types/escape-html':
specifier: ^1.0.2
version: 1.0.2
@@ -386,7 +386,7 @@ importers:
version: 2.0.2
rollup-plugin-license:
specifier: ^3.1.0
- version: 3.1.0(rollup@4.0.0-23)
+ version: 3.1.0(rollup@4.0.0-24)
sirv:
specifier: ^2.0.3
version: 2.0.3(patch_hash=z45f224eewh2pgpijxcc3aboqm)
@@ -3551,7 +3551,7 @@ packages:
slash: 4.0.0
dev: true
- /@rollup/plugin-alias@5.0.0(rollup@4.0.0-23):
+ /@rollup/plugin-alias@5.0.0(rollup@4.0.0-24):
resolution: {integrity: sha512-l9hY5chSCjuFRPsnRm16twWBiSApl2uYFLsepQYwtBuAxNMQ/1dJqADld40P0Jkqm65GRTLy/AC6hnpVebtLsA==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -3560,7 +3560,7 @@ packages:
rollup:
optional: true
dependencies:
- rollup: 4.0.0-23
+ rollup: 4.0.0-24
slash: 4.0.0
dev: true
@@ -3582,7 +3582,7 @@ packages:
rollup: 3.29.2
dev: true
- /@rollup/plugin-commonjs@25.0.4(rollup@4.0.0-23):
+ /@rollup/plugin-commonjs@25.0.4(rollup@4.0.0-24):
resolution: {integrity: sha512-L92Vz9WUZXDnlQQl3EwbypJR4+DM2EbsO+/KOcEkP4Mc6Ct453EeDB2uH9lgRwj4w5yflgNpq9pHOiY8aoUXBQ==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -3591,16 +3591,16 @@ packages:
rollup:
optional: true
dependencies:
- '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-24)
commondir: 1.0.1
estree-walker: 2.0.2
glob: 8.1.0
is-reference: 1.2.1
magic-string: 0.27.0
- rollup: 4.0.0-23
+ rollup: 4.0.0-24
dev: true
- /@rollup/plugin-dynamic-import-vars@2.0.5(rollup@4.0.0-23):
+ /@rollup/plugin-dynamic-import-vars@2.0.5(rollup@4.0.0-24):
resolution: {integrity: sha512-YNKbZ5Y08DwWHbcqcn5BOxf/X9lVV2fYiL0247k76rL/XNx6xQX0Tti6cCoA2jXhBQdBcDjsFTFoT3nl4QJmWg==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -3609,12 +3609,12 @@ packages:
rollup:
optional: true
dependencies:
- '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-24)
astring: 1.8.6
estree-walker: 2.0.2
fast-glob: 3.3.1
magic-string: 0.27.0
- rollup: 4.0.0-23
+ rollup: 4.0.0-24
dev: true
/@rollup/plugin-json@6.0.0(rollup@3.29.2):
@@ -3630,7 +3630,7 @@ packages:
rollup: 3.29.2
dev: true
- /@rollup/plugin-json@6.0.0(rollup@4.0.0-23):
+ /@rollup/plugin-json@6.0.0(rollup@4.0.0-24):
resolution: {integrity: sha512-i/4C5Jrdr1XUarRhVu27EEwjt4GObltD7c+MkCIpO2QIbojw8MUs+CCTqOphQi3Qtg1FLmYt+l+6YeoIf51J7w==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -3639,8 +3639,8 @@ packages:
rollup:
optional: true
dependencies:
- '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
- rollup: 4.0.0-23
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-24)
+ rollup: 4.0.0-24
dev: true
/@rollup/plugin-node-resolve@15.2.1(rollup@3.29.2):
@@ -3661,7 +3661,7 @@ packages:
rollup: 3.29.2
dev: true
- /@rollup/plugin-node-resolve@15.2.1(rollup@4.0.0-23):
+ /@rollup/plugin-node-resolve@15.2.1(rollup@4.0.0-24):
resolution: {integrity: sha512-nsbUg588+GDSu8/NS8T4UAshO6xeaOfINNuXeVHcKV02LJtoRaM1SiOacClw4kws1SFiNhdLGxlbMY9ga/zs/w==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -3670,13 +3670,13 @@ packages:
rollup:
optional: true
dependencies:
- '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-24)
'@types/resolve': 1.20.2
deepmerge: 4.2.2
is-builtin-module: 3.2.1
is-module: 1.0.0
resolve: 1.22.4
- rollup: 4.0.0-23
+ rollup: 4.0.0-24
dev: true
/@rollup/plugin-replace@5.0.2(rollup@3.29.2):
@@ -3693,7 +3693,7 @@ packages:
rollup: 3.29.2
dev: true
- /@rollup/plugin-typescript@11.1.3(rollup@4.0.0-23)(tslib@2.6.2)(typescript@5.2.2):
+ /@rollup/plugin-typescript@11.1.3(rollup@4.0.0-24)(tslib@2.6.2)(typescript@5.2.2):
resolution: {integrity: sha512-8o6cNgN44kQBcpsUJTbTXMTtb87oR1O0zgP3Dxm71hrNgparap3VujgofEilTYJo+ivf2ke6uy3/E5QEaiRlDA==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -3706,9 +3706,9 @@ packages:
tslib:
optional: true
dependencies:
- '@rollup/pluginutils': 5.0.4(rollup@4.0.0-23)
+ '@rollup/pluginutils': 5.0.4(rollup@4.0.0-24)
resolve: 1.22.4
- rollup: 4.0.0-23
+ rollup: 4.0.0-24
tslib: 2.6.2
typescript: 5.2.2
dev: true
@@ -3728,7 +3728,7 @@ packages:
rollup: 3.29.2
dev: true
- /@rollup/pluginutils@5.0.4(rollup@4.0.0-23):
+ /@rollup/pluginutils@5.0.4(rollup@4.0.0-24):
resolution: {integrity: sha512-0KJnIoRI8A+a1dqOYLxH8vBf8bphDmty5QvIm2hqm7oFCFYKCAZWWd2hXgMibaPsNDhI0AtpYfQZJG47pt/k4g==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -3740,81 +3740,81 @@ packages:
'@types/estree': 1.0.1
estree-walker: 2.0.2
picomatch: 2.3.1
- rollup: 4.0.0-23
+ rollup: 4.0.0-24
dev: true
- /@rollup/rollup-android-arm-eabi@4.0.0-23:
- resolution: {integrity: sha512-bFVjyz+f4ICADXH6NmEthwLa6LeP0oHSlh5UGDZnGptPzAjMH/gQ3Bo1kFzG0p9xUNW22/uwHb9gnrLGQjgSBA==}
+ /@rollup/rollup-android-arm-eabi@4.0.0-24:
+ resolution: {integrity: sha512-19cF3V1fHfzPzwu0cgZEdWLMdNkqSmKOhidqQv1CkUqAMcb7etA7WLx8YrX5ob31ruI0BYYrUDBunlIuMHHUrg==}
cpu: [arm]
os: [android]
requiresBuild: true
optional: true
- /@rollup/rollup-android-arm64@4.0.0-23:
- resolution: {integrity: sha512-iyygT9P3wLXqVnKFE7OpteL32ijdZOnDbJhQ4vsOMfyZyE7ce0fEDMM/VsLirUMHqCH8sQO6lxFq/qBkj3sPLQ==}
+ /@rollup/rollup-android-arm64@4.0.0-24:
+ resolution: {integrity: sha512-ftTp5ByyyozDsHfmYGeErrQmBi4ZEVZItC4Siilwretkf+cMv9z0s0Ru8ncd28OZpaO0cr9b7Afm+DIRDyE8Kw==}
cpu: [arm64]
os: [android]
requiresBuild: true
optional: true
- /@rollup/rollup-darwin-arm64@4.0.0-23:
- resolution: {integrity: sha512-2Vnxl0XiBxgyk8BDgkZF/AkP17bB8YpfUg73MjLVHzv4Kls9MHUAQLaanDZzqrsyXZpJb0f2+2oALoDK9+lRuA==}
+ /@rollup/rollup-darwin-arm64@4.0.0-24:
+ resolution: {integrity: sha512-wYXWdPbMLiIRHQeTF/r9ZoDcf3k1ROR0Kyd/caUtbs5VEZOBfnpZ/FHQPzXW0S1fzxTtD5W4tXULxARMHAlNdQ==}
cpu: [arm64]
os: [darwin]
requiresBuild: true
optional: true
- /@rollup/rollup-darwin-x64@4.0.0-23:
- resolution: {integrity: sha512-xyZ1WHFgp3xttutYFnk5AMqEGK42uSW6elI11tGi6x3OcQG8WkE6Vq2GQnFNoA8dv0QlZZjldFMBYEQ/ksvBPw==}
+ /@rollup/rollup-darwin-x64@4.0.0-24:
+ resolution: {integrity: sha512-8tIz6Uga/5XdeRkid7kfNtxrvru7o4lDBxAPooZezKXbyB2ap2yKAKCqTFEXyTuPhl2yxLMa5zqZ91FBEnSbPg==}
cpu: [x64]
os: [darwin]
requiresBuild: true
optional: true
- /@rollup/rollup-linux-arm-gnueabihf@4.0.0-23:
- resolution: {integrity: sha512-+eCcJMaejbxvKSBTGMAlYVRk/qYnKENJUvrDVSQGALZPuqALWgI7kdI/MJkfV4aUTyvf5ejb5lkX6/wPoMp38w==}
+ /@rollup/rollup-linux-arm-gnueabihf@4.0.0-24:
+ resolution: {integrity: sha512-ZCNBOaw2NV3BnpQ049VCPJSamss3wAoCunFcWYfhWgGyu9C0hiRvZAcKvhd7e/9EhuoIxsNxMLwI46NmZx9WBQ==}
cpu: [arm]
os: [linux]
requiresBuild: true
optional: true
- /@rollup/rollup-linux-arm64-gnu@4.0.0-23:
- resolution: {integrity: sha512-R4ffdK1hkjqqh8RSYOi06tztZPnbExh8ppNL1m5HgwaQhrmcUd3wgBJScaZXmetHUrunWfShxtbQCdZoTp8A2A==}
+ /@rollup/rollup-linux-arm64-gnu@4.0.0-24:
+ resolution: {integrity: sha512-BGnRktAZq4RI6FSicI+F6ws9paiYmjyaXUNKSukLthzgzPC91V4SXVylbFOCKvrhdWAr0lvZgcTrkgYNAmAcuQ==}
cpu: [arm64]
os: [linux]
requiresBuild: true
optional: true
- /@rollup/rollup-linux-x64-gnu@4.0.0-23:
- resolution: {integrity: sha512-ZB7Sl94bhM4sg5ZVOWKg0MfakJ6W4kDTZNUufteK83eTVHDMtGqCDTxBfMOAT3lDgkK+H6b1txaKgSht72Ss8A==}
+ /@rollup/rollup-linux-x64-gnu@4.0.0-24:
+ resolution: {integrity: sha512-FzhHpp+vRTjIUYXMExj9Ffj2bCQgnRAzlWlsQTdYGYvPQMVadfPMvnlcr4Li8P7Yv1iBFtDzRVfZAgL5glvIAA==}
cpu: [x64]
os: [linux]
requiresBuild: true
optional: true
- /@rollup/rollup-linux-x64-musl@4.0.0-23:
- resolution: {integrity: sha512-LKpQT5+PsXrOUyeuVVvPC1PC0lhSNeBYPF6Q9FgjYosxE+cdFSisU+rCxkRJwYX8fXmcK8/vuMkqPpUP6xCuog==}
+ /@rollup/rollup-linux-x64-musl@4.0.0-24:
+ resolution: {integrity: sha512-0y+oXnCCT5+U5V58bY7dy65yDrWWfopFJwtC2EbFeA9SHrVjG36/TQo535ML3zdFwO+fma8r5FP1os0psbQBXQ==}
cpu: [x64]
os: [linux]
requiresBuild: true
optional: true
- /@rollup/rollup-win32-arm64-msvc@4.0.0-23:
- resolution: {integrity: sha512-pEWZzHhioEt8HrM5PV7YiDbPmrZ8ceWtmoL/7xhvOgQ4xD3SCr5kych1gv1YKuWxLNKVl2S3SanARSvPQVcdog==}
+ /@rollup/rollup-win32-arm64-msvc@4.0.0-24:
+ resolution: {integrity: sha512-xT8djNMxVB84cCm1XILpQXkMcu8S+GBKjurXM4sc6eB1FQpFpcTAOsuQSg9xOhfPqm1xa7qqXA6ZpUhoUMboVQ==}
cpu: [arm64]
os: [win32]
requiresBuild: true
optional: true
- /@rollup/rollup-win32-ia32-msvc@4.0.0-23:
- resolution: {integrity: sha512-oPbbAitsulZ1czKOp7KTOdOVgMw9rFt1AC5+vKXCwEp+7rBFDuehX7dWEGyogsgMevW8oMfrQHBjxIj9tdKIkg==}
+ /@rollup/rollup-win32-ia32-msvc@4.0.0-24:
+ resolution: {integrity: sha512-3gXFBlG5f18xbhVxKTM+zwciJPk097i3YswLI9cajVd4MAqMw5bGbuZkGOZOMnkzeIX0ELxovYWPbGDyUr+f5g==}
cpu: [ia32]
os: [win32]
requiresBuild: true
optional: true
- /@rollup/rollup-win32-x64-msvc@4.0.0-23:
- resolution: {integrity: sha512-O4vk4bBXS5Hnla8Mmx1rP+X1SerP0Obl4HqgeluKqon1b8l6kHvS4sXSQuSMw7+VH4NFOEqfV7ES6cObwhSjSA==}
+ /@rollup/rollup-win32-x64-msvc@4.0.0-24:
+ resolution: {integrity: sha512-41+QkzRaKEZwmA14Fa2DI0QKN5hkcN/orA2KOg5vJAtvwSfB1uQTUmf6T4SGZLw/8In2TEmViB9tDVlbnXmH1A==}
cpu: [x64]
os: [win32]
requiresBuild: true
@@ -8858,7 +8858,7 @@ packages:
'@babel/code-frame': 7.22.13
dev: true
- /rollup-plugin-license@3.1.0(rollup@4.0.0-23):
+ /rollup-plugin-license@3.1.0(rollup@4.0.0-24):
resolution: {integrity: sha512-Cny2H2hJ7K+VdcJkH1pNcYRVhqIhZNu/fPusedW53fNZQOIwpXiznJ220EFvDkJbFUEkLqIDsDB5bEr/N9qfqw==}
engines: {node: '>=14.0.0'}
peerDependencies:
@@ -8871,7 +8871,7 @@ packages:
mkdirp: 3.0.1
moment: 2.29.3
package-name-regex: 2.0.6
- rollup: 4.0.0-23
+ rollup: 4.0.0-24
spdx-expression-validate: 2.0.0
spdx-satisfies: 5.0.1
dev: true
@@ -8884,22 +8884,22 @@ packages:
fsevents: 2.3.3
dev: true
- /rollup@4.0.0-23:
- resolution: {integrity: sha512-a5YMr7oRSMsslt101mwitUo1RR2IcS/3tnWB4GZ4zMSg4NskKu6b7HEe6uZdsTGz2JUWL0ahBpdJ/WOz0lyJ1Q==}
+ /rollup@4.0.0-24:
+ resolution: {integrity: sha512-Tcdk9cYyF5abnUQP68AWuSHahowglrzQH6olnHB4Lxi7VBuflwrlpavK7d046Ep2WmwDN0ey5sr+QzLShQ7Odw==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
hasBin: true
optionalDependencies:
- '@rollup/rollup-android-arm-eabi': 4.0.0-23
- '@rollup/rollup-android-arm64': 4.0.0-23
- '@rollup/rollup-darwin-arm64': 4.0.0-23
- '@rollup/rollup-darwin-x64': 4.0.0-23
- '@rollup/rollup-linux-arm-gnueabihf': 4.0.0-23
- '@rollup/rollup-linux-arm64-gnu': 4.0.0-23
- '@rollup/rollup-linux-x64-gnu': 4.0.0-23
- '@rollup/rollup-linux-x64-musl': 4.0.0-23
- '@rollup/rollup-win32-arm64-msvc': 4.0.0-23
- '@rollup/rollup-win32-ia32-msvc': 4.0.0-23
- '@rollup/rollup-win32-x64-msvc': 4.0.0-23
+ '@rollup/rollup-android-arm-eabi': 4.0.0-24
+ '@rollup/rollup-android-arm64': 4.0.0-24
+ '@rollup/rollup-darwin-arm64': 4.0.0-24
+ '@rollup/rollup-darwin-x64': 4.0.0-24
+ '@rollup/rollup-linux-arm-gnueabihf': 4.0.0-24
+ '@rollup/rollup-linux-arm64-gnu': 4.0.0-24
+ '@rollup/rollup-linux-x64-gnu': 4.0.0-24
+ '@rollup/rollup-linux-x64-musl': 4.0.0-24
+ '@rollup/rollup-win32-arm64-msvc': 4.0.0-24
+ '@rollup/rollup-win32-ia32-msvc': 4.0.0-24
+ '@rollup/rollup-win32-x64-msvc': 4.0.0-24
fsevents: 2.3.3
/run-parallel@1.2.0:
From 6b0074590925ebf4270e52565935a6263d37003c Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Tue, 3 Oct 2023 18:24:21 +0900
Subject: [PATCH 13/34] wip: revert "wip: remove utf8 BOM for now"
This reverts commit 4d4929278c45dd71c19e66a87c06f01508202efa.
---
playground/resolve/utf8-bom/main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/playground/resolve/utf8-bom/main.js b/playground/resolve/utf8-bom/main.js
index dbb4932fd56b91..6273e5ac04e016 100644
--- a/playground/resolve/utf8-bom/main.js
+++ b/playground/resolve/utf8-bom/main.js
@@ -1,3 +1,3 @@
-import '@babel/runtime/helpers/esm/slicedToArray'
+import '@babel/runtime/helpers/esm/slicedToArray'
export const msg = '[success]'
From 632d3b03fc4f21c3780cdf2e1b07cd02401f9415 Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Tue, 3 Oct 2023 19:04:46 +0900
Subject: [PATCH 14/34] wip: new hash algorithm
---
packages/vite/src/node/plugins/asset.ts | 9 +++++----
playground/assets/__tests__/assets.spec.ts | 8 ++++----
.../relative-base/relative-base-assets.spec.ts | 10 +++++-----
.../runtime-base/runtime-base-assets.spec.ts | 12 ++++++------
.../__tests__/url-base/url-base-assets.spec.ts | 12 +++++++-----
.../__tests__/backend-integration.spec.ts | 2 +-
playground/legacy/__tests__/legacy.spec.ts | 2 +-
playground/lib/__tests__/lib.spec.ts | 2 +-
.../preload-disabled/preload-disabled.spec.ts | 2 +-
playground/preload/__tests__/preload.spec.ts | 4 ++--
.../resolve-deps/preload-resolve-deps.spec.ts | 4 ++--
11 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts
index 9a91234f9378f6..36da08afb679ca 100644
--- a/packages/vite/src/node/plugins/asset.ts
+++ b/packages/vite/src/node/plugins/asset.ts
@@ -27,7 +27,8 @@ import {
} from '../utils'
import { FS_PREFIX } from '../constants'
-export const assetUrlRE = /__VITE_ASSET__([a-z\d]+)__(?:\$_(.*?)__)?/g
+// referenceId is base64url but replaces - with $
+export const assetUrlRE = /__VITE_ASSET__([\w$]+)__(?:\$_(.*?)__)?/g
const rawRE = /(?:\?|&)raw(?:&|$)/
export const urlRE = /(\?|&)url(?:&|$)/
@@ -78,10 +79,10 @@ export function renderAssetUrlInJS(
let s: MagicString | undefined
// Urls added with JS using e.g.
- // imgElement.src = "__VITE_ASSET__5aa0ddc0__" are using quotes
+ // imgElement.src = "__VITE_ASSET__5aA0Ddc0__" are using quotes
// Urls added in CSS that is imported in JS end up like
- // var inlined = ".inlined{color:green;background:url(__VITE_ASSET__5aa0ddc0__)}\n";
+ // var inlined = ".inlined{color:green;background:url(__VITE_ASSET__5aA0Ddc0__)}\n";
// In both cases, the wrapping should already be fine
@@ -107,7 +108,7 @@ export function renderAssetUrlInJS(
s.update(match.index, match.index + full.length, replacementString)
}
- // Replace __VITE_PUBLIC_ASSET__5aa0ddc0__ with absolute paths
+ // Replace __VITE_PUBLIC_ASSET__5aA0Ddc0__ with absolute paths
const publicAssetUrlMap = publicAssetUrlCache.get(config)!
publicAssetUrlRE.lastIndex = 0
diff --git a/playground/assets/__tests__/assets.spec.ts b/playground/assets/__tests__/assets.spec.ts
index 43a93a19276440..ad1b7d3ac61c47 100644
--- a/playground/assets/__tests__/assets.spec.ts
+++ b/playground/assets/__tests__/assets.spec.ts
@@ -19,7 +19,7 @@ import {
} from '~utils'
const assetMatch = isBuild
- ? /\/foo\/assets\/asset-\w{8}\.png/
+ ? /\/foo\/assets\/asset-[-\w]{8}\.png/
: '/foo/nested/asset.png'
const iconMatch = `/foo/icon.png`
@@ -245,7 +245,7 @@ describe('image', () => {
srcset.split(', ').forEach((s) => {
expect(s).toMatch(
isBuild
- ? /\/foo\/assets\/asset-\w{8}\.png \dx/
+ ? /\/foo\/assets\/asset-[-\w]{8}\.png \dx/
: /\/foo\/nested\/asset.png \dx/,
)
})
@@ -366,7 +366,7 @@ test('new URL(`./${dynamic}?abc`, import.meta.url)', async () => {
)
expect(await page.textContent('.dynamic-import-meta-url-2-query')).toMatch(
isBuild
- ? /\/foo\/assets\/asset-\w{8}\.png\?abc/
+ ? /\/foo\/assets\/asset-[-\w]{8}\.png\?abc/
: '/foo/nested/asset.png?abc',
)
})
@@ -377,7 +377,7 @@ test('new URL(`./${1 === 0 ? static : dynamic}?abc`, import.meta.url)', async ()
)
expect(await page.textContent('.dynamic-import-meta-url-2-ternary')).toMatch(
isBuild
- ? /\/foo\/assets\/asset-\w{8}\.png\?abc/
+ ? /\/foo\/assets\/asset-[-\w]{8}\.png\?abc/
: '/foo/nested/asset.png?abc',
)
})
diff --git a/playground/assets/__tests__/relative-base/relative-base-assets.spec.ts b/playground/assets/__tests__/relative-base/relative-base-assets.spec.ts
index 7f1df03bfcf42e..9dd112be5ab070 100644
--- a/playground/assets/__tests__/relative-base/relative-base-assets.spec.ts
+++ b/playground/assets/__tests__/relative-base/relative-base-assets.spec.ts
@@ -12,7 +12,7 @@ import {
const getBase = () => (viteConfig ? viteConfig?.testConfig?.baseRoute : '')
const absoluteAssetMatch = isBuild
- ? /http.*\/other-assets\/asset-\w{8}\.png/
+ ? /http.*\/other-assets\/asset-[-\w]{8}\.png/
: '/nested/asset.png'
// Asset URLs in CSS are relative to the same dir, the computed
@@ -22,7 +22,7 @@ const cssBgAssetMatch = absoluteAssetMatch
const iconMatch = `/icon.png`
const absoluteIconMatch = isBuild
- ? /http.*\/icon-\w{8}\.png/
+ ? /http.*\/icon-[-\w]{8}\.png/
: '/nested/icon.png'
const absolutePublicIconMatch = isBuild ? /http.*\/icon\.png/ : '/icon.png'
@@ -160,7 +160,7 @@ describe('image', () => {
srcset.split(', ').forEach((s) => {
expect(s).toMatch(
isBuild
- ? /other-assets\/asset-\w{8}\.png \dx/
+ ? /other-assets\/asset-[-\w]{8}\.png \dx/
: /\.\/nested\/asset\.png \dx/,
)
})
@@ -193,14 +193,14 @@ test('?raw import', async () => {
test('?url import', async () => {
expect(await page.textContent('.url')).toMatch(
- isBuild ? /http.*\/other-assets\/foo-\w{8}\.js/ : `/foo.js`,
+ isBuild ? /http.*\/other-assets\/foo-[-\w]{8}\.js/ : `/foo.js`,
)
})
test('?url import on css', async () => {
const txt = await page.textContent('.url-css')
expect(txt).toMatch(
- isBuild ? /http.*\/other-assets\/icons-\w{8}\.css/ : '/css/icons.css',
+ isBuild ? /http.*\/other-assets\/icons-[-\w]{8}\.css/ : '/css/icons.css',
)
isBuild &&
expect(findAssetFile(/index.*\.js$/, getBase(), 'entries')).toMatch(
diff --git a/playground/assets/__tests__/runtime-base/runtime-base-assets.spec.ts b/playground/assets/__tests__/runtime-base/runtime-base-assets.spec.ts
index 12412d00ef4204..b77a8bf6729678 100644
--- a/playground/assets/__tests__/runtime-base/runtime-base-assets.spec.ts
+++ b/playground/assets/__tests__/runtime-base/runtime-base-assets.spec.ts
@@ -9,7 +9,7 @@ import {
} from '~utils'
const absoluteAssetMatch = isBuild
- ? /\/other-assets\/asset-\w{8}\.png/
+ ? /\/other-assets\/asset-[-\w]{8}\.png/
: '/nested/asset.png'
// Asset URLs in CSS are relative to the same dir, the computed
@@ -19,7 +19,7 @@ const cssBgAssetMatch = absoluteAssetMatch
const iconMatch = `/icon.png`
const absoluteIconMatch = isBuild
- ? /\/other-assets\/icon-\w{8}\.png/
+ ? /\/other-assets\/icon-[-\w]{8}\.png/
: '/nested/icon.png'
const absolutePublicIconMatch = isBuild ? /\/icon\.png/ : '/icon.png'
@@ -137,7 +137,7 @@ describe('css url() references', () => {
describe.runIf(isBuild)('index.css URLs', () => {
let css: string
beforeAll(() => {
- css = findAssetFile(/index-\w{8}\.css$/, '', 'other-assets')
+ css = findAssetFile(/index-[-\w]{8}\.css$/, '', 'other-assets')
})
test('relative asset URL', () => {
@@ -156,7 +156,7 @@ describe('image', () => {
srcset.split(', ').forEach((s) => {
expect(s).toMatch(
isBuild
- ? /other-assets\/asset-\w{8}\.png \dx/
+ ? /other-assets\/asset-[-\w]{8}\.png \dx/
: /\.\/nested\/asset\.png \dx/,
)
})
@@ -189,14 +189,14 @@ test('?raw import', async () => {
test('?url import', async () => {
expect(await page.textContent('.url')).toMatch(
- isBuild ? /\/other-assets\/foo-\w{8}\.js/ : `/foo.js`,
+ isBuild ? /\/other-assets\/foo-[-\w]{8}\.js/ : `/foo.js`,
)
})
test('?url import on css', async () => {
const txt = await page.textContent('.url-css')
expect(txt).toMatch(
- isBuild ? /\/other-assets\/icons-\w{8}\.css/ : '/css/icons.css',
+ isBuild ? /\/other-assets\/icons-[-\w]{8}\.css/ : '/css/icons.css',
)
})
diff --git a/playground/assets/__tests__/url-base/url-base-assets.spec.ts b/playground/assets/__tests__/url-base/url-base-assets.spec.ts
index bc781a297157a6..214fc46be53a72 100644
--- a/playground/assets/__tests__/url-base/url-base-assets.spec.ts
+++ b/playground/assets/__tests__/url-base/url-base-assets.spec.ts
@@ -10,13 +10,13 @@ import {
} from '~utils'
const urlAssetMatch = isBuild
- ? /http:\/\/localhost:\d+\/other-assets\/asset-\w{8}\.png/
+ ? /http:\/\/localhost:\d+\/other-assets\/asset-[-\w]{8}\.png/
: '/nested/asset.png'
const iconMatch = '/icon.png'
const absoluteIconMatch = isBuild
- ? /http:\/\/localhost:\d+\/.*\/icon-\w{8}\.png/
+ ? /http:\/\/localhost:\d+\/.*\/icon-[-\w]{8}\.png/
: '/nested/icon.png'
const absolutePublicIconMatch = isBuild
@@ -152,7 +152,7 @@ describe('image', () => {
srcset.split(', ').forEach((s) => {
expect(s).toMatch(
isBuild
- ? /other-assets\/asset-\w{8}\.png \dx/
+ ? /other-assets\/asset-[-\w]{8}\.png \dx/
: /\.\/nested\/asset\.png \dx/,
)
})
@@ -185,7 +185,9 @@ test('?raw import', async () => {
test('?url import', async () => {
expect(await page.textContent('.url')).toMatch(
- isBuild ? /http:\/\/localhost:\d+\/other-assets\/foo-\w{8}\.js/ : '/foo.js',
+ isBuild
+ ? /http:\/\/localhost:\d+\/other-assets\/foo-[-\w]{8}\.js/
+ : '/foo.js',
)
})
@@ -193,7 +195,7 @@ test('?url import on css', async () => {
const txt = await page.textContent('.url-css')
expect(txt).toMatch(
isBuild
- ? /http:\/\/localhost:\d+\/other-assets\/icons-\w{8}\.css/
+ ? /http:\/\/localhost:\d+\/other-assets\/icons-[-\w]{8}\.css/
: '/css/icons.css',
)
})
diff --git a/playground/backend-integration/__tests__/backend-integration.spec.ts b/playground/backend-integration/__tests__/backend-integration.spec.ts
index 442ed159219af9..7356d8eff15c8c 100644
--- a/playground/backend-integration/__tests__/backend-integration.spec.ts
+++ b/playground/backend-integration/__tests__/backend-integration.spec.ts
@@ -13,7 +13,7 @@ import {
} from '~utils'
const outerAssetMatch = isBuild
- ? /\/dev\/assets\/logo-\w{8}\.png/
+ ? /\/dev\/assets\/logo-[-\w]{8}\.png/
: /\/dev\/@fs\/.+?\/images\/logo\.png/
test('should have no 404s', () => {
diff --git a/playground/legacy/__tests__/legacy.spec.ts b/playground/legacy/__tests__/legacy.spec.ts
index 59cdc5a3999504..3a78204dd5c57f 100644
--- a/playground/legacy/__tests__/legacy.spec.ts
+++ b/playground/legacy/__tests__/legacy.spec.ts
@@ -127,7 +127,7 @@ describe.runIf(isBuild)('build', () => {
test('includes structuredClone polyfill which is supported after core-js v3', () => {
expect(findAssetFile(/polyfills-legacy/)).toMatch('"structuredClone"')
- expect(findAssetFile(/polyfills-\w{8}\./)).toMatch('"structuredClone"')
+ expect(findAssetFile(/polyfills-[-\w]{8}\./)).toMatch('"structuredClone"')
})
test('should generate legacy sourcemap file', async () => {
diff --git a/playground/lib/__tests__/lib.spec.ts b/playground/lib/__tests__/lib.spec.ts
index 682fd5aeba6c85..684b336991bbbb 100644
--- a/playground/lib/__tests__/lib.spec.ts
+++ b/playground/lib/__tests__/lib.spec.ts
@@ -57,7 +57,7 @@ describe.runIf(isBuild)('build', () => {
expect(code).not.toMatch('__vitePreload')
// Test that library chunks are hashed
- expect(code).toMatch(/await import\("\.\/message-[a-z\d]{8}.js"\)/)
+ expect(code).toMatch(/await import\("\.\/message-[-\w]{8}.js"\)/)
})
test('@import hoist', async () => {
diff --git a/playground/preload/__tests__/preload-disabled/preload-disabled.spec.ts b/playground/preload/__tests__/preload-disabled/preload-disabled.spec.ts
index 1ef462ca7c238b..ea1fc220795043 100644
--- a/playground/preload/__tests__/preload-disabled/preload-disabled.spec.ts
+++ b/playground/preload/__tests__/preload-disabled/preload-disabled.spec.ts
@@ -21,7 +21,7 @@ describe.runIf(isBuild)('build', () => {
expect(html).not.toMatch(/link rel="modulepreload"/)
expect(html).toMatch(
- /link rel="stylesheet".*?href=".*?\/assets\/hello-\w{8}\.css"/,
+ /link rel="stylesheet".*?href=".*?\/assets\/hello-[-\w]{8}\.css"/,
)
})
})
diff --git a/playground/preload/__tests__/preload.spec.ts b/playground/preload/__tests__/preload.spec.ts
index fd89d58a80b1a9..4c055d01e770e0 100644
--- a/playground/preload/__tests__/preload.spec.ts
+++ b/playground/preload/__tests__/preload.spec.ts
@@ -19,10 +19,10 @@ describe.runIf(isBuild)('build', () => {
const html = await page.content()
expect(html).toMatch(
- /link rel="modulepreload".*?href=".*?\/assets\/hello-\w{8}\.js"/,
+ /link rel="modulepreload".*?href=".*?\/assets\/hello-[-\w]{8}\.js"/,
)
expect(html).toMatch(
- /link rel="stylesheet".*?href=".*?\/assets\/hello-\w{8}\.css"/,
+ /link rel="stylesheet".*?href=".*?\/assets\/hello-[-\w]{8}\.css"/,
)
})
})
diff --git a/playground/preload/__tests__/resolve-deps/preload-resolve-deps.spec.ts b/playground/preload/__tests__/resolve-deps/preload-resolve-deps.spec.ts
index c255919c4cf598..02f20ef837e242 100644
--- a/playground/preload/__tests__/resolve-deps/preload-resolve-deps.spec.ts
+++ b/playground/preload/__tests__/resolve-deps/preload-resolve-deps.spec.ts
@@ -19,11 +19,11 @@ describe.runIf(isBuild)('build', () => {
const html = await page.content()
expect(html).toMatch(
- /link rel="modulepreload".*?href="http.*?\/hello-\w{8}\.js"/,
+ /link rel="modulepreload".*?href="http.*?\/hello-[-\w]{8}\.js"/,
)
expect(html).toMatch(/link rel="modulepreload".*?href="\/preloaded.js"/)
expect(html).toMatch(
- /link rel="stylesheet".*?href="http.*?\/hello-\w{8}\.css"/,
+ /link rel="stylesheet".*?href="http.*?\/hello-[-\w]{8}\.css"/,
)
})
})
From a3c750fe5317dabd2368140b9764a1d14f3e56e8 Mon Sep 17 00:00:00 2001
From: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
Date: Tue, 3 Oct 2023 19:19:16 +0900
Subject: [PATCH 15/34] wip: new hash algorithm
---
playground/assets/__tests__/assets.spec.ts | 4 +-
.../__tests__/lightningcss.spec.ts | 2 +-
playground/css/__tests__/css.spec.ts | 14 +++----
.../no-css-minify/no-css-minify.spec.ts | 4 +-
.../glob-import/__tests__/glob-import.spec.ts | 2 +-
playground/legacy/__tests__/legacy.spec.ts | 2 +-
.../__tests__/ssr-webworker.spec.ts | 2 +-
.../sourcemap-hidden-worker.spec.ts | 26 +++++++------
.../sourcemap-inline-worker.spec.ts | 12 +++---
.../sourcemap/sourcemap-worker.spec.ts | 38 ++++++++++---------
10 files changed, 58 insertions(+), 48 deletions(-)
diff --git a/playground/assets/__tests__/assets.spec.ts b/playground/assets/__tests__/assets.spec.ts
index ad1b7d3ac61c47..976c53f4ce0e0c 100644
--- a/playground/assets/__tests__/assets.spec.ts
+++ b/playground/assets/__tests__/assets.spec.ts
@@ -405,7 +405,7 @@ describe.runIf(isBuild)('css and assets in css in build watch', () => {
test('css will not be lost and css does not contain undefined', async () => {
editFile('index.html', (code) => code.replace('Assets', 'assets'), true)
await notifyRebuildComplete(watcher)
- const cssFile = findAssetFile(/index-\w+\.css$/, 'foo')
+ const cssFile = findAssetFile(/index-[-\w]+\.css$/, 'foo')
expect(cssFile).not.toBe('')
expect(cssFile).not.toMatch(/undefined/)
})
@@ -472,6 +472,6 @@ test.skip('url() contains file in publicDir, as inline style', async () => {
test.runIf(isBuild)('assets inside