* Gathers relevant data about a module: source code, transformed code, * dependencies, etc. This function reads and transforms the source from * scratch. We don't repeat the same work as `readCached` because we assume * call sites have called it already.
(transformOptions: TransformOptions)
| 376 | * call sites have called it already. |
| 377 | */ |
| 378 | readFresh(transformOptions: TransformOptions): Promise<ReadResult> { |
| 379 | const key = stableObjectHash(transformOptions || {}); |
| 380 | const promise = this._readPromises.get(key); |
| 381 | if (promise != null) { |
| 382 | return promise; |
| 383 | } |
| 384 | const freshPromise = Promise.resolve().then(() => { |
| 385 | const cacheProps = this._getCacheProps(transformOptions, key); |
| 386 | return new Promise((resolve, reject) => { |
| 387 | this._getAndCacheTransformedCode( |
| 388 | cacheProps, |
| 389 | (transformError, freshResult) => { |
| 390 | if (transformError) { |
| 391 | reject(transformError); |
| 392 | return; |
| 393 | } |
| 394 | invariant(freshResult != null, 'inconsistent state'); |
| 395 | resolve(this._finalizeReadResult(cacheProps.sourceCode, freshResult)); |
| 396 | }, |
| 397 | ); |
| 398 | }).then(result => { |
| 399 | this._readResultsByOptionsKey.set(key, {result, outdatedDependencies: []}); |
| 400 | return result; |
| 401 | }); |
| 402 | }); |
| 403 | this._readPromises.set(key, freshPromise); |
| 404 | return freshPromise; |
| 405 | } |
| 406 | |
| 407 | _getCacheProps(transformOptions: TransformOptions, transformOptionsKey: string) { |
| 408 | const sourceCode = this._readSourceCode(); |
no test coverage detected