Skip to content

Commit 01bc33c

Browse files
Harrison IfeanyichukwuHarrison Ifeanyichukwu
Harrison Ifeanyichukwu
authored and
Harrison Ifeanyichukwu
committed
fix: keep all imports as externals if build format is cjs
1 parent 23be28d commit 01bc33c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/modules/Bundler.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export default class Bundler {
143143
) {
144144
exportStore.push({
145145
input: filePath,
146+
146147
output: {
147148
file: path.resolve(this.entryPath, config.outDir, newRelativePath),
148149
format: config.format,
@@ -151,13 +152,18 @@ export default class Bundler {
151152
sourcemap: config.sourcemap,
152153
globals: this.config.globals,
153154
},
155+
154156
plugins: config.uglify ? this.pluginsWithUglifier : this.plugins,
155-
external: config.externals,
156157

157-
// external: (id, parent, isResolved) => {
158-
// console.log(id);
159-
// return config.format === 'cjs';
160-
// },
158+
external: (id, parent, isResolved) => {
159+
if (config.format === 'cjs') {
160+
return true;
161+
} else if (config.externals.length > 0 && config.externals.includes(id)) {
162+
return true;
163+
} else {
164+
return false;
165+
}
166+
},
161167
watch: this.config.watch,
162168
});
163169
}

0 commit comments

Comments
 (0)