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

Subresource Integrity support for Module Federation plugin chunks #176

Open
AmsterGet opened this issue Mar 26, 2022 · 14 comments
Open

Subresource Integrity support for Module Federation plugin chunks #176

AmsterGet opened this issue Mar 26, 2022 · 14 comments

Comments

@AmsterGet
Copy link

Hello!
I use webpack-subresource-integrity plugin together with webpack module federation and it throws an error during build process ERROR in webpack-subresource-integrity: Asset {assetName} contains unresolved integrity placeholders.

I may be missing something in the configuration, but it seems that hashes are not resolved for chunks generated by the WMF plugin.
Refers to this issue in the webpack repo.

Any help would be greatly appreciated.

Thank you in advance.

@jscheid
Copy link
Collaborator

jscheid commented Mar 26, 2022

We could add a mechanism to pass a URL-to-hash mapping as suggested here, and bake that into entry chunks (or ideally into all chunks which will load the URL when hashLoading: "lazy"). That would be useful for #167 as well.

Happy to take a look when I can find some time, in the meantime a PR for this is welcome.

@jscheid
Copy link
Collaborator

jscheid commented Mar 28, 2022

Could you provide a repro for the contains unresolved integrity placeholders error?

@AmsterGet
Copy link
Author

You can reproduce it here for application-a and application-b builds.

@subeshb1
Copy link

subeshb1 commented Jun 2, 2022

Any updates on this?

@dmialeshka
Copy link

bump

@StavM
Copy link

StavM commented Jan 27, 2023

any update on this ?

@brunos3d
Copy link

brunos3d commented Jan 30, 2023

Hello, folks. I'm working at a Webpack plugin that generates a JSON stats file about module federated chunks in the application
https://github.com/valorkin/mf-loadable-adapter/tree/master/packages/loadable-adapters/src/federation-stats-plugin

Here is my PR adding the support to SriPlugin, my intent is to generate the JSON stats file within the integrity information, but I got the error mentioned above on this thread during my builds, here is a screenshot containing the output file which contains the unresolved SRI hashes

image

I believe we can use this approach to solve these lazy Sri Hashes:

  • Add options to allow Module Federation Support. e.g: moduleFederation: true
  • Add options to pass a set of URLs containing the remote URL / the endpoint of the federated-stats.json file, then make a fetch before the __webpack_require__.sriHashes which lazily gets the Sri hashes from the remotes we did like here.
  • Add a warning to the Sri plugin which tells the user to use federation-stats-plugin and some documentation on readme showing how to use it.

I would appreciate it if we move this conversation forward 🚀

@jscheid
Copy link
Collaborator

jscheid commented Feb 11, 2023

@brunos3d without being too familiar with federation in Webpack, this does sound like a workable solution. PRs are welcome.

@sowtame
Copy link

sowtame commented Aug 21, 2023

bump

@yiluxiangbei87110
Copy link

Hello! I use webpack-subresource-integrity plugin together with webpack module federation and it throws an error during build process ERROR in webpack-subresource-integrity: Asset {assetName} contains unresolved integrity placeholders.

I may be missing something in the configuration, but it seems that hashes are not resolved for chunks generated by the WMF plugin. Refers to this issue in the webpack repo.

Any help would be greatly appreciated.

Thank you in advance.

Hello! I use webpack-subresource-integrity plugin together with webpack module federation and it throws an error during build process ERROR in webpack-subresource-integrity: Asset {assetName} contains unresolved integrity placeholders.

I may be missing something in the configuration, but it seems that hashes are not resolved for chunks generated by the WMF plugin. Refers to this issue in the webpack repo.

Any help would be greatly appreciated.

Thank you in advance.

Bro, I have also encountered this problem. Have you solved it?

@sowtame
Copy link

sowtame commented Aug 24, 2023

I fixed it here #220
please review

@SQReder
Copy link

SQReder commented Sep 27, 2023

bump

@sowtame
Copy link

sowtame commented Sep 27, 2023

hi, I made a temporary package @sowtame/webpack-subresource-integrity, supports wmf.
it's created from this pr

@rrosenshain-sc
Copy link

rrosenshain-sc commented Mar 29, 2024

hi, I made a temporary package @sowtame/webpack-subresource-integrity, supports wmf. it's created from this pr

Hey @sowtame I tried using your package but I'm getting:

ERROR in webpack/runtime/compat
Cannot read properties of undefined (reading 'getChunkRootModules')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants