diff --git a/build.ts b/build.ts index 2e20a64..738041a 100644 --- a/build.ts +++ b/build.ts @@ -1,3 +1,4 @@ +import { readFile, writeFile } from 'node:fs/promises' import { dts } from 'bun-plugin-dtsx' console.log('Building...') @@ -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') diff --git a/src/index.ts b/src/index.ts index 33861aa..6dd0882 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,7 +37,7 @@ export async function loadConfig({ 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 }