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: add js-entry-webpack-plugin to readme #1732
Conversation
I am really sorry but I don't understand what you mean. What problem does your plugin solve? |
@jantimon sorry didn't make it clear. In micro frontend architecture, the micro project can provide js file as its entry, which will later be loaded, mounted and unmounted by the base project (find more at single-spa) In this condition, if the js entry like index.tsx import some css file, and after building, the css entry file will be ignored coz html-webpack-plugin is nowhere to use to collect the css entry bundle This plugin inserts js fragment to create link tag in built js entry, which can load the css entry bundle so as not to make any break change to the project |
wow really cool that you managed to publish the plugins 🎉 unfortunately your plugin seems to be not a plugin for the html-webpack-plugin so I guess it's not well suited for the list of plugins for html-webpack-plugin in the readme.. I tried to understand your plugin but it's still quite hard to understand (probably because I have never used single-spa) Why is it called js-entry if it's a solution for css files? Did you know that there are already multiple solutions to extract different css assets in webpack? all of them are supported by the html-webpack-plugin the html-webpack-plugin will not ignore css files |
@jantimon Hi and thanks Let's put it this way. Leave the brilliant template features of html-webpack-plugin aside, another problem that it solving is to collect the entry bundles into template file, such as js and css And my plugin is not actually to extract some css assests but to collect them. As I mentioned above, if a Micro project generates a index.js and a extracted index.hash8.css, this is no place to load the css entry coz the base project only loads microA's Finally, my plugin is inspired by html-webpack-plugin, kind of an offspring of it, and solves the problem using js (not js file which finally generates html code) as a template, can enlarge the feature for html-webpack-plugin. And that's why this PR goes Thanks anyway~ |
Hm but wouldn't such an approach slow down the page load because of the watefall loading?
|
@jantimon I think it is a normal thing coz the entry.css is required, like html template does, may generates like <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Example template</title>
<script defer="defer" src="bundle.js"></script>
<link href="styles.css" rel="stylesheet" />
</head>
<body></body>
</html> And for that, we can insert the css link script at the end of js source, which may help a little to the profermance Moreover, the enterprise-ready micro solutions like qiankun and garfish all provide prefetch apps api, which can be enabled at a passing of a config And also, if you have some better ideas to this |
I believe this could also be done with a custom html-webpack-plugin however a dedicated plugin might be totally fine in that case. To load the css directly you could use the https://webpack.js.org/loaders/style-loader/ which would pack the css right into your js file. |
Please rebase, thank you |
@alexander-akait Hi, I rebased, plz check |
* fix: reemit favicon in serve/watch mode (jantimon#1804) * refactor: use logger to avoid pulling logs in output (jantimon#1805) * refactor: avoid extra file (jantimon#1806) * refactor: code (jantimon#1807) * docs: improve (jantimon#1808) * fix: avoid have undefined `type` for script tags (jantimon#1809) * refactor: fix regression after refactor and testing (jantimon#1810) * fix: reemit assets from loaders (jantimon#1811) * test: case for watch/serve and reemitting assets (jantimon#1812) * docs: add js-entry-webpack-plugin (jantimon#1732) * chore(release): 5.5.4 * docs: add html-webpack-inject-attributes-plugin to readme (jantimon#1787) * feat: Added support `type=systemjs-module` via the `scriptLoading` option (jantimon#1822) * fix: memoy leak (jantimon#1836) * feat: add `@rspack/core` as an optional peer dependency (jantimon#1829) * chore(release): 5.6.0 --------- Co-authored-by: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Co-authored-by: liam <lawler61@163.com> Co-authored-by: alexander.akait <sheo13666q@gmail.com> Co-authored-by: Yuwen Duan <dyw934854565@sina.com> Co-authored-by: 坏人日记 <badry.lin@gmail.com> Co-authored-by: Joe Boyle <jboyle617@gmail.com>
Hi, this PR is mainly to solve the problem when choosing
js file
as project entry especially in aMicro Frontend Project
And the source code is inspired by
html-webpack-plugin
Usage:
Thanks for checking, if possible, add it on the awesome list which can be convenient for others
Related Issue: #1699