-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ben Jervis
authored
Oct 12, 2021
1 parent
e250423
commit a9c5cb7
Showing
23 changed files
with
219 additions
and
123 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,9 @@ | ||
--- | ||
'@vanilla-extract/vite-plugin': patch | ||
--- | ||
|
||
Fix plugin for watch mode. | ||
|
||
The vite plugin previously relied on a one to one matching of resolve to load calls, and would clean up the CSS stored in memory after it was loaded. | ||
|
||
This isn't true in `--watch` mode, as the same file can be loaded on the rebuild without having to be resolved, which the plugin now handles. |
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,10 @@ | ||
--- | ||
'@vanilla-extract/css': patch | ||
--- | ||
|
||
Improve the browser runtime dev experience. | ||
|
||
The vanilla browser runtime now creates style tags containing the CSS itself, rather than injecting it directly into the CSSOM. | ||
|
||
This helps with debugability, as the generated CSS can actually be seen in the devtools. | ||
There are also some new attributes set on the style tags, making it easier to identify the source of each style. |
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,9 @@ | ||
--- | ||
'@vanilla-extract/vite-plugin': patch | ||
--- | ||
|
||
Update the "vanilla-extract" devStyleRuntime option. | ||
|
||
When using the vanilla browser runtime in vite, it now operates on a new model where a .css.js file is generated, that uses @vanilla-extract/css/injectStyles to add the css to the browser. | ||
|
||
This allows for hot reloading of styles, and makes styles a bit easier to debug at dev time (because they're actually visible). |
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,10 @@ | ||
--- | ||
'@vanilla-extract/babel-plugin': patch | ||
'@vanilla-extract/vite-plugin': patch | ||
--- | ||
|
||
Handle vite 2.6. | ||
|
||
As of vite 2.6 and greater, `?used` gets appended to css imports, which causes the file imports to be not what we expected. | ||
|
||
This caused mismatching classnames in the vite plugin, and it caused the babel plugin to not add filescopes when it should have. |
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,10 @@ | ||
--- | ||
'@vanilla-extract/vite-plugin': patch | ||
--- | ||
|
||
Automatically optimize deps. | ||
|
||
When using the new vanilla browser runtime, the new `injectStyles` dependency gets injected at runtime, so vite can't discover it ahead of time and pre-bundle it. | ||
|
||
The plugin will now add the dependency to optimizeDeps if the vanilla runtime is being used so that it's optimized up front. | ||
It also ensures that some relevant vanilla packages are externalised in SSR mode. |
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/integration': patch | ||
--- | ||
|
||
Export the fileScope functions. | ||
|
||
`stringifyFileScope` and `parseFileScope` are now exported to be used in other packages. |
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,8 @@ | ||
{ | ||
"main": "dist/vanilla-extract-css-injectStyles.cjs.js", | ||
"module": "dist/vanilla-extract-css-injectStyles.esm.js", | ||
"browser": { | ||
"./dist/vanilla-extract-css-injectStyles.cjs.js": "./dist/vanilla-extract-css-injectStyles.browser.cjs.js", | ||
"./dist/vanilla-extract-css-injectStyles.esm.js": "./dist/vanilla-extract-css-injectStyles.browser.esm.js" | ||
} | ||
} |
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,30 @@ | ||
import type { FileScope } from './types'; | ||
|
||
const stylesheets: Record<string, HTMLElement> = {}; | ||
|
||
interface InjectStylesOptions { | ||
fileScope: FileScope; | ||
css: string; | ||
} | ||
export const injectStyles = ({ fileScope, css }: InjectStylesOptions) => { | ||
const fileScopeId = fileScope.packageName | ||
? [fileScope.packageName, fileScope.filePath].join('/') | ||
: fileScope.filePath; | ||
|
||
let stylesheet = stylesheets[fileScopeId]; | ||
|
||
if (!stylesheet) { | ||
const styleEl = document.createElement('style'); | ||
|
||
if (fileScope.packageName) { | ||
styleEl.setAttribute('data-package', fileScope.packageName); | ||
} | ||
|
||
styleEl.setAttribute('data-file', fileScope.filePath); | ||
styleEl.setAttribute('type', 'text/css'); | ||
stylesheet = stylesheets[fileScopeId] = styleEl; | ||
document.head.appendChild(styleEl); | ||
} | ||
|
||
stylesheet.innerHTML = css; | ||
}; |
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
Oops, something went wrong.