@vanilla-extract/integration
Advanced tools
Comparing version 0.0.0-inline-prototype-20233215256 to 0.0.0-inline-prototype-2023322105512
@@ -962,2 +962,3 @@ 'use strict'; | ||
const vanillaExtractMacroIdentifier = babel.types.identifier('css$'); | ||
const globalApis = ['createGlobalTheme', 'globalFontFace', 'globalKeyframes', 'globalLayer', 'globalStyle']; | ||
function vanillaBabelPlugin () { | ||
@@ -968,2 +969,3 @@ return { | ||
this.identifierOwners = new DefaultMap(() => new Set()); | ||
this.globalVanillaApiStatements = new Set(); | ||
this.depGraph = new DependencyGraph$1(); | ||
@@ -1052,2 +1054,11 @@ this.macroOwners = new DefaultMap(() => new Set()); | ||
} | ||
} else if (isCssFile && statement.isExpressionStatement()) { | ||
const expression = statement.node.expression; | ||
invariant__default["default"](babel.types.isCallExpression(expression), 'Can only extract call expressions at the global level in `.css.ts` files'); | ||
if (babel.types.isIdentifier(expression.callee) && | ||
// TODO: Use a list of global APIs | ||
globalApis.includes(expression.callee.name)) { | ||
statement.get('expression').replaceWith(babel.types.callExpression(vanillaExtractMacroIdentifier, [expression])); | ||
this.globalVanillaApiStatements.add(statementIndex); | ||
} | ||
} | ||
@@ -1084,2 +1095,9 @@ const opts = { | ||
for (const statementIndex of Array.from(bodyPath.keys()).reverse()) { | ||
const statement = bodyPath[statementIndex]; | ||
if (isCssFile && this.globalVanillaApiStatements.has(statementIndex)) { | ||
store.buildTimeStatements.unshift(statement.node); | ||
statement.remove(); | ||
continue; | ||
} | ||
// Should keep index if it creates/modifies an essential identifier | ||
@@ -1092,3 +1110,2 @@ // or it depends on a macro | ||
const mutatesEssentialIdentifier = hasIntersection(mutatedIdents, essentialIdentifiers); | ||
const statement = bodyPath[statementIndex]; | ||
const statementMacros = Array.from(this.macroOwners.get(statementIndex)); | ||
@@ -1095,0 +1112,0 @@ const isExportStatement = this.exportStatements.has(statementIndex); |
@@ -962,2 +962,3 @@ 'use strict'; | ||
const vanillaExtractMacroIdentifier = babel.types.identifier('css$'); | ||
const globalApis = ['createGlobalTheme', 'globalFontFace', 'globalKeyframes', 'globalLayer', 'globalStyle']; | ||
function vanillaBabelPlugin () { | ||
@@ -968,2 +969,3 @@ return { | ||
this.identifierOwners = new DefaultMap(() => new Set()); | ||
this.globalVanillaApiStatements = new Set(); | ||
this.depGraph = new DependencyGraph$1(); | ||
@@ -1052,2 +1054,11 @@ this.macroOwners = new DefaultMap(() => new Set()); | ||
} | ||
} else if (isCssFile && statement.isExpressionStatement()) { | ||
const expression = statement.node.expression; | ||
invariant__default["default"](babel.types.isCallExpression(expression), 'Can only extract call expressions at the global level in `.css.ts` files'); | ||
if (babel.types.isIdentifier(expression.callee) && | ||
// TODO: Use a list of global APIs | ||
globalApis.includes(expression.callee.name)) { | ||
statement.get('expression').replaceWith(babel.types.callExpression(vanillaExtractMacroIdentifier, [expression])); | ||
this.globalVanillaApiStatements.add(statementIndex); | ||
} | ||
} | ||
@@ -1084,2 +1095,9 @@ const opts = { | ||
for (const statementIndex of Array.from(bodyPath.keys()).reverse()) { | ||
const statement = bodyPath[statementIndex]; | ||
if (isCssFile && this.globalVanillaApiStatements.has(statementIndex)) { | ||
store.buildTimeStatements.unshift(statement.node); | ||
statement.remove(); | ||
continue; | ||
} | ||
// Should keep index if it creates/modifies an essential identifier | ||
@@ -1092,3 +1110,2 @@ // or it depends on a macro | ||
const mutatesEssentialIdentifier = hasIntersection(mutatedIdents, essentialIdentifiers); | ||
const statement = bodyPath[statementIndex]; | ||
const statementMacros = Array.from(this.macroOwners.get(statementIndex)); | ||
@@ -1095,0 +1112,0 @@ const isExportStatement = this.exportStatements.has(statementIndex); |
{ | ||
"name": "@vanilla-extract/integration", | ||
"version": "0.0.0-inline-prototype-20233215256", | ||
"version": "0.0.0-inline-prototype-2023322105512", | ||
"description": "Zero-runtime Stylesheets-in-TypeScript", | ||
@@ -23,3 +23,3 @@ "main": "dist/vanilla-extract-integration.cjs.js", | ||
"@vanilla-extract/babel-plugin-debug-ids": "^1.0.2", | ||
"@vanilla-extract/css": "^0.0.0-inline-prototype-20233215256", | ||
"@vanilla-extract/css": "^0.0.0-inline-prototype-2023322105512", | ||
"esbuild": "0.17.6", | ||
@@ -26,0 +26,0 @@ "eval": "0.1.6", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133557
3482