Skip to content

Commit

Permalink
fix: Throw when config file does not exist (#1156)
Browse files Browse the repository at this point in the history
Co-authored-by: kongmoumou <kongmoumou@users.noreply.github.com>
  • Loading branch information
kongmoumou and kongmoumou authored Nov 13, 2024
1 parent 199f330 commit aa14676
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Binary file modified docs/assets/init-demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions packages/wxt/e2e/tests/user-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,18 @@ describe('User Config', () => {
await project.fileExists('.output/test-chrome-mv3-development-dev-build'),
).toBe(true);
});

it('should throw error when config file not exist', async () => {
const project = new TestProject();
project.addFile(
'src/entrypoints/background.ts',
`export default defineBackground(
() => console.log('Hello background'),
);`,
);

await expect(
project.build({ configFile: 'foo.config.ts' }),
).rejects.toThrowError(/not found/);
});
});
3 changes: 3 additions & 0 deletions packages/wxt/src/core/resolve-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export async function resolveConfig(
esmResolve: true,
},
});
if (inlineConfig.configFile && metadata.layers?.length === 0) {
throw Error(`Config file "${inlineConfig.configFile}" not found`);
}
userConfig = loadedConfig ?? {};
userConfigMetadata = metadata;
}
Expand Down

0 comments on commit aa14676

Please # to comment.