Skip to content

Commit

Permalink
chore: ensure vite comment makes dist output
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Jan 8, 2025
1 parent ccae05f commit 595c6a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion build.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readFile, writeFile } from 'node:fs/promises'
import { dts } from 'bun-plugin-dtsx'

console.log('Building...')
Expand All @@ -8,4 +9,17 @@ await Bun.build({
plugins: [dts()],
})

console.log('Built')
// Read the built file
const filePath = './dist/index.js'
const content = await readFile(filePath, 'utf8')

// add vite-ignore to dynamic import to suppress vite warning given we know
const updatedContent = content.replace(
/await import\(configPath\)/g,
'await import(/* @vite-ignore */configPath)',
)

// Write the modified content back to the file
await writeFile(filePath, updatedContent)

console.log('Built and updated dynamic imports')
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function loadConfig<T>({
const configPath = resolve(cwd || process.cwd(), `${name}.config`)

try {
const importedConfig = await import(/* @vite-ignore */configPath)
const importedConfig = await import(configPath)
const loadedConfig = importedConfig.default || importedConfig
return deepMerge(defaultConfig, loadedConfig) as T
}
Expand Down

0 comments on commit 595c6a4

Please sign in to comment.