-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
[fix][webpack]: Use a dynamic list of exclude to allow TSX plugins to be transpiled #14674
Conversation
Special thanks to @gu-stav for teaching me about profiling 💅🏼 |
Codecov ReportBase: 58.76% // Head: 58.78% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #14674 +/- ##
==========================================
+ Coverage 58.76% 58.78% +0.01%
==========================================
Files 1322 1323 +1
Lines 32045 32059 +14
Branches 5989 5992 +3
==========================================
+ Hits 18831 18845 +14
Misses 11351 11351
Partials 1863 1863
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@gu-stav, tested on windows (personally) and added some tests as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thank you for adding these great tests! 🌻
What does it do?
exclude
pattern forwebpack
to not exclude the TSX plugins installed innode_modules
by creating a dynamic regex.Why is it needed?
Currently when a plugin-creator makes a fresh plugin with Typescript we do not provide a build step for the
admin
package they may create, therefore when they publish their plugin tonpm
it containstsx|ts
files. When this is imported into a strapi app and the build is triggered it fails because it is compiled.How to test it?
cd examples/getstarted
yarn add strapi-plugin-point-list
yarn build
How did I come to this conclusion
I compared the memory profiles of building with different webpack configurations on a clean strapi app vs the current build process (without the plugin so it would actually work).
The problem
This is our current rule for webpack:
Current Benchmark
Solution 1 – Remove Exclude
The webpack config:
Solution 2 – Create a dynamic exclude list
note – i've inlined this for illustration purposes only
Solution 3 – Only pass
cacheDir
asinclude
This solution did not work and failed to build.
Methodology
The general flow is listed below:
pip3 install memory-profiler pip3 install matplotlib npx create-strapi-app@4.4.4 strapi-app --quickstart cd strapi-app yarn add strapi-plugin-point-list /opt/homebrew/bin/mprof run node_modules/.bin/strapi build /opt/homebrew/bin/mprof plot
Environment
I also manually deleted the
.cache
folder after every build, just incase.Also, if you wanna explore the dat files, see the zip below.
dat_files.zip
Related issue(s)/PR(s)