Skip to content

Commit 6b5a4bc

Browse files
committed
fix: correctly transform imports from Quasar (trailing comma issue)
1 parent 9f0361d commit 6b5a4bc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/loader.js.transform-quasar-imports.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ module.exports = function (content, map) {
88
regex,
99
(_, match) => match.split(',')
1010
.map(identifier => {
11-
const data = identifier.split(' as ')
11+
const id = identifier.trim()
1212

13-
if (data[1] !== void 0) {
14-
return `import ${data[1].trim()} from '${importTransformation(data[0].trim())}';`
13+
// might be an empty entry like below
14+
// (notice useQuasar is followed by a comma)
15+
// import { QTable, useQuasar, } from 'quasar'
16+
if (id === '') {
17+
return ''
1518
}
1619

20+
const data = id.split(' as ')
1721
const name = data[0].trim()
18-
return `import ${name} from '${importTransformation(name)}';`
22+
23+
return `import ${data[1] !== void 0 ? data[1].trim() : name} from '${importTransformation(name)}';`
1924
})
2025
.join('')
2126
)

0 commit comments

Comments
 (0)