Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore popup/index.ts instead of erroring #1333

Open
aleclarson opened this issue Jan 5, 2025 · 1 comment
Open

Ignore popup/index.ts instead of erroring #1333

aleclarson opened this issue Jan 5, 2025 · 1 comment

Comments

@aleclarson
Copy link

In #276, an error message was added for when both popup/index.html and popup/index.ts exist. As I mentioned in this comment, it would be better to simply ignore the popup/index.ts file, especially since the docs suggest that a popup must be a .html file.

@aklinker1
Copy link
Collaborator

aklinker1 commented Jan 5, 2025

For reference, here is where we apply the glob patterns to detect entrypoint files:

const relativePaths = await glob(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
cwd: wxt.config.entrypointsDir,
});

There is a test that already exists to cover this. It just needs updated slightly: remove the popup.html input and don't expect any validation errors.

it('should not allow multiple entrypoints with the same name', async () => {
globMock.mockResolvedValueOnce([
'options/index.html',
'options/index.jsx',
'popup.html',
'popup/index.html',
'popup/index.ts',
'ui.html',
]);
await expect(() => findEntrypoints()).rejects.toThrowError(
[
'Multiple entrypoints with the same name detected, only one entrypoint for each name is allowed.',
'',
'- options',
` - ${unnormalizePath('src/entrypoints/options/index.html')}`,
` - ${unnormalizePath('src/entrypoints/options/index.jsx')}`,
'- popup',
` - ${unnormalizePath('src/entrypoints/popup.html')}`,
` - ${unnormalizePath('src/entrypoints/popup/index.html')}`,
` - ${unnormalizePath('src/entrypoints/popup/index.ts')}`,
].join('\n'),
);
});

Additionally, we should add another test case, basically a copy of the original, that expects an error for popup.html, popup/index.html, and popup.content.ts files - there can still only be one entrypoint named "popup".

This issue just ignores */index.[jt]sx? when */index.html already exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants