File tree 2 files changed +7
-2
lines changed
packages/vite/src/node/plugins
playground/dynamic-import/nested 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ const preloadMarkerRE = new RegExp(preloadMarker, 'g')
42
42
const dynamicImportPrefixRE = / i m p o r t \s * \( /
43
43
44
44
const dynamicImportTreeshakenRE =
45
- / ( (?: \b c o n s t \s + | \b l e t \s + | \b v a r \s + | , \s * ) ( \{ [ ^ } . ] + \} ) \s * = \s * a w a i t \s + i m p o r t \( [ ^ ) ] + \) ) | ( \( \s * a w a i t \s + i m p o r t \( [ ^ ) ] + \) \s * \) ( \? ? \. [ \w $ ] + ) ) | \b i m p o r t \( [ ^ ) ] + \) ( \s * \. t h e n \( [ ^ { ] * ? \ (\s * \{ ( [ ^ } . ] + ) \} ) / g
45
+ / ( (?: \b c o n s t \s + | \b l e t \s + | \b v a r \s + | , \s * ) ( \{ [ ^ } . ] + \} ) \s * = \s * a w a i t \s + i m p o r t \( [ ^ ) ] + \) ) | ( \( \s * a w a i t \s + i m p o r t \( [ ^ ) ] + \) \s * \) ( \? ? \. [ \w $ ] + ) ) | \b i m p o r t \( [ ^ ) ] + \) ( \s * \. t h e n \( \s * (?: f u n c t i o n \s * ) ? \ (\s * \{ ( [ ^ } . ] + ) \} \) ) / g
46
46
47
47
function toRelativePath ( filename : string , importer : string ) {
48
48
const relPath = path . posix . relative ( path . posix . dirname ( importer ) , filename )
@@ -285,7 +285,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
285
285
286
286
/* handle `import('foo').then(({foo})=>{})`
287
287
*
288
- * match[5]: `.then(({foo}`
288
+ * match[5]: `.then(({foo}) `
289
289
* match[6]: `foo`
290
290
* import end: `import('foo').`
291
291
* ^
Original file line number Diff line number Diff line change @@ -171,10 +171,15 @@ import(`../nested/nested/${base}.js`).then((mod) => {
171
171
const default2 = ( await import ( './treeshaken/syntax.js' ) ) . default ,
172
172
other = ( ) => { }
173
173
const foo = await import ( './treeshaken/syntax.js' ) . then ( ( mod ) => mod . foo )
174
+ const foo2 = await import ( './treeshaken/syntax.js' ) . then (
175
+ ( { foo = { } } ) => foo ,
176
+ )
177
+ await import ( './treeshaken/syntax.js' ) . then ( ( mod ) => mod . foo ( { foo } ) )
174
178
default1 ( )
175
179
default2 ( )
176
180
other ( )
177
181
foo ( )
182
+ foo2 ( )
178
183
} ) ( )
179
184
180
185
import ( `../nested/static.js` ) . then ( ( mod ) => {
You can’t perform that action at this time.
0 commit comments