Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vanilla-extract/esbuild-plugin

Package Overview
Dependencies
Maintainers
4
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vanilla-extract/esbuild-plugin - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

LICENSE

0

dist/declarations/src/index.d.ts

@@ -0,0 +0,0 @@ import { IdentifierOption } from '@vanilla-extract/integration';

4

dist/vanilla-extract-esbuild-plugin.cjs.dev.js

@@ -64,7 +64,7 @@ 'use strict';

});
const contents = integration.processVanillaFile({
const contents = await integration.processVanillaFile({
source,
filePath: path,
outputCss,
identOption: identifiers !== null && identifiers !== void 0 ? identifiers : build.initialOptions.minify ? 'short' : 'debug'
identOption: identifiers ?? (build.initialOptions.minify ? 'short' : 'debug')
});

@@ -71,0 +71,0 @@ return {

@@ -64,7 +64,7 @@ 'use strict';

});
const contents = integration.processVanillaFile({
const contents = await integration.processVanillaFile({
source,
filePath: path,
outputCss,
identOption: identifiers !== null && identifiers !== void 0 ? identifiers : build.initialOptions.minify ? 'short' : 'debug'
identOption: identifiers ?? (build.initialOptions.minify ? 'short' : 'debug')
});

@@ -71,0 +71,0 @@ return {

@@ -60,7 +60,7 @@ import { vanillaExtractFilescopePlugin, virtualCssFileFilter, getSourceFromVirtualCssFile, cssFileFilter, compile, processVanillaFile } from '@vanilla-extract/integration';

});
const contents = processVanillaFile({
const contents = await processVanillaFile({
source,
filePath: path,
outputCss,
identOption: identifiers !== null && identifiers !== void 0 ? identifiers : build.initialOptions.minify ? 'short' : 'debug'
identOption: identifiers ?? (build.initialOptions.minify ? 'short' : 'debug')
});

@@ -67,0 +67,0 @@ return {

{
"name": "@vanilla-extract/esbuild-plugin",
"version": "2.0.0",
"version": "2.0.1",
"description": "Zero-runtime Stylesheets-in-TypeScript",

@@ -18,3 +18,3 @@ "main": "dist/vanilla-extract-esbuild-plugin.cjs.js",

"dependencies": {
"@vanilla-extract/integration": "^1.2.0"
"@vanilla-extract/integration": "^2.0.0"
},

@@ -24,2 +24,2 @@ "devDependencies": {

}
}
}

@@ -59,3 +59,3 @@ # 🧁 vanilla-extract

> 💡 These `.css.ts` files will be evaluated at build time. None of the code in these files will be included in your final bundle. Think of it as using TypeScript as your preprocessor instead of Sass, Less, etc.
> 💡 Once you've [configured your build tooling,](#setup) these `.css.ts` files will be evaluated at build time. None of the code in these files will be included in your final bundle. Think of it as using TypeScript as your preprocessor instead of Sass, Less, etc.

@@ -78,3 +78,3 @@ **Then consume them in your markup.**

Want to work at a higher level while maximising style re-use? Check out 🍨 [Sprinkles](https://github.com/seek-oss/vanilla-extract/tree/master/packages/sprinkles), our official zero-runtime atomic CSS framework, built on top of vanilla-extract.
Want to work at a higher level while maximising style re-use? Check out 🍨 [Sprinkles](https://vanilla-extract.style/documentation/sprinkles-api), our official zero-runtime atomic CSS framework, built on top of vanilla-extract.

@@ -87,3 +87,3 @@ ---

- [Vite](#vite)
- [Snowpack](#snowpack)
- [Next.js](#nextjs)
- [Gatsby](#gatsby)

@@ -97,6 +97,6 @@ - [Test environments](#test-environments)

- [globalStyle](#globalstyle)
- [composeStyles](#composestyles)
- [createTheme](#createtheme)
- [createGlobalTheme](#createglobaltheme)
- [createThemeContract](#createthemecontract)
- [createGlobalThemeContract](#createglobalthemecontract)
- [assignVars](#assignvars)

@@ -109,2 +109,4 @@ - [createVar](#createvar)

- [globalKeyframes](#globalkeyframes)
- [Recipes API](#recipes-api)
- [recipe](#recipe)
- [Dynamic API](#dynamic-api)

@@ -129,15 +131,7 @@ - [assignInlineVars](#assigninlinevars)

```bash
npm install @vanilla-extract/css @vanilla-extract/babel-plugin @vanilla-extract/webpack-plugin
npm install @vanilla-extract/css @vanilla-extract/webpack-plugin
```
2. Add the [Babel](https://babeljs.io) plugin.
2. Add the [webpack](https://webpack.js.org) plugin.
```json
{
"plugins": ["@vanilla-extract/babel-plugin"]
}
```
3. Add the [webpack](https://webpack.js.org) plugin.
> 💡 This plugin accepts an optional [configuration object](#configuration).

@@ -188,2 +182,14 @@

3. If you'd like automatic debuggable identifiers, you can add the [Babel](https://babeljs.io) plugin.
```bash
$ npm install @vanilla-extract/babel-plugin
```
```json
{
"plugins": ["@vanilla-extract/babel-plugin"]
}
```
### esbuild

@@ -275,3 +281,3 @@

### Snowpack
### Next.js

@@ -281,6 +287,6 @@ 1. Install the dependencies.

```bash
npm install @vanilla-extract/css @vanilla-extract/snowpack-plugin
npm install @vanilla-extract/css @vanilla-extract/babel-plugin @vanilla-extract/next-plugin
```
2. Add the [Snowpack](https://www.snowpack.dev/) plugin to your snowpack config.
2. If you don't have a `next.config.js` file in the root of your project, create one. Add the [Next.js](https://nextjs.org) plugin to your `next.config.js` file.

@@ -290,10 +296,44 @@ > 💡 This plugin accepts an optional [configuration object](#configuration).

```js
// snowpack.config.json
const {
createVanillaExtractPlugin
} = require('@vanilla-extract/next-plugin');
const withVanillaExtract = createVanillaExtractPlugin();
/** @type {import('next').NextConfig} */
const nextConfig = {};
module.exports = withVanillaExtract(nextConfig);
```
If required, this plugin can be composed with other plugins.
```js
const {
createVanillaExtractPlugin
} = require('@vanilla-extract/next-plugin');
const withVanillaExtract = createVanillaExtractPlugin();
const withMDX = require('@next/mdx')({
extension: /\.mdx$/
});
/** @type {import('next').NextConfig} */
const nextConfig = {};
module.exports = withVanillaExtract(withMDX(nextConfig));
```
3. (Optional) If you want to automatically generate debug IDs during development, you can add the [Babel](https://babeljs.io) plugin. Note that this step will cause Next.js to switch from [SWC](https://github.com/swc-project/swc) to Babel, increasing build times. This may or may not be an issue depending on the size of your project.
> Note: While optional for Next.js, the Babel plugin is still required when trying to run `.css.ts` files in Node for unit testing since the files are no longer being processed by a bundler.
If you don't have a `.babelrc` file in the root of your project, create one. Add the Babel plugin to your `.babelrc` file, ensuring that you're also including `"next/babel"` in your `presets` array.
```json
{
"plugins": ["@vanilla-extract/snowpack-plugin"]
"presets": ["next/babel"],
"plugins": ["@vanilla-extract/babel-plugin"]
}
```
> Please note: There are currently no automatic readable class names during development. However, you can still manually provide a debug ID as the last argument to functions that generate scoped styles, e.g. `export const className = style({ ... }, 'className');`
### Gatsby

@@ -406,8 +446,48 @@

> 💡 To improve maintainability, each `style` block can only target a single element. To enforce this, all selectors must target the `&` character which is a reference to the current element. For example, `'&:hover:not(:active)'` is considered valid, while `'& > a'` and ``[`& ${childClass}`]`` are not.
> 💡 To improve maintainability, each style block can only target a single element. To enforce this, all selectors must target the “&” character which is a reference to the current element.
>
>If you want to target another scoped class then it should be defined within the `style` block of that class instead. For example, ``[`& ${childClass}`]`` is invalid since it targets `${childClass}`, so it should instead be defined in the `style` block for `childClass`.
> For example, `'&:hover:not(:active)'` and `` [`${parentClass} &`] `` are considered valid, while `'& a[href]'` and `` [`& ${childClass}`] `` are not.
>
>If you want to globally target child nodes within the current element (e.g. `'& > a'`), you should use [`globalStyle`](#globalstyle) instead.
> If you want to target another scoped class then it should be defined within the style block of that class instead.
>
> For example, `` [`& ${childClass}`] `` is invalid since it doesn’t target “&”, so it should instead be defined in the style block for `childClass`.
>
> If you want to globally target child nodes within the current element (e.g. `'& a[href]'`), you should use [`globalStyle`](#globalstyle) instead.
Multiple styles can be composed into a single rule by providing an array of styles.
```ts
import { style } from '@vanilla-extract/css';
const base = style({ padding: 12 });
export const primary = style([
base,
{ background: 'blue' }
]);
export const secondary = style([
base,
{ background: 'aqua' }
]);
```
When composed styles are used in selectors, they are assigned an additional class if required so they can be uniquely identified. When selectors are processed internally, the composed classes are removed, only leaving behind the unique identifier classes. This allows you to treat them as if they were a single class within vanilla-extract selectors.
```ts
import {
style,
globalStyle,
} from '@vanilla-extract/css';
const background = style({ background: 'mintcream' });
const padding = style({ padding: 12 });
export const container = style([background, padding]);
globalStyle(`${container} *`, {
boxSizing: 'border-box'
});
```
### styleVariants

@@ -428,2 +508,15 @@

Multiple styles can be composed into a single rule by providing an array of styles.
```ts
import { styleVariants } from '@vanilla-extract/css';
const base = style({ padding: 12 });
export const variant = styleVariants({
primary: [base, { background: 'blue' }],
secondary: [base, { background: 'aqua' }],
});
```
You can also transform the values by providing a map function as the second argument.

@@ -434,11 +527,13 @@

const spaceScale = {
small: 4,
medium: 8,
large: 16
};
const base = style({ padding: 12 });
export const padding = styleVariants(spaceScale, (space) => ({
padding: space
}));
const backgrounds = {
primary: 'blue',
secondary: 'aqua'
} as const;
export const variant = styleVariants(
backgrounds,
(background) => [base, { background }]
);
```

@@ -461,3 +556,3 @@

```ts
import { globalStyle } from '@vanilla-extract/css';
import { style, globalStyle } from '@vanilla-extract/css';

@@ -471,46 +566,2 @@ export const parentClass = style({});

### composeStyles
Combines multiple styles into a single class string, while also deduplicating and removing unnecessary spaces.
```ts
import { style, composeStyles } from '@vanilla-extract/css';
const button = style({
padding: 12,
borderRadius: 8
});
export const primaryButton = composeStyles(
button,
style({ background: 'coral' })
);
export const secondaryButton = composeStyles(
button,
style({ background: 'peachpuff' })
);
```
> 💡 Styles can also be provided in shallow and deeply nested arrays, similar to [classnames.](https://github.com/JedWatson/classnames)
When style compositions are used in selectors, they are assigned an additional class so they can be uniquely identified. When selectors are processed internally, the composed classes are removed, only leaving behind the unique identifier classes. This allows you to treat them as if they were a single class within vanilla-extract selectors.
```ts
import {
style,
globalStyle,
composeStyles
} from '@vanilla-extract/css';
const background = style({ background: 'mintcream' });
const padding = style({ padding: 12 });
export const container = composeStyles(background, padding);
globalStyle(`${container} *`, {
boxSizing: 'border-box'
});
```
### createTheme

@@ -701,6 +752,3 @@

import {
createGlobalThemeContract,
createGlobalTheme
} from '@vanilla-extract/css';
import { createGlobalThemeContract } from '@vanilla-extract/css';

@@ -722,6 +770,3 @@ export const vars = createGlobalThemeContract({

import {
createGlobalThemeContract,
createGlobalTheme
} from '@vanilla-extract/css';
import { createGlobalThemeContract } from '@vanilla-extract/css';

@@ -872,4 +917,4 @@ export const vars = createGlobalThemeContract({

const rotate = keyframes({
'0%': { rotate: '0deg' },
'100%': { rotate: '360deg' },
'0%': { transform: 'rotate(0deg)' },
'100%': { transform: 'rotate(360deg)' }
});

@@ -890,4 +935,4 @@

globalKeyframes('rotate', {
'0%': { rotate: '0deg' },
'100%': { rotate: '360deg' },
'0%': { transform: 'rotate(0deg)' },
'100%': { transform: 'rotate(360deg)' }
});

@@ -900,5 +945,113 @@

## Recipes API
Create multi-variant styles with a type-safe runtime API, heavily inspired by [Stitches.](https://stitches.dev)
As with the rest of vanilla-extract, all styles are generated at build time.
```bash
$ npm install @vanilla-extract/recipes
```
### recipe
Creates a multi-variant style function that can be used at runtime or statically in `.css.ts` files.
Accepts an optional set of `base` styles, `variants`, `compoundVariants` and `defaultVariants`.
```ts
import { recipe } from '@vanilla-extract/recipes';
export const button = recipe({
base: {
borderRadius: 6
},
variants: {
color: {
neutral: { background: 'whitesmoke' },
brand: { background: 'blueviolet' },
accent: { background: 'slateblue' }
},
size: {
small: { padding: 12 },
medium: { padding: 16 },
large: { padding: 24 }
},
rounded: {
true: { borderRadius: 999 }
}
},
// Applied when multiple variants are set at once
compoundVariants: [
{
variants: {
color: 'neutral',
size: 'large'
},
style: {
background: 'ghostwhite'
}
}
],
defaultVariants: {
color: 'accent',
size: 'medium'
}
});
```
With this recipe configured, you can now use it in your templates.
```ts
import { button } from './button.css.ts';
document.write(`
<button class="${button({
color: 'accent',
size: 'large',
rounded: true
})}">
Hello world
</button>
`);
```
Your recipe configuration can also make use of existing variables, classes and styles.
For example, you can pass in the result of your [`sprinkles`](https://vanilla-extract.style/documentation/sprinkles-api) function directly.
```ts
import { recipe } from '@vanilla-extract/recipes';
import { reset } from './reset.css.ts';
import { sprinkles } from './sprinkles.css.ts';
export const button = recipe({
base: [reset, sprinkles({ borderRadius: 'round' })],
variants: {
color: {
neutral: sprinkles({ background: 'neutral' }),
brand: sprinkles({ background: 'brand' }),
accent: sprinkles({ background: 'accent' })
},
size: {
small: sprinkles({ padding: 'small' }),
medium: sprinkles({ padding: 'medium' }),
large: sprinkles({ padding: 'large' })
}
},
defaultVariants: {
color: 'accent',
size: 'medium'
}
});
```
## Dynamic API
We also provide a lightweight standalone package to support dynamic runtime theming.
Dynamically update theme variables at runtime.

@@ -905,0 +1058,0 @@ ```bash

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc