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

Float integrity bugfix #27224

Merged
merged 3 commits into from
Aug 14, 2023
Merged

Float integrity bugfix #27224

merged 3 commits into from
Aug 14, 2023

Conversation

gnoff
Copy link
Collaborator

@gnoff gnoff commented Aug 13, 2023

Stacked on #27223

When a script resource adopts certain props from a preload for that resource the integrity prop was incorrectly getting assinged to the referrerPolicy prop instead. This is now fixed.

@react-sizebot
Copy link

Comparing: 1a001da...9970fd2

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 164.32 kB 164.32 kB = 51.76 kB 51.76 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 171.74 kB 171.73 kB = 53.97 kB 53.98 kB
facebook-www/ReactDOM-prod.classic.js = 567.12 kB 567.12 kB = 100.09 kB 100.09 kB
facebook-www/ReactDOM-prod.modern.js = 550.92 kB 550.92 kB = 97.25 kB 97.25 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.development.js = 391.56 kB 364.69 kB = 83.91 kB 79.72 kB
oss-experimental/react-dom/umd/react-dom-server.browser.development.js = 390.71 kB 363.85 kB = 84.02 kB 79.84 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js = 375.74 kB 349.76 kB = 83.50 kB 79.31 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js = 374.57 kB 348.59 kB = 83.17 kB 79.00 kB
oss-experimental/react-dom/cjs/react-dom-static.node.development.js = 374.54 kB 348.55 kB = 83.26 kB 79.09 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js = 373.92 kB 347.94 kB = 83.04 kB 78.85 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.development.js = 373.50 kB 347.52 kB = 83.24 kB 79.07 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js = 373.09 kB 347.11 kB = 83.12 kB 78.95 kB
oss-experimental/react-dom/cjs/react-dom-static.edge.development.js = 372.81 kB 346.83 kB = 83.06 kB 78.89 kB
oss-experimental/react-dom/cjs/react-dom-static.browser.development.js = 372.40 kB 346.42 kB = 82.94 kB 78.77 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js = 370.90 kB 344.92 kB = 82.44 kB 78.27 kB
oss-stable/react-dom/umd/react-dom-server-legacy.browser.development.js = 381.45 kB 354.59 kB = 81.77 kB 77.53 kB
oss-stable-semver/react-dom/umd/react-dom-server-legacy.browser.development.js = 381.43 kB 354.56 kB = 81.74 kB 77.50 kB
oss-stable/react-dom/umd/react-dom-server.browser.development.js = 381.19 kB 354.32 kB = 82.07 kB 77.89 kB
oss-stable-semver/react-dom/umd/react-dom-server.browser.development.js = 381.16 kB 354.30 kB = 82.05 kB 77.86 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.development.js = 366.05 kB 340.07 kB = 81.38 kB 77.10 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.development.js = 366.02 kB 340.04 kB = 81.35 kB 77.07 kB
oss-stable/react-dom/cjs/react-dom-server.node.development.js = 365.46 kB 339.48 kB = 81.24 kB 77.02 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.development.js = 365.44 kB 339.46 kB = 81.23 kB 76.99 kB
oss-stable/react-dom/cjs/react-dom-server.edge.development.js = 364.39 kB 338.41 kB = 81.33 kB 77.10 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.development.js = 364.37 kB 338.39 kB = 81.31 kB 77.07 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.development.js = 364.23 kB 338.25 kB = 80.92 kB 76.64 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.development.js = 364.21 kB 338.23 kB = 80.89 kB 76.62 kB
oss-stable/react-dom/cjs/react-dom-server.browser.development.js = 363.98 kB 338.00 kB = 81.21 kB 76.98 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.development.js = 363.96 kB 337.98 kB = 81.19 kB 76.95 kB
oss-stable/react-dom/cjs/react-dom-server.bun.development.js = 361.21 kB 335.23 kB = 80.30 kB 76.08 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.development.js = 361.18 kB 335.20 kB = 80.28 kB 76.05 kB
facebook-www/ReactDOMServer-dev.classic.js = 383.14 kB 353.47 kB = 83.61 kB 79.01 kB
facebook-www/ReactDOMServer-dev.modern.js = 375.71 kB 346.04 kB = 81.98 kB 77.37 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js = 370.54 kB 340.87 kB = 80.71 kB 76.13 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.development.js = 391.56 kB 364.69 kB = 83.91 kB 79.72 kB
oss-experimental/react-dom/umd/react-dom-server.browser.development.js = 390.71 kB 363.85 kB = 84.02 kB 79.84 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js = 375.74 kB 349.76 kB = 83.50 kB 79.31 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js = 374.57 kB 348.59 kB = 83.17 kB 79.00 kB
oss-experimental/react-dom/cjs/react-dom-static.node.development.js = 374.54 kB 348.55 kB = 83.26 kB 79.09 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js = 373.92 kB 347.94 kB = 83.04 kB 78.85 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.development.js = 373.50 kB 347.52 kB = 83.24 kB 79.07 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js = 373.09 kB 347.11 kB = 83.12 kB 78.95 kB
oss-experimental/react-dom/cjs/react-dom-static.edge.development.js = 372.81 kB 346.83 kB = 83.06 kB 78.89 kB
oss-experimental/react-dom/cjs/react-dom-static.browser.development.js = 372.40 kB 346.42 kB = 82.94 kB 78.77 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js = 370.90 kB 344.92 kB = 82.44 kB 78.27 kB
oss-stable/react-dom/umd/react-dom-server-legacy.browser.development.js = 381.45 kB 354.59 kB = 81.77 kB 77.53 kB
oss-stable-semver/react-dom/umd/react-dom-server-legacy.browser.development.js = 381.43 kB 354.56 kB = 81.74 kB 77.50 kB
oss-stable/react-dom/umd/react-dom-server.browser.development.js = 381.19 kB 354.32 kB = 82.07 kB 77.89 kB
oss-stable-semver/react-dom/umd/react-dom-server.browser.development.js = 381.16 kB 354.30 kB = 82.05 kB 77.86 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.development.js = 366.05 kB 340.07 kB = 81.38 kB 77.10 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.development.js = 366.02 kB 340.04 kB = 81.35 kB 77.07 kB
oss-stable/react-dom/cjs/react-dom-server.node.development.js = 365.46 kB 339.48 kB = 81.24 kB 77.02 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.development.js = 365.44 kB 339.46 kB = 81.23 kB 76.99 kB
oss-stable/react-dom/cjs/react-dom-server.edge.development.js = 364.39 kB 338.41 kB = 81.33 kB 77.10 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.development.js = 364.37 kB 338.39 kB = 81.31 kB 77.07 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.browser.development.js = 364.23 kB 338.25 kB = 80.92 kB 76.64 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.browser.development.js = 364.21 kB 338.23 kB = 80.89 kB 76.62 kB
oss-stable/react-dom/cjs/react-dom-server.browser.development.js = 363.98 kB 338.00 kB = 81.21 kB 76.98 kB
oss-stable-semver/react-dom/cjs/react-dom-server.browser.development.js = 363.96 kB 337.98 kB = 81.19 kB 76.95 kB
oss-stable/react-dom/cjs/react-dom-server.bun.development.js = 361.21 kB 335.23 kB = 80.30 kB 76.08 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.development.js = 361.18 kB 335.20 kB = 80.28 kB 76.05 kB
facebook-www/ReactDOMServer-dev.classic.js = 383.14 kB 353.47 kB = 83.61 kB 79.01 kB
facebook-www/ReactDOMServer-dev.modern.js = 375.71 kB 346.04 kB = 81.98 kB 77.37 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js = 370.54 kB 340.87 kB = 80.71 kB 76.13 kB

Generated by 🚫 dangerJS against 9970fd2

@gnoff gnoff merged commit 0fb5b61 into facebook:main Aug 14, 2023
@gnoff gnoff deleted the float-integrity-bugfix branch August 14, 2023 17:10
github-actions bot pushed a commit that referenced this pull request Aug 14, 2023
Stacked on #27223

When a script resource adopts certain props from a preload for that
resource the integrity prop was incorrectly getting assinged to the
referrerPolicy prop instead. This is now fixed.

DiffTrain build for [0fb5b61](0fb5b61)
gnoff added a commit that referenced this pull request Aug 17, 2023
…dule` (#27220)

Stacked on #27224 

### Implements `ReactDOM.preloadModule()`
`preloadModule` is a function to preload modules of various types.
Similar to `preload` this is useful when you expect to use a Resource
soon but can't render that resource directly. At the moment the only
sensible module to preload is script modules along with some other `as`
variants such as `as="serviceworker"`. In the future when there is some
notion of how to preload style module script or json module scripts this
API will be extended to support those as well.

##### Arguments
1. `href: string` -> the href or src value you want to preload.
2. `options?: {...}` -> 
2.1. `options.as?: string` -> the `as` property the modulepreload link
should render with. If not provided it will be omitted which will cause
the modulepreload to be treated like a script module
2.2. `options.crossOrigin?: string` -> modules always load with CORS but
you can provide `use-credentials` if you want to change the default
behavior
2.3. `options.integrity?: string` -> an integrity hash for subresource
integrity APIs
  
##### Rendering
each preloaded module will emit a `<link rel="modulepreload" href="..."
/>`
if `as` is specified and is something other than `"script"` the as
attribute will also be included
if crossOrigin or integrity as specified their attributes will also be
included

During SSR these script tags will be emitted before content. If we have
not yet flushed the document head they will be emitted there after
things that block paint such as font preloads, img preloads, and
stylesheets.

On the client these link tags will be appended to the document.head.
  
### Implements `ReactDOM.preinitModule()`
`preinitModule` is a function to loading module scripts before they are
required. It has the same use cases as `preinit`.

During SSR you would use this to tell the browsers to start fetching
code that will be used without having to wait for bootstrapping to
initiate module fetches.

ON the client you would use this to start fetching a module script early
for an anticipated navigation or other event that is likely to depend on
this module script.

the `as` property for Float methods drew inspiration from the `as`
attribute of the `<link rel="preload" ... >` tag but it is used as a
sort of tag for the kind of thing being targetted by Float methods. For
`preinitModule` we currently only support `as: "script"` and this is
also the assumed default type so you current never need to specify this
`as` value. In the future `preinitModule` will support additional module
script types such as `style` or `json`. The support of these types will
correspond to [Module Import
Attributes](https://github.com/tc39/proposal-import-attributes).

##### Arguments
1. `href: string` -> the href or src value you want to preinitialize
2. `options?: {...}` ->
2.1 `options.as?: string` -> only supports `script` and this is the
default behavior. Until we support import attributes such as `json` and
`style` there will not be much reason to provide an `as` option.
2.2. `options.crossOrigin?: string`: modules always load with CORS but
you can provide `use-credentials` if you want to change the default
behavior
2.3 `options.integrity?: string` -> an integrity hash for subresource
integrity APIs

##### Rendering
each preinitialized `script` module will emit a `<script type="module"
async="" src"...">` During SSR these will appear behind display blocking
resources such as font preloads, img preloads, and stylesheets. In the
browser these will be appende to the head.

Note that for other `as` types the rendered output will be slightly
different. `<script type="module">import "..." with {type: "json"
}</script>`. Since this tag is an inline script variants of React that
do not use inline scripts will simply omit these preinitialization tags
from the SSR output. This is not implemented in this PR but will appear
in a future update.
github-actions bot pushed a commit that referenced this pull request Aug 17, 2023
…dule` (#27220)

Stacked on #27224

### Implements `ReactDOM.preloadModule()`
`preloadModule` is a function to preload modules of various types.
Similar to `preload` this is useful when you expect to use a Resource
soon but can't render that resource directly. At the moment the only
sensible module to preload is script modules along with some other `as`
variants such as `as="serviceworker"`. In the future when there is some
notion of how to preload style module script or json module scripts this
API will be extended to support those as well.

##### Arguments
1. `href: string` -> the href or src value you want to preload.
2. `options?: {...}` ->
2.1. `options.as?: string` -> the `as` property the modulepreload link
should render with. If not provided it will be omitted which will cause
the modulepreload to be treated like a script module
2.2. `options.crossOrigin?: string` -> modules always load with CORS but
you can provide `use-credentials` if you want to change the default
behavior
2.3. `options.integrity?: string` -> an integrity hash for subresource
integrity APIs

##### Rendering
each preloaded module will emit a `<link rel="modulepreload" href="..."
/>`
if `as` is specified and is something other than `"script"` the as
attribute will also be included
if crossOrigin or integrity as specified their attributes will also be
included

During SSR these script tags will be emitted before content. If we have
not yet flushed the document head they will be emitted there after
things that block paint such as font preloads, img preloads, and
stylesheets.

On the client these link tags will be appended to the document.head.

### Implements `ReactDOM.preinitModule()`
`preinitModule` is a function to loading module scripts before they are
required. It has the same use cases as `preinit`.

During SSR you would use this to tell the browsers to start fetching
code that will be used without having to wait for bootstrapping to
initiate module fetches.

ON the client you would use this to start fetching a module script early
for an anticipated navigation or other event that is likely to depend on
this module script.

the `as` property for Float methods drew inspiration from the `as`
attribute of the `<link rel="preload" ... >` tag but it is used as a
sort of tag for the kind of thing being targetted by Float methods. For
`preinitModule` we currently only support `as: "script"` and this is
also the assumed default type so you current never need to specify this
`as` value. In the future `preinitModule` will support additional module
script types such as `style` or `json`. The support of these types will
correspond to [Module Import
Attributes](https://github.com/tc39/proposal-import-attributes).

##### Arguments
1. `href: string` -> the href or src value you want to preinitialize
2. `options?: {...}` ->
2.1 `options.as?: string` -> only supports `script` and this is the
default behavior. Until we support import attributes such as `json` and
`style` there will not be much reason to provide an `as` option.
2.2. `options.crossOrigin?: string`: modules always load with CORS but
you can provide `use-credentials` if you want to change the default
behavior
2.3 `options.integrity?: string` -> an integrity hash for subresource
integrity APIs

##### Rendering
each preinitialized `script` module will emit a `<script type="module"
async="" src"...">` During SSR these will appear behind display blocking
resources such as font preloads, img preloads, and stylesheets. In the
browser these will be appende to the head.

Note that for other `as` types the rendered output will be slightly
different. `<script type="module">import "..." with {type: "json"
}</script>`. Since this tag is an inline script variants of React that
do not use inline scripts will simply omit these preinitialization tags
from the SSR output. This is not implemented in this PR but will appear
in a future update.

DiffTrain build for [e505316](e505316)
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
Stacked on facebook#27223

When a script resource adopts certain props from a preload for that
resource the integrity prop was incorrectly getting assinged to the
referrerPolicy prop instead. This is now fixed.
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
…dule` (facebook#27220)

Stacked on facebook#27224 

### Implements `ReactDOM.preloadModule()`
`preloadModule` is a function to preload modules of various types.
Similar to `preload` this is useful when you expect to use a Resource
soon but can't render that resource directly. At the moment the only
sensible module to preload is script modules along with some other `as`
variants such as `as="serviceworker"`. In the future when there is some
notion of how to preload style module script or json module scripts this
API will be extended to support those as well.

##### Arguments
1. `href: string` -> the href or src value you want to preload.
2. `options?: {...}` -> 
2.1. `options.as?: string` -> the `as` property the modulepreload link
should render with. If not provided it will be omitted which will cause
the modulepreload to be treated like a script module
2.2. `options.crossOrigin?: string` -> modules always load with CORS but
you can provide `use-credentials` if you want to change the default
behavior
2.3. `options.integrity?: string` -> an integrity hash for subresource
integrity APIs
  
##### Rendering
each preloaded module will emit a `<link rel="modulepreload" href="..."
/>`
if `as` is specified and is something other than `"script"` the as
attribute will also be included
if crossOrigin or integrity as specified their attributes will also be
included

During SSR these script tags will be emitted before content. If we have
not yet flushed the document head they will be emitted there after
things that block paint such as font preloads, img preloads, and
stylesheets.

On the client these link tags will be appended to the document.head.
  
### Implements `ReactDOM.preinitModule()`
`preinitModule` is a function to loading module scripts before they are
required. It has the same use cases as `preinit`.

During SSR you would use this to tell the browsers to start fetching
code that will be used without having to wait for bootstrapping to
initiate module fetches.

ON the client you would use this to start fetching a module script early
for an anticipated navigation or other event that is likely to depend on
this module script.

the `as` property for Float methods drew inspiration from the `as`
attribute of the `<link rel="preload" ... >` tag but it is used as a
sort of tag for the kind of thing being targetted by Float methods. For
`preinitModule` we currently only support `as: "script"` and this is
also the assumed default type so you current never need to specify this
`as` value. In the future `preinitModule` will support additional module
script types such as `style` or `json`. The support of these types will
correspond to [Module Import
Attributes](https://github.com/tc39/proposal-import-attributes).

##### Arguments
1. `href: string` -> the href or src value you want to preinitialize
2. `options?: {...}` ->
2.1 `options.as?: string` -> only supports `script` and this is the
default behavior. Until we support import attributes such as `json` and
`style` there will not be much reason to provide an `as` option.
2.2. `options.crossOrigin?: string`: modules always load with CORS but
you can provide `use-credentials` if you want to change the default
behavior
2.3 `options.integrity?: string` -> an integrity hash for subresource
integrity APIs

##### Rendering
each preinitialized `script` module will emit a `<script type="module"
async="" src"...">` During SSR these will appear behind display blocking
resources such as font preloads, img preloads, and stylesheets. In the
browser these will be appende to the head.

Note that for other `as` types the rendered output will be slightly
different. `<script type="module">import "..." with {type: "json"
}</script>`. Since this tag is an inline script variants of React that
do not use inline scripts will simply omit these preinitialization tags
from the SSR output. This is not implemented in this PR but will appear
in a future update.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
Stacked on #27223

When a script resource adopts certain props from a preload for that
resource the integrity prop was incorrectly getting assinged to the
referrerPolicy prop instead. This is now fixed.

DiffTrain build for commit 0fb5b61.
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
…dule` (#27220)

Stacked on #27224

### Implements `ReactDOM.preloadModule()`
`preloadModule` is a function to preload modules of various types.
Similar to `preload` this is useful when you expect to use a Resource
soon but can't render that resource directly. At the moment the only
sensible module to preload is script modules along with some other `as`
variants such as `as="serviceworker"`. In the future when there is some
notion of how to preload style module script or json module scripts this
API will be extended to support those as well.

##### Arguments
1. `href: string` -> the href or src value you want to preload.
2. `options?: {...}` ->
2.1. `options.as?: string` -> the `as` property the modulepreload link
should render with. If not provided it will be omitted which will cause
the modulepreload to be treated like a script module
2.2. `options.crossOrigin?: string` -> modules always load with CORS but
you can provide `use-credentials` if you want to change the default
behavior
2.3. `options.integrity?: string` -> an integrity hash for subresource
integrity APIs

##### Rendering
each preloaded module will emit a `<link rel="modulepreload" href="..."
/>`
if `as` is specified and is something other than `"script"` the as
attribute will also be included
if crossOrigin or integrity as specified their attributes will also be
included

During SSR these script tags will be emitted before content. If we have
not yet flushed the document head they will be emitted there after
things that block paint such as font preloads, img preloads, and
stylesheets.

On the client these link tags will be appended to the document.head.

### Implements `ReactDOM.preinitModule()`
`preinitModule` is a function to loading module scripts before they are
required. It has the same use cases as `preinit`.

During SSR you would use this to tell the browsers to start fetching
code that will be used without having to wait for bootstrapping to
initiate module fetches.

ON the client you would use this to start fetching a module script early
for an anticipated navigation or other event that is likely to depend on
this module script.

the `as` property for Float methods drew inspiration from the `as`
attribute of the `<link rel="preload" ... >` tag but it is used as a
sort of tag for the kind of thing being targetted by Float methods. For
`preinitModule` we currently only support `as: "script"` and this is
also the assumed default type so you current never need to specify this
`as` value. In the future `preinitModule` will support additional module
script types such as `style` or `json`. The support of these types will
correspond to [Module Import
Attributes](https://github.com/tc39/proposal-import-attributes).

##### Arguments
1. `href: string` -> the href or src value you want to preinitialize
2. `options?: {...}` ->
2.1 `options.as?: string` -> only supports `script` and this is the
default behavior. Until we support import attributes such as `json` and
`style` there will not be much reason to provide an `as` option.
2.2. `options.crossOrigin?: string`: modules always load with CORS but
you can provide `use-credentials` if you want to change the default
behavior
2.3 `options.integrity?: string` -> an integrity hash for subresource
integrity APIs

##### Rendering
each preinitialized `script` module will emit a `<script type="module"
async="" src"...">` During SSR these will appear behind display blocking
resources such as font preloads, img preloads, and stylesheets. In the
browser these will be appende to the head.

Note that for other `as` types the rendered output will be slightly
different. `<script type="module">import "..." with {type: "json"
}</script>`. Since this tag is an inline script variants of React that
do not use inline scripts will simply omit these preinitialization tags
from the SSR output. This is not implemented in this PR but will appear
in a future update.

DiffTrain build for commit e505316.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants