-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
createCompiler
to integration package (#1030)
- Loading branch information
1 parent
45d3b86
commit 49ff399
Showing
53 changed files
with
3,445 additions
and
951 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@vanilla-extract/css': minor | ||
--- | ||
|
||
Provide current file scope as an additional argument to the adapter methods `registerClassName` and `registerComposition`. This is to allow fine-grained caching of registered class names and class compositions per file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@vanilla-extract/css': patch | ||
--- | ||
|
||
Throw when `setAdapter` is called with a falsy value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@vanilla-extract/esbuild-plugin': patch | ||
'@vanilla-extract/integration': patch | ||
'@vanilla-extract/jest-transform': patch | ||
--- | ||
|
||
Bump esbuild to v0.17.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@vanilla-extract/integration': minor | ||
--- | ||
|
||
Add `createCompiler` function for creating a compiler instance that can be re-used between builds. This is a low-level function intended for use by bundler plugins and, as such, is currently undocumented. Note that in order to use the new compiler you must also update `@vanilla-extract/css` to v1.10.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@vanilla-extract/integration': minor | ||
--- | ||
|
||
Add support for `onBeginFileScope` adapter lifecycle hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"private": true, | ||
"name": "@vanilla-extract/esbuild-plugin-next", | ||
"version": "0.0.0", | ||
"description": "Zero-runtime Stylesheets-in-TypeScript", | ||
"main": "dist/vanilla-extract-esbuild-plugin-next.cjs.js", | ||
"module": "dist/vanilla-extract-esbuild-plugin-next.esm.js", | ||
"files": [ | ||
"/dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/vanilla-extract-css/vanilla-extract.git", | ||
"directory": "packages/esbuild-plugin-next" | ||
}, | ||
"author": "SEEK", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@vanilla-extract/integration": "^6.0.2" | ||
}, | ||
"devDependencies": { | ||
"esbuild": "0.17.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { dirname } from 'path'; | ||
|
||
import { | ||
cssFileFilter, | ||
createCompiler, | ||
vanillaExtractTransformPlugin, | ||
IdentifierOption, | ||
CreateCompilerOptions, | ||
} from '@vanilla-extract/integration'; | ||
import type { Plugin } from 'esbuild'; | ||
|
||
const vanillaCssNamespace = 'vanilla-extract-css-ns'; | ||
|
||
interface VanillaExtractPluginOptions { | ||
outputCss?: boolean; | ||
runtime?: boolean; | ||
processCss?: (css: string) => Promise<string>; | ||
identifiers?: IdentifierOption; | ||
compilerVitePlugins?: CreateCompilerOptions['vitePlugins']; | ||
} | ||
export function vanillaExtractPlugin({ | ||
outputCss = true, | ||
runtime = false, | ||
processCss, | ||
identifiers: identOption, | ||
compilerVitePlugins: vitePlugins, | ||
}: VanillaExtractPluginOptions = {}): Plugin { | ||
if (runtime) { | ||
// If using runtime CSS then just apply fileScopes and debug IDs to code | ||
return vanillaExtractTransformPlugin({ identOption }); | ||
} | ||
|
||
return { | ||
name: 'vanilla-extract', | ||
async setup(build) { | ||
const root = build.initialOptions.absWorkingDir || process.cwd(); | ||
const identifiers = | ||
identOption || (build.initialOptions.minify ? 'short' : 'debug'); | ||
|
||
const compiler = createCompiler({ root, identifiers, vitePlugins }); | ||
|
||
build.onDispose(async () => { | ||
await compiler.close(); | ||
}); | ||
|
||
build.onResolve({ filter: /\.vanilla\.css/ }, (args) => { | ||
return { | ||
path: args.path, | ||
namespace: vanillaCssNamespace, | ||
}; | ||
}); | ||
|
||
build.onLoad( | ||
{ filter: /.*/, namespace: vanillaCssNamespace }, | ||
async ({ path }) => { | ||
const [rootRelativePath] = path.split('.vanilla.css'); | ||
|
||
let { css, filePath } = compiler.getCssForFile(rootRelativePath); | ||
|
||
if (typeof processCss === 'function') { | ||
css = await processCss(css); | ||
} | ||
|
||
return { | ||
contents: css, | ||
loader: 'css', | ||
resolveDir: dirname(filePath), | ||
}; | ||
}, | ||
); | ||
|
||
build.onLoad({ filter: cssFileFilter }, async ({ path }) => { | ||
const { source, watchFiles } = await compiler.processVanillaFile(path, { | ||
outputCss, | ||
}); | ||
|
||
return { | ||
contents: source, | ||
loader: 'js', | ||
watchFiles: Array.from(watchFiles), | ||
}; | ||
}); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,6 @@ | |
"@vanilla-extract/integration": "^6.0.2" | ||
}, | ||
"devDependencies": { | ||
"esbuild": "^0.16.3" | ||
"esbuild": "0.17.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.