-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
feat: custom haste #11107
feat: custom haste #11107
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some (hopeful) q's.
(missing changelog entry 😀)
@@ -219,7 +229,22 @@ export default class HasteMap extends EventEmitter { | |||
private _watchers: Array<Watcher>; | |||
private _worker: WorkerInterface | null; | |||
|
|||
constructor(options: Options) { | |||
static getStatic(config: Config.ProjectConfig): HasteMapStatic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this async
so we can use import(config.haste.hasteMapModulePath)
in the future? same for create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing to async complicates some call sites such as the setup function in testWorker.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but it needs to be async in order to use ESM. so we either need to make it so now, or make it async whenever somebody wants to write these modules using ESM (such as a WASM implementation)
Codecov Report
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some nits, and missing changelog. Other than that this LGTM 👍
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
At Facebook, we want to use a completely custom implementation of the haste map. Overriding individual pieces such as hasteImplModulePath isn't enough to be achieve our goals with the custom implementation. We need many pieces of the build process overwritten: the crawlers, the format it is persisted to disk, and the module map. We also have added dependencies such as a sqlite library.
This change introduces the option to completely override the HasteMap class with a custom implementation. This involves relatively little changes to HasteMap itself, other than some new interfaces. The one added method is "getModuleMapFromJSON" inside HasteMap. This is needed because our custom implementation also overrides the ModuleMap serialization, so we need to go to/from serialized module maps in the correct format.
Test plan
An E2E test was written which overrides the HasteMap using this option. This custom implementation overrides all the pieces we need, including the ModuleMap. We can see with this that modules are able to be resolved with specific names as defined in the custom implementation. We can also see the custom module map serialization/deserialization working.