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

feat(modules): New entrypoints:found hook #967

Closed
wants to merge 2 commits into from

Conversation

aklinker1
Copy link
Collaborator

@aklinker1 aklinker1 commented Sep 3, 2024

This closes #937.

wxt.hooks.hook("entrypoints:found", (_, paths) => {
  paths.push("src/entrypoints/content-scripts/google/some-script.content.ts");
  paths.push("src/entrypoints/content-scripts/google/another-script.content/index.ts");
});

Or use a glob pattern:

import glob from 'fast-glob';

wxt.hooks.hook("entrypoints:found", async (_, paths) => {
  const customEntrypoints = awit glob([
    "src/entrypoints/**/*.content.ts",
    "src/entrypoints/**/*.content/index.ts"
  ]);
  paths.push(...customEntrypoints);
});

Copy link

netlify bot commented Sep 3, 2024

Deploy Preview for creative-fairy-df92c4 failed.

Name Link
🔨 Latest commit 4e9246b
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/66d7467bc9541e000824905f

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.77%. Comparing base (87fbb1f) to head (4e9246b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #967      +/-   ##
==========================================
- Coverage   81.90%   81.77%   -0.14%     
==========================================
  Files         125      125              
  Lines        6605     6605              
  Branches     1100     1100              
==========================================
- Hits         5410     5401       -9     
- Misses       1181     1190       +9     
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aklinker1
Copy link
Collaborator Author

aklinker1 commented Sep 3, 2024

Hmm, yeah, so this just is not going to work without a more sophisticated algorithm for detecting folders vs single file entrypoints.

For example, because I had to switch to using absolute paths, entrypoints/popup/index.html would be matched as the popup entrypoint correctly, but entrypoints/popup/main.ts get matched as an unlisted script. There isn't a simple and easy way to tell these apart. You could ignore any files inside a folder with index.html or index.ts file, but then we'd be hiding warnings that make it easy to know why a file isn't being built as an entrypoint.

I could write a even more complex solution that works nicely for all cases... but I don't think this issue is worth the effort. Just use the standardized project layout. That's what opinionated frameworks are all about.

So I'm gonna close this PR, and suggest a different solution on #937

@aklinker1 aklinker1 closed this Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request for nested content folder structure
1 participant