Skip to content

Commit 8fc1a9d

Browse files
authored
fix(vite-import): fix the issue of escaping comment code in on-demand packaging plugin (#2726)
1 parent 297d6b5 commit 8fc1a9d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internals/vue-vite-import/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ const transformDefaultImport = (matchRes: string, opt: PluginInnerOption) => {
154154
return `import ${matchRes} from '${importName}'`
155155
}
156156

157+
// 排除注释代码
157158
const getCompRegExp = (libraryName: any) =>
158-
new RegExp(`import\\s+?{*([\\w ,\\s]+)}*\\s+?from\\s+?('|")${libraryName}('|")`, 'g')
159+
new RegExp(`(?<!//\\s*)import\\s+?{*([\\w ,\\s]+)}*\\s+?from\\s+?('|")${libraryName}('|")`, 'g')
159160

160161
function transformCode(code: string, plgOptions: PluginInnerOptions): string {
161162
let resultCode = code

0 commit comments

Comments
 (0)