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

🐛 Webpack entry: {name: './extension-less-file'} not supported #949

Closed
6 tasks done
fregante opened this issue Feb 20, 2025 · 3 comments
Closed
6 tasks done

🐛 Webpack entry: {name: './extension-less-file'} not supported #949

fregante opened this issue Feb 20, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@fregante
Copy link

Prerequisites

Reproduction url

Non-minimal repro: https://github.com/pixiebrix/pixiebrix-extension/blob/92cbf5c2c132fc5618be7f0855266daac99f1f88/webpack.config.mjs#L112-L142

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

I'm creating some issues for tracking the bugs I found. I'll minimize the repro as necessary.

I reported this a year ago, but the reason was not immediately clear because knip does not report invalid entry points (this seems to be a common cause for trouble).

If webpack.config.js exports this, knip can't resolve them

module.exports = {
  entry: {
    background: './src/background/background',
    contentScript: './src/contentScript/contentScript',
  }
}

but it works if I add the extensions:

module.exports = {
  entry: {
    background: './src/background/background.ts',
    contentScript: './src/contentScript/contentScript.tsx',
  }
}

I think webpack can resolve certain extensions natively (.js) but extra config may be required to resolve .ts and .tsx. This works correctly in webpack:

module.exports = {
  entry: {
    background: './src/background/background',
    contentScript: './src/contentScript/contentScript',
  }
  resolve: {
    extensions: [".ts", ".tsx", ".jsx", ".js", ".mjs"],
  }
}

You can see extension-less entries in the docs: https://webpack.js.org/configuration/entry-context/#dynamic-entry

@fregante fregante added the bug Something isn't working label Feb 20, 2025
@webpro webpro closed this as completed in e42b09d Feb 23, 2025
@webpro
Copy link
Member

webpro commented Feb 23, 2025

This hasn't been reported before as I guess most configurations just use the full filename including the extension.

@webpro
Copy link
Member

webpro commented Feb 23, 2025

🚀 This issue has been resolved in v5.44.5. See Release 5.44.5 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

@fregante
Copy link
Author

I can confirm that did it! Thank you Lars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants