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
New command: spfx project externalize #571
Comments
Interesting suggestion. How would you determine, which packages could be externalized? |
For example, if we detect that @pnp/sp is being used and/or in the package.json, we know that could be offloaded to a CDN instead of bundling it. The idea would be to build detection rules this first one would be CDN001_pnp_sp or something like that. Of course this set of rules would be separate from the upgrade ones. |
With over 700.000 packages on npm how would we handle them in a way that scales? Theoretically, every package could be defined as an external so how could we deal with it in a way that won't require us adding every single package explicitly? |
Agreed, however each package can have different module definition, a global var or not exposed as well as different supported CDNs and url formats (meaning file name on the CDN, versioning tag…). So I can't think of a reliable consistent approach. |
It might be interesting to build a proof of concepts to see if this is viable. As you mentioned, it might be hard to get this done reliably so having something to look at would give us a better idea what's possible. |
I would recommend to have a dedicated tool for this as there would be to many "options" in making a decision on externalizing or not. The reason for externalizing could be many (compliance, reuse, performance, size...) which would it extremely difficult to create this command without building in biased thoughts. |
Depending on the complexity, it could be a separate tool or a separate command in the CLI, which would free folks from having to install yet another tool. But yes, definitely something separate. |
"One tool to rule them all" :-) |
I had an idea a couple of days ago. Based on the spfx project upgrade command, why not building a spfx project externalize command?
The idea is that it'd be based on detection rules, scan the package.json (and maybe some source files) to detect packages that could be externalized and suggest a config.json external configuration.
This way a developer could be sure he has the proper configuration, didn't miss out any package and so on.
Thoughts?
The text was updated successfully, but these errors were encountered: