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
experimentalImportBundleSupport: Move bundle path hints into serialised dependency map #901
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
labels
Nov 30, 2022
This pull request was exported from Phabricator. Differential Revision: D40412241 |
Differential Revision: D41615402 fbshipit-source-id: 6a232adef049573408dc503c2ddb4738f1c43f86
…ed dependency map (facebook#901) Summary: Pull Request resolved: facebook#901 Changelog: [Experimental] `experimentalImportBundleSupport`: Move bundle path hints into serialised dependency map ## Problem `experimentalImportBundleSupport` (D15943150 (facebook@72329d0)) originally relied on including a global map from module IDs to paths (`importBundleNames`) in each bundle served by the HTTP server. This allowed a custom (and Meta-internal) implementation of `asyncRequire` to construct and fetch an HTTP URL corresponding to any given async-loadable module. The global map approach breaks Fast Refresh when new async imports are added to a module, because it turns out we never update the global map during HMR. New `import()` call sites can be added and are transformed to `asyncRequire`, but the map entries they need aren't there, so they just throw at runtime. ## Solution Naively, fixing this would require teaching the entire HMR pipeline (Graph, DeltaCalculator, HmrServer, HmrClient) to incrementally update the `importBundleNames` map at runtime on the client. Here we take a different approach: breaking up the `importBundleNames` map into individual maps, one for each module that contains async dependencies. 1. Every call to `asyncRequire` now has an extra argument `paths` which holds a *local* map from IDs to paths. Conceptually, this is the same information that `importBundleNames` has for the entire graph, except now it's split by "parent" module. 2. `paths` is generated by the serializer for async dependencies (only) and written to the bundle in a backwards-compatible format as part of the dependency map - which is now either an array or an *object with a numeric indexer*, depending on whether it has a `paths` property. The HMR machinery already knows how to update dependency maps, so in particular it keeps `paths` up-to-date as part of that. No special plumbing needed! 🎉 NOTE: Anyone using the (still experimental) `experimentalImportBundleSupport` API will need to update their `asyncRequire` implementation to use this new mechanism instead (cc EvanBacon). ## Next steps * `graph.importBundleNames` will be going away in a separate diff. * Custom bundle splitting implementations may want something other than the *path* of a module, specifically, to be passed to `asyncRequire`. The contract is between the serializer and the `asyncRequire` implementation. We might want to use the term "fetch key" instead of "path", allow it to be any serializable value rather than just a string, and add a `createModuleFetchKey` API (analogous to `createModuleIdFactory`) to control this in config. Differential Revision: D40412241 fbshipit-source-id: f2704a94bd7f7ad923b6418378f23e7104b35211
motiz88
force-pushed
the
export-D40412241
branch
from
November 30, 2022 16:23
05d7264
to
8180cce
Compare
This pull request was exported from Phabricator. Differential Revision: D40412241 |
hyochan
pushed a commit
to dooboolab-community/dooboo-ui
that referenced
this pull request
Mar 14, 2023
….0 (#264) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [metro-react-native-babel-preset](https://togithub.com/facebook/metro) | [`^0.72.0` -> `^0.76.0`](https://renovatebot.com/diffs/npm/metro-react-native-babel-preset/0.72.3/0.76.0) | [![age](https://badges.renovateapi.com/packages/npm/metro-react-native-babel-preset/0.76.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/metro-react-native-babel-preset/0.76.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/metro-react-native-babel-preset/0.76.0/compatibility-slim/0.72.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/metro-react-native-babel-preset/0.76.0/confidence-slim/0.72.3)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>facebook/metro</summary> ### [`v0.76.0`](https://togithub.com/facebook/metro/releases/tag/v0.76.0) [Compare Source](https://togithub.com/facebook/metro/compare/v0.75.1...v0.76.0) - **\[Breaking]**: Increase minimum Node version from 14 to 16. (facebook/metro@e5950ae by [@​huntie](https://togithub.com/huntie)) - **\[Breaking]**: Remove `isAssetFile` from custom resolver context, add `assetExts`. (facebook/metro@c6548f7 by [@​huntie](https://togithub.com/huntie)) - **\[Feature]**: Support [`require.resolveWeak()`](https://facebook.github.io/metro/docs/module-api#requireresolveweak). (facebook/metro@354d6e4 by [@​motiz88](https://togithub.com/motiz88)) - **\[Fix]**: Don't over-invalidate on symlink changes if resolution through symlinks is not enabled. (facebook/metro@2303c10 by [@​robhogan](https://togithub.com/robhogan)) - **\[Fix]**: Returning `false` from [`context.redirectModulePath`](https://facebook.github.io/metro/docs/resolution#redirectmodulepath-string--string--false) will resolve to empty module in all cases. (facebook/metro@0f1846a by [@​huntie](https://togithub.com/huntie)) - **\[Fix]**: Respect extensionless entries in `browser`, `react-native` etc when resolving subpath package specifiers. (facebook/metro@7e92227 by [@​huntie](https://togithub.com/huntie)) - **\[Fix]**: Remove undocumented Meta-only `__jsResource` and `__conditionallySplitJsResource` functions from module API. (facebook/metro@f1d905b and facebook/metro@69c8fc7 by [@​motiz88](https://togithub.com/motiz88)) > NOTE: Experimental features are not covered by semver and can change at any time. - **\[Experimental]**: Fixes and improvements for symlink support. (facebook/metro@0e2a70a, facebook/metro@3bef954, and facebook/metro@eeb211f by [@​robhogan](https://togithub.com/robhogan)) - **\[Experimental]**: Fix bug where `"exports"` field would be used on relative imports within a package. (facebook/metro@cd25c2b by [@​huntie](https://togithub.com/huntie)) ### [`v0.75.1`](https://togithub.com/facebook/metro/releases/tag/v0.75.1) [Compare Source](https://togithub.com/facebook/metro/compare/v0.75.0...v0.75.1) - **\[Feature]**: `metro-inspector-proxy`: Add a human-readable reference to each inspector entries/pages.([facebook/metro#921 by [@​byCedric](https://togithub.com/byCedric)) - **\[Feature]**: `metro-inspector-proxy`: Report errors in the console. (facebook/metro@da8b41b by [@​mattbfb](https://togithub.com/mattbfb)) - **\[Fix]**: Race condition where a very recently modified file might have missing metadata.(facebook/metro@baf28ab by [@​robhogan](https://togithub.com/robhogan)) - **\[Fix]**: Source maps may have invalid entries when using Terser minification. ([facebook/metro#928 by [@​robhogan](https://togithub.com/robhogan)) - **\[Fix]**: `metro-inspector-proxy`: Fetch source maps from Metro. (facebook/metro@6690b39 by [@​mattbfb](https://togithub.com/mattbfb)) - **\[Fix]**: Mitigate potential source map mismatches with concurrent transformations due to [terser#​1341](https://togithub.com/terser/terser/issues/1341). ([facebook/metro#929 by [@​robhogan](https://togithub.com/robhogan)) > NOTE: Experimental features are not covered by semver and can change at any time. - **\[Experimental]**: Add initial_build annotation to Resolving and Transforming Dependencies (facebook/metro@fc83b52 by [@​blakef](https://togithub.com/blakef)) - **\[Experimental]**: Implement support for Package Exports (enabled via `resolver.unstable_enablePackageExports`) (facebook/metro@4d7ab38, facebook/metro@38b96f8, facebook/metro@216d3e2, facebook/metro@6e6f36f by [@​huntie](https://togithub.com/huntie)) - **\[Experimental]**: Implement support for symlinks (enabled via `resolver.unstable_enableSymlinks`) ([facebook/metro#925, [facebook/metro#926, etc. by [@​robhogan](https://togithub.com/robhogan)) **Full Changelog:** facebook/metro@v0.75.0...v0.75.1 ### [`v0.75.0`](https://togithub.com/facebook/metro/releases/tag/v0.75.0) [Compare Source](https://togithub.com/facebook/metro/compare/v0.74.1...v0.75.0) - **\[Breaking]**: Formalise minimum Node JS requirement at 14.17.0 via `package.json#engines`. (facebook/metro@c3e453e) - **\[Breaking]**: Filter untyped context properties passed to custom resolvers. (facebook/metro@cb01ec0) - **\[Breaking]**: Change default `context.redirectModulePath` implementation to return absolute path in all cases. (facebook/metro@acbfe63) - **\[Feature]**: Add `mainFields`, `getPackage`, and `getPackageForModule` to custom resolver context. (facebook/metro@adfb593) **Full Changelog**: facebook/metro@v0.74.1...v0.75.0 ### [`v0.74.1`](https://togithub.com/facebook/metro/releases/tag/v0.74.1) [Compare Source](https://togithub.com/facebook/metro/compare/v0.74.0...v0.74.1) - **\[Feature]**: Add `@babel/plugin-proposal-numeric-separator` to `metro-react-native-babel-preset` ([facebook/metro#681 by [@​SConaway](https://togithub.com/SConaway)) **Full Changelog**: facebook/metro@v0.74.0...v0.74.1 ### [`v0.74.0`](https://togithub.com/facebook/metro/releases/tag/v0.74.0) [Compare Source](https://togithub.com/facebook/metro/compare/v0.73.8...v0.74.0) - **\[Breaking]** Remove [@​babel/plugin-transform-template-literals](https://togithub.com/babel/plugin-transform-template-literals) from metro-react-native-babel-preset (facebook/metro@322dea8) - **\[Breaking]** Remove `postProcessBundleSourcemap` from config (facebook/metro@339794e) - **\[Fix]** Don't log ENOENT errors to console for expected URL stack frames (facebook/metro@1031ae6) - **\[Fix]** Don't attempt to use the `find` crawler on Windows (facebook/metro@735aa9f) - **\[Performance]** Improve AST processing during transformation ([facebook/metro#854 by [@​EvanBacon](https://togithub.com/EvanBacon)) - **\[Performance]** Improve Fast Refresh responsiveness when watching a large number of files (facebook/metro@b942eca) **Full Changelog:** facebook/metro@v0.73.6...v0.74.0 ### [`v0.73.8`](https://togithub.com/facebook/metro/releases/tag/v0.73.8) [Compare Source](https://togithub.com/facebook/metro/compare/v0.73.7...v0.73.8) *This is a hotfix on the `0.73.x` branch.* - **\[Fix]**: Source maps may have invalid entries when using Terser minification. ([facebook/metro#928) - **\[Fix]**: Mitigate potential source map mismatches with concurrent transformations due to [terser#​1341](https://togithub.com/terser/terser/issues/1341). ([facebook/metro#929) **Full Changelog**: facebook/metro@v0.73.7...v0.73.8 ### [`v0.73.7`](https://togithub.com/facebook/metro/releases/tag/v0.73.7) [Compare Source](https://togithub.com/facebook/metro/compare/v0.73.6...v0.73.7) *This is a hotfix on the `0.73.x` branch.* - **\[Fix]** Don't attempt to use the `find` crawler on Windows (facebook/metro@3703019) ### [`v0.73.6`](https://togithub.com/facebook/metro/releases/tag/v0.73.6) [Compare Source](https://togithub.com/facebook/metro/compare/v0.73.5...v0.73.6) - **\[Fix]** Fix duplicate 'add' events, reduce dropped events on new subtrees in `NodeWatcher` (non-Watchman, non-macOS).(facebook/metro@51fb7e3) > NOTE: Experimental features are not covered by semver and can change at any time. - **\[Experimental]** `experimentalImportBundleSupport`: Move bundle path hints into serialised dependency map([facebook/metro#901) **Full Changelog:** facebook/metro@v0.73.5...v0.73.6 ### [`v0.73.5`](https://togithub.com/facebook/metro/releases/tag/v0.73.5) [Compare Source](https://togithub.com/facebook/metro/compare/v0.73.4...v0.73.5) - **\[Fix]**: Make all `getTransformOptions` result properties optional. (facebook/metro@a07c823) - **\[Fix]**: Bug that can lead to "unknown module" errors at runtime after an incremental build. (facebook/metro@b1be263) - **\[Fix]**: `metro-runtime`: Re-throw cached module errors without wrapping. (facebook/metro@032c4a1) - **\[Fix]** Bump `babel/types` dependency to `^7.20.0` for more consistent exposed AST Bump `babel/types` dependency to `^7.20.0` for more consistent exposed AST **Full Changelog**: facebook/metro@v0.73.4...v0.73.5 ### [`v0.73.4`](https://togithub.com/facebook/metro/releases/tag/v0.73.4) [Compare Source](https://togithub.com/facebook/metro/compare/v0.73.3...v0.73.4) - **\[Feature]:** Expose `watch` option in `RunServerOptions` ([facebook/metro#889 by [@​EvanBacon](https://togithub.com/EvanBacon)) - **\[Feature]:** `metro-runtime`: Emit additional context on WebSocket `'close'` events (facebook/metro@d54986c) > NOTE: Experimental features are not covered by semver and can change at any time. - **\[Experimental]**: `experimentalImportBundleSupport`: Retraverse parents of deleted async dependencies (facebook/metro@cb806d1) **Full Changelog:** facebook/metro@v0.73.3...v0.73.4 ### [`v0.73.3`](https://togithub.com/facebook/metro/releases/tag/v0.73.3) [Compare Source](https://togithub.com/facebook/metro/compare/v0.73.2...v0.73.3) - **\[Feature]**: Add configurable watcher health check that is off by default (facebook/metro@7adf468, facebook/metro@39f6e50) > NOTE: Experimental features are not covered by semver and can change at any time. - **\[Experimental]**: Move `experimentalImportBundleSupport` option from transformer to server (facebook/metro@3c0e1f7) **Full Changelog:** facebook/metro@v0.73.2...v0.73.3 ### [`v0.73.2`](https://togithub.com/facebook/metro/releases/tag/v0.73.2) [Compare Source](https://togithub.com/facebook/metro/compare/v0.73.1...v0.73.2) Maintenance release with purely internal changes. **Full Changelog:** facebook/metro@v0.73.1...v0.73.2 ### [`v0.73.1`](https://togithub.com/facebook/metro/releases/tag/v0.73.1) [Compare Source](https://togithub.com/facebook/metro/compare/v0.73.0...v0.73.1) - **\[Fix]**: Generate a unique name for each Watchman subscription. ([`3b0e78a`](https://togithub.com/facebook/metro/commit/3b0e78a76f4eea9f02e8b8464cf5b5e4549d6ac7)) > NOTE: Experimental features are not covered by semver and can change at any time. - **\[Experimental]\[Fix]**: Normalize file paths for `require.context` on Windows ([facebook/metro#876 by [@​byCedric](https://togithub.com/byCedric)) **Full Changelog:** facebook/metro@v0.73.0...v0.73.1 ### [`v0.73.0`](https://togithub.com/facebook/metro/releases/tag/v0.73.0) [Compare Source](https://togithub.com/facebook/metro/compare/v0.72.3...v0.73.0) - **\[Breaking]** Switch default minifier from `uglify-es` to `terser`. ([#​871](https://togithub.com/facebook/metro/issues/871)) - **\[Breaking]**: Increase minimum supported Node.js version to ^14.17.0. ([#​872](https://togithub.com/facebook/metro/issues/872)) - **\[Breaking]**: Drop support for old (pre-CalVer) Watchman versions. ([`422055a`](https://togithub.com/facebook/metro/commit/422055a5ccaca41edb1864ca07d4f810b3e03791)) - **\[Feature]**: Support `fsevents` watcher on Apple Silicon. ([#​875](https://togithub.com/facebook/metro/issues/875)) - **\[Feature]**: Support loading source URLs in inspector-proxy. ([`db19b06`](https://togithub.com/facebook/metro/commit/db19b06bdd6d2fbbe109e4f3be4b3af3489c1f1c)) - **\[Fix]**: Log warning on unexpected error during `metro-file-map` cache read. ([`7028b7f`](https://togithub.com/facebook/metro/commit/7028b7f51074f9ceef22258a8643d0f90de2388b)) - **\[Fix]**: Remove exponentiation operator transform from `metro-react-native-babel-preset`. ([`c2365bb`](https://togithub.com/facebook/metro/commit/c2365bb1d72a3773b31c05feab13a96afac484df)) - **\[Fix]**: Don’t check `watchman --version` if `useWatchman` is false. ([`76c9307`](https://togithub.com/facebook/metro/commit/76c9307ed61efa7794b30b4e585cc5941ed73e16)) **Full Changelog:** facebook/metro@v0.72.3...v0.73.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/dooboolab/dooboo-ui). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNjAuMCIsInVwZGF0ZWRJblZlciI6IjM0LjE2MC4wIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Changelog: [Experimental]
experimentalImportBundleSupport
: Move bundle path hints into serialised dependency mapProblem
experimentalImportBundleSupport
(D15943150 (72329d0)) originally relied on including a global map from module IDs to paths (importBundleNames
) in each bundle served by the HTTP server. This allowed a custom (and Meta-internal) implementation ofasyncRequire
to construct and fetch an HTTP URL corresponding to any given async-loadable module.The global map approach breaks Fast Refresh when new async imports are added to a module, because it turns out we never update the global map during HMR. New
import()
call sites can be added and are transformed toasyncRequire
, but the map entries they need aren't there, so they just throw at runtime.Solution
Naively, fixing this would require teaching the entire HMR pipeline (Graph, DeltaCalculator, HmrServer, HmrClient) to incrementally update the
importBundleNames
map at runtime on the client.Here we take a different approach: breaking up the
importBundleNames
map into individual maps, one for each module that contains async dependencies.asyncRequire
now has an extra argumentpaths
which holds a local map from IDs to paths. Conceptually, this is the same information thatimportBundleNames
has for the entire graph, except now it's split by "parent" module.paths
is generated by the serializer for async dependencies (only) and written to the bundle in a backwards-compatible format as part of the dependency map - which is now either an array or an object with a numeric indexer, depending on whether it has apaths
property.The HMR machinery already knows how to update dependency maps, so in particular it keeps
paths
up-to-date as part of that. No special plumbing needed! 🎉NOTE: Anyone using the (still experimental)
experimentalImportBundleSupport
API will need to update theirasyncRequire
implementation to use this new mechanism instead (cc @EvanBacon).Next steps
graph.importBundleNames
will be going away in a separate diff.asyncRequire
. The contract is between the serializer and theasyncRequire
implementation. We might want to use the term "fetch key" instead of "path", allow it to be any serializable value rather than just a string, and add acreateModuleFetchKey
API (analogous tocreateModuleIdFactory
) to control this in config.Differential Revision: D40412241