mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 22:59:10 +00:00
fix(build): skip preload treeshaking for nested braces (#17687)
This commit is contained in:
parent
b723a753ce
commit
4be96b48bc
@ -42,7 +42,7 @@ const preloadMarkerRE = new RegExp(preloadMarker, 'g')
|
||||
const dynamicImportPrefixRE = /import\s*\(/
|
||||
|
||||
const dynamicImportTreeshakenRE =
|
||||
/((?:\bconst\s+|\blet\s+|\bvar\s+|,\s*)(\{[^}.=]+\})\s*=\s*await\s+import\([^)]+\))|(\(\s*await\s+import\([^)]+\)\s*\)(\??\.[\w$]+))|\bimport\([^)]+\)(\s*\.then\(\s*(?:function\s*)?\(\s*\{([^}.=]+)\}\))/g
|
||||
/((?:\bconst\s+|\blet\s+|\bvar\s+|,\s*)(\{[^{}.=]+\})\s*=\s*await\s+import\([^)]+\))|(\(\s*await\s+import\([^)]+\)\s*\)(\??\.[\w$]+))|\bimport\([^)]+\)(\s*\.then\(\s*(?:function\s*)?\(\s*\{([^{}.=]+)\}\))/g
|
||||
|
||||
function toRelativePath(filename: string, importer: string) {
|
||||
const relPath = path.posix.relative(path.posix.dirname(importer), filename)
|
||||
|
@ -175,11 +175,21 @@ import(`../nested/nested/${base}.js`).then((mod) => {
|
||||
({ foo = {} }) => foo,
|
||||
)
|
||||
await import('./treeshaken/syntax.js').then((mod) => mod.foo({ foo }))
|
||||
const obj = [
|
||||
'',
|
||||
{
|
||||
async lazy() {
|
||||
const { foo } = await import('./treeshaken/treeshaken.js')
|
||||
return { foo: aaa(foo) }
|
||||
},
|
||||
},
|
||||
]
|
||||
default1()
|
||||
default2()
|
||||
other()
|
||||
foo()
|
||||
foo2()
|
||||
obj[1].lazy()
|
||||
})()
|
||||
|
||||
import(`../nested/static.js`).then((mod) => {
|
||||
|
Loading…
Reference in New Issue
Block a user