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

[BUG] messages/external folder imported twice due to missing glob exclusion #1095

Open
xiata opened this issue Oct 3, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@xiata
Copy link
Contributor

xiata commented Oct 3, 2024

What happened?

In cli/plasmo/src/features/background-service-worker/bgsw-messaging.ts#getHandlerList there is a glob that inadvertently includes external messages when given getHandlerList(manifest, "messages"). The glob should not enter the messages/external folder because messages should only include internal message listeners, not the external message listeners.

How to reproduce:

  1. Create an external message handler, e.g. src/background/external/messages/Test.ts
  2. Create a .babelrc with at least the preset-env:
{
    "presets": [
      [
        "@babel/preset-env",
        {
          "targets": "chrome >= 90",
          "useBuiltIns": "usage",
          "corejs": 3
        }
      ],
      [
        "@babel/preset-typescript",
        {
          "allowDeclareFields": true
        }
      ]
    ]
  }
  1. plasmo build. Note that the build will fail according to the external message handler you added.

Version

Latest

What OS are you seeing the problem on?

MacOSX

What browsers are you seeing the problem on?

Chrome

Relevant log output

🟣 Plasmo v0.89.2
🔴 The Browser Extension Framework
🔵 INFO   | Prepare to bundle the extension...
🔵 INFO   | Building for target: chrome-mv3
🔵 INFO   | Loaded environment variables from: [ '.env.chrome', '.env.production', '.env' ]
🔴 ERROR  | Identifier 'messagesExternalTest' has already been declared. (38:20)


### (OPTIONAL) Contribution

- [X] I would like to fix this BUG via a PR

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
- [X] I checked the [current issues](https://github.com/PlasmoHQ/plasmo/issues?q=is%3Aopen+is%3Aissue+label%3Abug) for duplicate problems.
@xiata xiata added the bug Something isn't working label Oct 3, 2024
@xiata
Copy link
Contributor Author

xiata commented Oct 3, 2024

#1096

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

1 participant