Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .changeset/sunny-years-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@vanilla-extract/webpack-plugin': patch
'@vanilla-extract/next-plugin': patch
---

Fixes a bug where the `externals` option was silently ignored
8 changes: 6 additions & 2 deletions packages/webpack-plugin/src/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { LoaderContext } from './types';
import createCompat from './compat';

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

interface CompilationResult {
Expand Down Expand Up @@ -131,7 +135,7 @@ function compileVanillaSource(
new ExternalsPlugin('commonjs', [
'@vanilla-extract/css',
'@vanilla-extract/css/fileScope',
externals,
...(Array.isArray(externals) ? externals : [externals]),
]).apply(childCompiler);

let source: string;
Expand Down
4 changes: 4 additions & 0 deletions packages/webpack-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export interface PluginOptions {
test?: RuleSetRule['test'];
identifiers?: IdentifierOption;
outputCss?: boolean;
/**
* Effectively `ExternalItem[]` from webpack. Currently typed as `any` as this type was
* previously not exposed. The `any` type will be fixed in the next major version.
*/
externals?: any;
/** @deprecated */
allowRuntime?: boolean;
Expand Down
8 changes: 8 additions & 0 deletions site/docs/integrations/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ const withVanillaExtract = createVanillaExtractPlugin({

Each integration will set a default value based on the configuration options passed to the bundler.

### externals

Effectively [`ExternalItem[]`] from webpack.
Currently typed as `any` as this type was previously not exposed.
The `any` type will be fixed in the next major version.

[`ExternalItem[]`]: https://github.com/webpack/webpack/blob/9211be0f7a04feb45e1074e6cf848a657dd82ebc/declarations/WebpackOptions.d.ts#L207-L211

### unstable_turbopack

> ⚠️  Turbopack support is experimental. Its API is unstable and may undergo breaking changes in non-major versions. Additionally, it may not handle all features supported by Next.js.
Expand Down
8 changes: 8 additions & 0 deletions site/docs/integrations/webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,11 @@ new VanillaExtractPlugin({
```

Each integration will set a default value based on the configuration options passed to the bundler.

### externals

Effectively [`ExternalItem[]`] from webpack.
Currently typed as `any` as this type was previously not exposed.
The `any` type will be fixed in the next major version.

[`ExternalItem[]`]: https://github.com/webpack/webpack/blob/9211be0f7a04feb45e1074e6cf848a657dd82ebc/declarations/WebpackOptions.d.ts#L207-L211