Skip to content

Commit

Permalink
fix: don't pass external modules to the manualChunks function (#5068)
Browse files Browse the repository at this point in the history
* fix: don't pass external modules to the manualChunks function

* tweak
  • Loading branch information
TrickyPi committed Jul 17, 2023
1 parent fecf0cf commit 0655bd6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 34 deletions.
9 changes: 3 additions & 6 deletions src/Bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
error,
logCannotAssignModuleToChunk,
logChunkInvalid,
logExternalModulesCannotBeIncludedInManualChunks,
logInvalidOption
} from './utils/logs';
import type { OutputBundleWithPlaceholders } from './utils/outputBundle';
Expand Down Expand Up @@ -129,12 +128,10 @@ export default class Bundle {
getModuleInfo: this.graph.getModuleInfo
};
for (const module of this.graph.modulesById.values()) {
const manualChunkAlias = getManualChunk(module.id, manualChunksApi);
if (typeof manualChunkAlias === 'string') {
if (module instanceof Module) {
if (module instanceof Module) {
const manualChunkAlias = getManualChunk(module.id, manualChunksApi);
if (typeof manualChunkAlias === 'string') {
manualChunkAliasesWithEntry.push([manualChunkAlias, module]);
} else {
return error(logExternalModulesCannotBeIncludedInManualChunks(module.id));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const text = "External modules couldn't be passed to the manualChunks.";

module.exports = defineTest({
description: text,
options: {
external: id => {
if (id.endsWith('external.js')) {
return true;
}
},
output: {
manualChunks(id) {
if (id.endsWith('external.js')) {
throw new Error(text);
}
}
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './external.js';

This file was deleted.

This file was deleted.

0 comments on commit 0655bd6

Please sign in to comment.