Skip to content

Commit

Permalink
Split out compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Jan 23, 2025
1 parent 5f66abb commit f1be233
Show file tree
Hide file tree
Showing 20 changed files with 109 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-flowers-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/vite-plugin': patch
---

Consume compiler API from new `@vanilla-extract/compiler` package instead of `@vanilla-extract/integration`
5 changes: 5 additions & 0 deletions .changeset/new-cameras-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/compiler': minor
---

Initial release
5 changes: 5 additions & 0 deletions .changeset/seven-drinks-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/integration': minor
---

Export `serializeVanillaModule` function
7 changes: 7 additions & 0 deletions .changeset/tiny-needles-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@vanilla-extract/integration': major
---

Remove `createCompiler` function and `Compiler` and `CreateCompilerOptions` types

BREAKING CHANGE: These APIs have been moved to the new `@vanilla-extract/compiler` package
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tsconfig.tsbuildinfo
packages/**/README.md
!packages/sprinkles/README.md
!packages/integration/README.md
!packages/compiler/README.md
test-results
.parcel-cache

Expand Down
3 changes: 3 additions & 0 deletions packages/compiler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @vanilla-extract/integration

This package is not intended for public consumption.
24 changes: 24 additions & 0 deletions packages/compiler/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@vanilla-extract/compiler",
"version": "0.0.0",
"description": "Zero-runtime Stylesheets-in-TypeScript",
"main": "dist/vanilla-extract-compiler.cjs.js",
"module": "dist/vanilla-extract-compiler.esm.js",
"types": "dist/vanilla-extract-compiler.cjs.d.ts",
"files": [
"/dist"
],
"repository": {
"type": "git",
"url": "https://github.com/vanilla-extract-css/vanilla-extract.git",
"directory": "packages/compiler"
},
"author": "SEEK",
"license": "MIT",
"dependencies": {
"@vanilla-extract/css": "workspace:^",
"@vanilla-extract/integration": "workspace:^",
"vite": "^5.0.11",
"vite-node": "^1.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import type { Adapter } from '@vanilla-extract/css';
import { transformCss } from '@vanilla-extract/css/transformCss';
import type { ModuleNode, UserConfig as ViteUserConfig } from 'vite';

import type { IdentifierOption } from './types';
import { cssFileFilter } from './filters';
import { getPackageInfo } from './packageInfo';
import { transform } from './transform';
import { normalizePath } from './addFileScope';
import {
cssFileFilter,
transform,
normalizePath,
getPackageInfo,
serializeVanillaModule,
type IdentifierOption,
} from '@vanilla-extract/integration';
import { lock } from './lock';
import { serializeVanillaModule } from './processVanillaFile';

type Css = Parameters<Adapter['appendCss']>[0];
type Composition = Parameters<Adapter['registerComposition']>[0];
Expand Down
5 changes: 5 additions & 0 deletions packages/compiler/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export {
createCompiler,
type Compiler,
type CreateCompilerOptions,
} from './compiler';
File renamed without changes.
1 change: 1 addition & 0 deletions packages/esbuild-plugin-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"author": "SEEK",
"license": "MIT",
"dependencies": {
"@vanilla-extract/compiler": "workspace:^",
"@vanilla-extract/integration": "workspace:^"
},
"peerDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions packages/esbuild-plugin-next/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { dirname } from 'path';

import {
cssFileFilter,
type CreateCompilerOptions,
createCompiler,
} from '@vanilla-extract/compiler';
import {
cssFileFilter,
vanillaExtractTransformPlugin,
IdentifierOption,
CreateCompilerOptions,
} from '@vanilla-extract/integration';
import type { Plugin } from 'esbuild';

Expand Down
4 changes: 1 addition & 3 deletions packages/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
"eval": "0.1.8",
"find-up": "^5.0.0",
"javascript-stringify": "^2.0.1",
"mlly": "^1.4.2",
"vite": "^5.0.11",
"vite-node": "^1.2.0"
"mlly": "^1.4.2"
},
"devDependencies": {
"@types/babel__core": "^7.20.5"
Expand Down
17 changes: 8 additions & 9 deletions packages/integration/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ export {
processVanillaFile,
parseFileScope,
stringifyFileScope,
serializeVanillaModule,
} from './processVanillaFile';
export { getSourceFromVirtualCssFile } from './virtualFile';
export { getPackageInfo } from './packageInfo';
export { compile, vanillaExtractTransformPlugin } from './compile';
export { createCompiler } from './compiler';
export { getPackageInfo, type PackageInfo } from './packageInfo';
export {
compile,
vanillaExtractTransformPlugin,
type CompileOptions,
} from './compile';
export { hash } from './hash';
export { addFileScope, normalizePath } from './addFileScope';
export { serializeCss, deserializeCss } from './serialize';
export { transformSync, transform } from './transform';

export * from './filters';

export { cssFileFilter, virtualCssFileFilter } from './filters';
export type { IdentifierOption } from './types';
export type { PackageInfo } from './packageInfo';
export type { CompileOptions } from './compile';
export type { Compiler, CreateCompilerOptions } from './compiler';
1 change: 1 addition & 0 deletions packages/vite-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"author": "SEEK",
"license": "MIT",
"dependencies": {
"@vanilla-extract/compiler": "workspace:^",
"@vanilla-extract/integration": "workspace:^"
},
"devDependencies": {
Expand Down
5 changes: 2 additions & 3 deletions packages/vite-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import type {
TransformResult,
UserConfig,
} from 'vite';
import { type Compiler, createCompiler } from '@vanilla-extract/compiler';
import {
cssFileFilter,
IdentifierOption,
type IdentifierOption,
getPackageInfo,
transform,
type Compiler,
createCompiler,
normalizePath,
} from '@vanilla-extract/integration';

Expand Down
30 changes: 24 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tests/compiler/compiler.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path';
import { createCompiler, normalizePath } from '@vanilla-extract/integration';
import { createCompiler } from '@vanilla-extract/compiler';
import { normalizePath } from '@vanilla-extract/integration';
import tsconfigPaths from 'vite-tsconfig-paths';

expect.addSnapshotSerializer({
Expand Down
3 changes: 2 additions & 1 deletion tests/compiler/compiler.vitest.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path';
import { describe, beforeAll, afterAll, test, expect } from 'vitest';
import { createCompiler, normalizePath } from '@vanilla-extract/integration';
import { createCompiler } from '@vanilla-extract/compiler';
import { normalizePath } from '@vanilla-extract/integration';

// Vitest has trouble with snapshots that don't contain wrapping quotes. See this regex and the functions above/below it:
// https://github.com/vitest-dev/vitest/blob/ae73f2737607a878ba589d548aa6f8ba639dc07c/packages/snapshot/src/port/inlineSnapshot.ts#L96
Expand Down
1 change: 1 addition & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "^6.4.2",
"@vanilla-extract-private/test-helpers": "workspace:*",
"@vanilla-extract/compiler": "workspace:*",
"@vanilla-extract/css": "workspace:*",
"@vanilla-extract/dynamic": "workspace:*",
"@vanilla-extract/integration": "workspace:*",
Expand Down

0 comments on commit f1be233

Please sign in to comment.