Skip to content

Commit

Permalink
fix: incorrect process for removing pure import
Browse files Browse the repository at this point in the history
fix #301
  • Loading branch information
qmhc committed Feb 21, 2024
1 parent 17e4f52 commit d0c0c86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/transform.ts
Expand Up @@ -152,7 +152,7 @@ export function transformAliasImport(
})
}

const pureImportRE = /import\s?['"][^;\n]+?['"];?\n?/g
const pureImportRE = /^import\s?['"][^;\n]+?['"];?\n?/g

export function removePureImport(content: string) {
return content.replace(pureImportRE, '')
Expand Down
3 changes: 3 additions & 0 deletions tests/transform.spec.ts
Expand Up @@ -110,6 +110,9 @@ describe('transform tests', () => {
expect(
removePureImport('import "@/themes/common.scss";\nimport type { Ref } from "vue";')
).toEqual('import type { Ref } from "vue";')
expect(removePureImport("{ 'database-import': import('vue').FunctionalComponent }")).toEqual(
"{ 'database-import': import('vue').FunctionalComponent }"
)
})

it('test: hasExportDefault', () => {
Expand Down

0 comments on commit d0c0c86

Please sign in to comment.