bug: Ignore external folder when globbing messages folder #1096
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Details
Fixes a build error that occurs when a custom .babelrc is provided in the project that makes use of
@babel/preset-env
.The error
If you have a .babelrc and an external message such as
src/background/messages/external/Test.ts
, you will receive the following trying to build the extension:Root cause
In
cli/plasmo/src/features/background-service-worker/bgsw-messaging.ts
'sgetHandlerList
function, it performs a glob of all typescript files that are within the designated messages folder. Due tomessages/external
(public external messaging) being contained withinmessages
(extension internal messaging), this causes any external messaging to have a duplicate import created during build whengetHandlerList
is invoked withdirName: "messaging"
colliding with the invokation ofdirName: "messaging/external"
. Parcel happily removes the duplicate import, but unfortunately if you configure@babel/preset-env
for your extension (e.g. targeting older browsers), this triggers a hard error from babel.The fix
Since
messages/external
folder should be ignored whengetHandlerList
is givendirName: "messaging"
, simply add a glob ignore in that case.Code of Conduct
Contacts
If your PR is accepted, we will award you with the
Contributor
role on Discord server.To join the server, visit: https://www.plasmo.com/s/d