Skip to content

Commit 42ff4c8

Browse files
Centralise esbuild options type (#720)
Co-authored-by: Michael Taranto <[email protected]>
1 parent e373b51 commit 42ff4c8

File tree

9 files changed

+42
-365
lines changed

9 files changed

+42
-365
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Want to work at a higher level while maximising style re-use? Check out 🍨 [S
8888
- [Test environments](#test-environments)
8989
- [Configuration](#configuration)
9090
- [identifiers](#identifiers)
91+
- [esbuildOptions](#esbuildoptions)
9192
- [Styling API](#styling-api)
9293
- [style](#style)
9394
- [styleVariants](#stylevariants)
@@ -396,9 +397,8 @@ Each integration will set a default value based on the configuration options pas
396397
### esbuildOptions
397398
> Only for `esbuild`, `vite` and `rollup` plugins
398399
399-
The `vite`, `esbuild` and `rollup` plugins use esbuild internally to compile `.css.ts` files before running them to extract styles. You can pass additional options here to customize that process.
400-
401-
Accepts a subset of esbuild build options (`plugins`, `external`, `define` and `loader`), see https://esbuild.github.io/api/#build-api. The options are deep merged with the default options provided by Vanilla Extract.
400+
esbuild is used internally to compile `.css.ts` files before evaluating them to extract styles. You can pass additional options here to customize that process.
401+
Accepts a subset of esbuild build options (`plugins`, `external`, `define` and `loader`), see https://esbuild.github.io/api/#build-api.
402402

403403
---
404404

packages/esbuild-plugin/src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import {
88
compile,
99
vanillaExtractFilescopePlugin,
1010
IdentifierOption,
11+
CompileOptions,
1112
} from '@vanilla-extract/integration';
12-
import type { Plugin, BuildOptions as EsbuildOptions } from 'esbuild';
13+
import type { Plugin } from 'esbuild';
1314

1415
const vanillaCssNamespace = 'vanilla-extract-css-ns';
1516

@@ -22,10 +23,7 @@ interface VanillaExtractPluginOptions {
2223
runtime?: boolean;
2324
processCss?: (css: string) => Promise<string>;
2425
identifiers?: IdentifierOption;
25-
esbuildOptions?: Pick<
26-
EsbuildOptions,
27-
'plugins' | 'external' | 'define' | 'loader'
28-
>;
26+
esbuildOptions?: CompileOptions['esbuildOptions'];
2927
}
3028
export function vanillaExtractPlugin({
3129
outputCss,

packages/integration/src/compile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const vanillaExtractFilescopePlugin = (): Plugin => ({
3535
},
3636
});
3737

38-
interface CompileOptions {
38+
export interface CompileOptions {
3939
filePath: string;
4040
cwd?: string;
4141
esbuildOptions?: Pick<

packages/integration/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ export * from './filters';
1414

1515
export type { IdentifierOption } from './processVanillaFile';
1616
export type { PackageInfo } from './packageInfo';
17+
export type { CompileOptions } from './compile';

packages/rollup-plugin/src/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@ import {
66
IdentifierOption,
77
getSourceFromVirtualCssFile,
88
virtualCssFileFilter,
9+
CompileOptions,
910
} from '@vanilla-extract/integration';
10-
import { BuildOptions as EsbuildOptions } from 'esbuild';
1111
import { posix } from 'path';
1212

1313
const { relative, normalize, dirname } = posix;
1414

1515
interface Options {
1616
identifiers?: IdentifierOption;
1717
cwd?: string;
18-
esbuildOptions?: Pick<
19-
EsbuildOptions,
20-
'plugins' | 'external' | 'define' | 'loader'
21-
>;
18+
esbuildOptions?: CompileOptions['esbuildOptions'];
2219
}
2320
export function vanillaExtractPlugin({
2421
identifiers,

packages/vite-plugin/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"postcss-load-config": "^3.1.0"
2222
},
2323
"devDependencies": {
24-
"esbuild": "^0.11.16",
2524
"vite": "^2.7.0"
2625
},
2726
"peerDependencies": {

packages/vite-plugin/src/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,16 @@ import {
1010
IdentifierOption,
1111
addFileScope,
1212
getPackageInfo,
13+
CompileOptions,
1314
} from '@vanilla-extract/integration';
1415
import { PostCSSConfigResult, resolvePostcssConfig } from './postcss';
15-
import { BuildOptions as EsbuildOptions } from 'esbuild';
1616

1717
const styleUpdateEvent = (fileId: string) =>
1818
`vanilla-extract-style-update:${fileId}`;
1919

2020
interface Options {
2121
identifiers?: IdentifierOption;
22-
esbuildOptions?: Pick<
23-
EsbuildOptions,
24-
'plugins' | 'external' | 'define' | 'loader'
25-
>;
22+
esbuildOptions?: CompileOptions['esbuildOptions'];
2623
}
2724
export function vanillaExtractPlugin({
2825
identifiers,

0 commit comments

Comments
 (0)