@mattsjones/css-babel-plugin
Advanced tools
Comparing version 0.0.6 to 0.0.7
# @mattsjones/css-babel-plugin | ||
## 0.0.7 | ||
### Patch Changes | ||
- bf2f380: Add debug ID to `createVar` calls, detect global style calls | ||
## 0.0.6 | ||
@@ -4,0 +10,0 @@ |
import { PluginObj, PluginPass } from '@babel/core'; | ||
declare const exportConfig: { | ||
style: { | ||
maxParams: number; | ||
}; | ||
createTheme: { | ||
maxParams: number; | ||
}; | ||
mapToStyles: { | ||
maxParams: number; | ||
}; | ||
fontFace: { | ||
maxParams: number; | ||
}; | ||
keyframes: { | ||
maxParams: number; | ||
}; | ||
}; | ||
declare type RelevantExport = keyof typeof exportConfig; | ||
declare const styleFunctions: string[]; | ||
declare type StyleFunction = typeof styleFunctions[number]; | ||
interface PluginOptions { | ||
@@ -27,3 +11,3 @@ alias?: string; | ||
namespaceImport: string; | ||
importIdentifiers: Map<string, RelevantExport>; | ||
importIdentifiers: Map<string, StyleFunction>; | ||
packageIdentifier: string; | ||
@@ -30,0 +14,0 @@ fileScope: string; |
@@ -17,3 +17,3 @@ 'use strict'; | ||
`); | ||
const exportConfig = { | ||
const debuggableFunctionConfig = { | ||
style: { | ||
@@ -33,5 +33,8 @@ maxParams: 2 | ||
maxParams: 2 | ||
}, | ||
createVar: { | ||
maxParams: 1 | ||
} | ||
}; | ||
const relevantExports = Object.keys(exportConfig); | ||
const styleFunctions = [...Object.keys(debuggableFunctionConfig), 'globalStyle', 'createGlobalTheme', 'createThemeVars', 'globalFontFace', 'globalKeyframes']; | ||
@@ -83,3 +86,3 @@ const extractName = node => { | ||
})) { | ||
return relevantExports.find(exportName => core.types.isIdentifier(callee.property, { | ||
return styleFunctions.find(exportName => core.types.isIdentifier(callee.property, { | ||
name: exportName | ||
@@ -150,3 +153,3 @@ })); | ||
if (relevantExports.includes(importName)) { | ||
if (styleFunctions.includes(importName)) { | ||
this.importIdentifiers.set(local.name, importName); | ||
@@ -165,4 +168,4 @@ } | ||
if (usedExport) { | ||
if (node.arguments.length < exportConfig[usedExport].maxParams) { | ||
if (usedExport && usedExport in debuggableFunctionConfig) { | ||
if (node.arguments.length < debuggableFunctionConfig[usedExport].maxParams) { | ||
const debugIdent = getDebugId(path); | ||
@@ -169,0 +172,0 @@ |
@@ -17,3 +17,3 @@ 'use strict'; | ||
`); | ||
const exportConfig = { | ||
const debuggableFunctionConfig = { | ||
style: { | ||
@@ -33,5 +33,8 @@ maxParams: 2 | ||
maxParams: 2 | ||
}, | ||
createVar: { | ||
maxParams: 1 | ||
} | ||
}; | ||
const relevantExports = Object.keys(exportConfig); | ||
const styleFunctions = [...Object.keys(debuggableFunctionConfig), 'globalStyle', 'createGlobalTheme', 'createThemeVars', 'globalFontFace', 'globalKeyframes']; | ||
@@ -83,3 +86,3 @@ const extractName = node => { | ||
})) { | ||
return relevantExports.find(exportName => core.types.isIdentifier(callee.property, { | ||
return styleFunctions.find(exportName => core.types.isIdentifier(callee.property, { | ||
name: exportName | ||
@@ -150,3 +153,3 @@ })); | ||
if (relevantExports.includes(importName)) { | ||
if (styleFunctions.includes(importName)) { | ||
this.importIdentifiers.set(local.name, importName); | ||
@@ -165,4 +168,4 @@ } | ||
if (usedExport) { | ||
if (node.arguments.length < exportConfig[usedExport].maxParams) { | ||
if (usedExport && usedExport in debuggableFunctionConfig) { | ||
if (node.arguments.length < debuggableFunctionConfig[usedExport].maxParams) { | ||
const debugIdent = getDebugId(path); | ||
@@ -169,0 +172,0 @@ |
@@ -9,3 +9,3 @@ import { relative } from 'path'; | ||
`); | ||
const exportConfig = { | ||
const debuggableFunctionConfig = { | ||
style: { | ||
@@ -25,5 +25,8 @@ maxParams: 2 | ||
maxParams: 2 | ||
}, | ||
createVar: { | ||
maxParams: 1 | ||
} | ||
}; | ||
const relevantExports = Object.keys(exportConfig); | ||
const styleFunctions = [...Object.keys(debuggableFunctionConfig), 'globalStyle', 'createGlobalTheme', 'createThemeVars', 'globalFontFace', 'globalKeyframes']; | ||
@@ -75,3 +78,3 @@ const extractName = node => { | ||
})) { | ||
return relevantExports.find(exportName => types.isIdentifier(callee.property, { | ||
return styleFunctions.find(exportName => types.isIdentifier(callee.property, { | ||
name: exportName | ||
@@ -142,3 +145,3 @@ })); | ||
if (relevantExports.includes(importName)) { | ||
if (styleFunctions.includes(importName)) { | ||
this.importIdentifiers.set(local.name, importName); | ||
@@ -157,4 +160,4 @@ } | ||
if (usedExport) { | ||
if (node.arguments.length < exportConfig[usedExport].maxParams) { | ||
if (usedExport && usedExport in debuggableFunctionConfig) { | ||
if (node.arguments.length < debuggableFunctionConfig[usedExport].maxParams) { | ||
const debugIdent = getDebugId(path); | ||
@@ -161,0 +164,0 @@ |
{ | ||
"name": "@mattsjones/css-babel-plugin", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"main": "dist/mattsjones-css-babel-plugin.cjs.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/mattsjones-css-babel-plugin.esm.js", |
17167
473