Skip to content

Commit 8538d95

Browse files
committed
Fix broken webpack/next.js externals
1 parent 0e63320 commit 8538d95

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

.changeset/sunny-years-knock.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@vanilla-extract/webpack-plugin': patch
3+
'@vanilla-extract/next-plugin': patch
4+
---
5+
6+
Fixes a bug where the `externals` option was silently ignored

packages/webpack-plugin/src/compiler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import type { LoaderContext } from './types';
22
import createCompat from './compat';
33

4-
// Should be "ExternalsItem" but webpack doesn't expose it
4+
// Webpack exposes the `Externals` type which is a union of several types.
5+
// We likely intended to only accept a subset of these, but chose to use `any`.
6+
// We handle potential array inputs, but really we should be more specific about what we accept
7+
// here, or handling all types. Changing this type would be a breaking change,
8+
// so we can look at this in a future major release.
59
type Externals = any;
610

711
interface CompilationResult {
@@ -131,7 +135,7 @@ function compileVanillaSource(
131135
new ExternalsPlugin('commonjs', [
132136
'@vanilla-extract/css',
133137
'@vanilla-extract/css/fileScope',
134-
externals,
138+
...(Array.isArray(externals) ? externals : [externals]),
135139
]).apply(childCompiler);
136140

137141
let source: string;

0 commit comments

Comments
 (0)