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
fix: more types #4361
fix: more types #4361
Changes from 17 commits
5cb4167
ffe2517
1db67e0
891824e
a50cde0
31e2bf4
b44b46b
58fa511
62538d5
0a584b8
6bb4195
372a8fd
9140a2e
b841c99
fe7e0c4
e331522
437e90b
7e87c36
52d4b21
8cf37cb
e75e854
488a386
9e986e6
08bec13
a96d407
196ad88
2c47163
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -549,12 +549,17 @@ export class ModuleLoader { | |
}; | ||
} | ||
|
||
private async handleExistingModule(module: Module, isEntry: boolean, isPreload: PreloadType) { | ||
private async handleExistingModule( | ||
module: Module, | ||
isEntry: boolean, | ||
isPreload: PreloadType | ||
): Promise<void> { | ||
const loadPromise = this.moduleLoadPromises.get(module)!; | ||
if (isPreload) { | ||
return isPreload === RESOLVE_DEPENDENCIES | ||
await (isPreload === RESOLVE_DEPENDENCIES | ||
? waitForDependencyResolution(loadPromise) | ||
: loadPromise; | ||
: loadPromise); | ||
return; | ||
} | ||
if (isEntry) { | ||
module.info.isEntry = true; | ||
|
@@ -564,7 +569,7 @@ export class ModuleLoader { | |
} | ||
module.implicitlyLoadedAfter.clear(); | ||
} | ||
return this.fetchModuleDependencies(module, ...(await loadPromise)); | ||
await this.fetchModuleDependencies(module, ...(await loadPromise)); | ||
} | ||
|
||
private handleResolveId( | ||
|
@@ -584,10 +589,8 @@ export class ModuleLoader { | |
moduleSideEffects: this.hasModuleSideEffects(source, true), | ||
syntheticNamedExports: false | ||
}; | ||
} else { | ||
if (resolvedId.external && resolvedId.syntheticNamedExports) { | ||
this.options.onwarn(errExternalSyntheticExports(source, importer)); | ||
} | ||
} else if (resolvedId.external && resolvedId.syntheticNamedExports) { | ||
this.options.onwarn(errExternalSyntheticExports(source, importer)); | ||
} | ||
return resolvedId; | ||
} | ||
|
@@ -715,7 +718,7 @@ function isNotAbsoluteExternal( | |
); | ||
} | ||
|
||
async function waitForDependencyResolution(loadPromise: LoadModulePromise) { | ||
async function waitForDependencyResolution(loadPromise: LoadModulePromise): Promise<void> { | ||
const [resolveStaticDependencyPromises, resolveDynamicImportPromises] = await loadPromise; | ||
return Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]); | ||
await Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid the unnecessary "await as last statement", one could also just type this as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably so (albeit probably microscopic in the grand schema of things). I believe I saw this pattern across the code base. I guess there is no "good" way to return I'll revert. |
||
} |
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.
What is the advantage of doing this? Considering performance, my understanding is that
.bind
is now more efficient as it avoids the indirection of the additional function, and these functions are "hot" in that they are called very often during the tree-shaking phase. And TypeScript should be able to handle.bind
correctly.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.
yeah, that has nothing to do with typescript. there were perf issues with
bind
(in the past), I think those have been fixed tho.it's just consistency, e.g.: https://github.com/rollup/rollup/pull/4361/files/437e90bc8e8e784d8b3667280d4890dbcfff9945#diff-bdf37a1325be24e5865c89e911c2f1125a1d857ec429afb790bde572bbe12b0fR761-R765
but I'll revert.