Skip to content

Commit

Permalink
feat(astro): add .astro files to default include (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin committed May 8, 2024
1 parent 128d050 commit 87baffc
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/vite-astro/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default defineConfig({
'svelte/store',
'react',
],
dirs: ['src/utils/*.ts'],
dts: './src/auto-imports.d.ts',
}),
],
Expand Down
1 change: 1 addition & 0 deletions examples/vite-astro/src/components/Card.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Props {
}
const { href, title, body } = Astro.props as Props;
console.log(one)
---

<li class="link-card">
Expand Down
1 change: 1 addition & 0 deletions examples/vite-astro/src/components/Card.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
onMount(() => {
console.log('Test unplugin-auto-import ')
console.log(one)
})
function add() {
Expand Down
3 changes: 0 additions & 3 deletions examples/vite-astro/src/components/Card.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<script setup lang='ts'>
const count = ref(0)
let number = $ref(0)
function add() {
count.value++
number++
}
</script>

<template>
<div>
<h1>Vue {{ count }}</h1>
<h1>Vue/maros {{ number }}</h1>
<button @click="add">
Add
</button>
Expand Down
2 changes: 2 additions & 0 deletions examples/vite-astro/src/utils/contants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const one = 1
export const two = 1
2 changes: 1 addition & 1 deletion src/core/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ${dts}`.trim()}\n`
})

const filter = createFilter(
options.include || [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/],
options.include || [/\.[jt]sx?$/, /\.astro$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/],
options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/],
)
const dts = preferDTS === false
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ export interface Options {
/**
* Rules to include transforming target.
*
* @default [/\.[jt]sx?$/, /\.vue\??/]
* @default [/\.[jt]sx?$/, /\.astro$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/]
*/
include?: FilterPattern

/**
* Rules to exclude transforming target.
*
* @default [/node_modules/, /\.git/]
* @default [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]
*/
exclude?: FilterPattern

Expand Down

0 comments on commit 87baffc

Please sign in to comment.