Skip to content

Conversation

@leovalette
Copy link

Summary

Motivation:
While migrating our App to streaming SSR using renderToPipeableStream, we identified a limitation in @loadable/server. Currently, there is a discrepancy between the two ways to retrieve asset tags:

  • String-based methods (getScriptTags(), getStyleTags()) → Include integrity attributes ✅
  • JSX methods (getScriptElements(), getStyleElements()) → Do not include integrity attributes ❌

This PR resolves this issue by ensuring that the integrity property from webpack stats is correctly passed to the generated JSX elements. This allows for Subresource Integrity (SRI) checks to be maintained when using the JSX API.

Changes include:

  • Updating assetToScriptElement, assetToStyleElement, and assetToLinkElement in ChunkExtractor.js to include the integrity prop if available.
  • Adding unit tests to verify the attribute is correctly rendered.

Test plan

New unit tests have been added to packages/server/src/ChunkExtractor.test.js to cover this feature.

yarn test packages/server
yarn run v1.22.22
$ jest packages/server
 PASS  packages/server/src/ChunkExtractor.test.js
 PASS  packages/server/src/util.test.js

Test Suites: 2 passed, 2 total
Tests:       6 skipped, 46 passed, 52 total
Snapshots:   36 passed, 36 total
Time:        0.56s, estimated 1s
Ran all test suites matching /packages\/server/i.
✨  Done in 1.73s.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant