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

[BundleRefPlugin] resolve imports to files too #69241

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
return BundleRefModule directly
  • Loading branch information
spalger committed Jun 16, 2020
commit 345724f728674813d2cca30c3df0006ea815888b
12 changes: 6 additions & 6 deletions packages/kbn-optimizer/src/worker/bundle_refs_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ export class BundleRefsPlugin {
const context = data.context;
const dep = data.dependencies[0];

this.resolveRef(context, dep.request).then(
(ref) => {
if (!ref) {
this.maybeReplaceImport(context, dep.request).then(
(module) => {
if (!module) {
wrappedFactory(data, callback);
} else {
callback(undefined, new BundleRefModule(ref.exportId));
callback(undefined, module);
}
},
(error) => callback(error)
Expand Down Expand Up @@ -149,7 +149,7 @@ export class BundleRefsPlugin {
* then an error is thrown. If the request does not resolve to a bundleRef then
* undefined is returned. Otherwise it returns the referenced bundleRef.
*/
private async resolveRef(context: string, request: string) {
private async maybeReplaceImport(context: string, request: string) {
// ignore imports that have loaders defined or are not relative seeming
if (request.includes('!') || !request.startsWith('.')) {
return;
Expand Down Expand Up @@ -179,7 +179,7 @@ export class BundleRefsPlugin {
for (const ref of eligibleRefs) {
const resolvedEntry = await this.cachedResolveRefEntry(ref);
if (resolved === resolvedEntry) {
return ref;
return new BundleRefModule(ref.exportId);
}
}

Expand Down