Skip to content

Commit 108d801

Browse files
committed
fix: fix injectImports when there's no pre-existing import declarations
closes #2925
1 parent e8b2243 commit 108d801

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/@vue/cli/lib/util/injectImportsAndOptions.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ module.exports = function injectImportsAndOptions (source, imports, injections)
2525
}
2626
})
2727
// avoid blank line after the previous import
28-
delete ast.program.body[lastImportIndex].loc
28+
if (lastImportIndex !== -1) {
29+
delete ast.program.body[lastImportIndex].loc
30+
}
2931

3032
const nonDuplicates = i => {
3133
return !importDeclarations.some(node => {

0 commit comments

Comments
 (0)