Skip to content

Commit aa14676

Browse files
authored
fix: Throw when config file does not exist (#1156)
Co-authored-by: kongmoumou <[email protected]>
1 parent 199f330 commit aa14676

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

docs/assets/init-demo.gif

26.4 KB
Loading

packages/wxt/e2e/tests/user-config.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,18 @@ describe('User Config', () => {
157157
await project.fileExists('.output/test-chrome-mv3-development-dev-build'),
158158
).toBe(true);
159159
});
160+
161+
it('should throw error when config file not exist', async () => {
162+
const project = new TestProject();
163+
project.addFile(
164+
'src/entrypoints/background.ts',
165+
`export default defineBackground(
166+
() => console.log('Hello background'),
167+
);`,
168+
);
169+
170+
await expect(
171+
project.build({ configFile: 'foo.config.ts' }),
172+
).rejects.toThrowError(/not found/);
173+
});
160174
});

packages/wxt/src/core/resolve-config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export async function resolveConfig(
5353
esmResolve: true,
5454
},
5555
});
56+
if (inlineConfig.configFile && metadata.layers?.length === 0) {
57+
throw Error(`Config file "${inlineConfig.configFile}" not found`);
58+
}
5659
userConfig = loadedConfig ?? {};
5760
userConfigMetadata = metadata;
5861
}

0 commit comments

Comments
 (0)