Skip to content

Commit

Permalink
fix: rename import velite config to avoid naming conflicts (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
zce authored Oct 31, 2024
1 parent 1d67422 commit 146a4d8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/guide/using-collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export { default as others } from './others.json'
```

```js [index.d.ts]
import config from '../velite.config'
import type __vc from '../velite.config.js'

type Collections = typeof config.collections
type Collections = typeof __vc.collections

export type Post = Collections['posts']['schema']['_output']
export declare const posts: Post[]
Expand Down
4 changes: 2 additions & 2 deletions src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const outputEntry = async (dest: string, format: Output['format'], config
const configModPath = relative(dest, configPath).replace(/\\/g, '/')

const entry: string[] = []
const dts: string[] = [`import type config from '${configModPath}'\n`]
dts.push('type Collections = typeof config.collections\n')
const dts: string[] = [`import type __vc from '${configModPath}'\n`]
dts.push('type Collections = typeof __vc.collections\n')

Object.entries(collections).map(([name, collection]) => {
if (format === 'cjs') {
Expand Down
2 changes: 1 addition & 1 deletion test/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('standalone fixtures', async t => {
equal(entry.length, 288, 'entry output length should be 288')

const dts = await readFile('examples/basic/.velite/index.d.ts', 'utf8')
equal(dts.length, 636, 'dts output length should be 636')
equal(dts.length, 632, 'dts output length should be 632')

const options = await readFile('examples/basic/.velite/options.json', 'utf8')
equal(options.length, 1121, 'options output length should be 1121')
Expand Down
2 changes: 1 addition & 1 deletion test/nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('integration with nextjs fixtures', async t => {
equal(entry.length, 288, 'entry output length should be 288')

const dts = await readFile('examples/nextjs/.velite/index.d.ts', 'utf8')
equal(dts.length, 636, 'dts output length should be 636')
equal(dts.length, 632, 'dts output length should be 632')

const options = await readFile('examples/nextjs/.velite/options.json', 'utf8')
equal(options.length, 775, 'options output length should be 775')
Expand Down

0 comments on commit 146a4d8

Please sign in to comment.