@nozbe/zacs
Advanced tools
Comparing version 1.1.0-11 to 1.1.0-12
{ | ||
"name": "@nozbe/zacs", | ||
"version": "1.1.0-11", | ||
"version": "1.1.0-12", | ||
"description": "Zero Abstraction Cost Styling (for React DOM and React Native)", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -985,29 +985,47 @@ /* eslint-disable no-use-before-define */ | ||
visitor: { | ||
VariableDeclarator(path, state) { | ||
if (!isZacsDeclaration(t, path.node)) { | ||
return | ||
} | ||
VariableDeclarator: { | ||
enter(path, state) { | ||
if (!isZacsDeclaration(t, path.node)) { | ||
return | ||
} | ||
validateZacsDeclaration(t, path) | ||
validateZacsDeclaration(t, path) | ||
const { node } = path | ||
const { init } = node | ||
const zacsMethod = init.callee.property.name | ||
const { node } = path | ||
const { init } = node | ||
const zacsMethod = init.callee.property.name | ||
if (zacsMethod === '_experimentalStyleSheet') { | ||
transformStyleSheet(t, state, path) | ||
} else if (zacsMethod.startsWith('create')) { | ||
node.init = createZacsComponent(t, state, path) | ||
} else { | ||
const id = node.id.name | ||
const stateKey = componentKey(id) | ||
if (state.get(stateKey)) { | ||
throw path.buildCodeFrameError(`Duplicate ZACS declaration for name: ${id}`) | ||
if (zacsMethod === '_experimentalStyleSheet') { | ||
// do nothing, will process on exit | ||
// eslint-disable-next-line no-useless-return | ||
return | ||
} else if (zacsMethod.startsWith('create')) { | ||
node.init = createZacsComponent(t, state, path) | ||
} else { | ||
const id = node.id.name | ||
const stateKey = componentKey(id) | ||
if (state.get(stateKey)) { | ||
throw path.buildCodeFrameError(`Duplicate ZACS declaration for name: ${id}`) | ||
} | ||
state.set(stateKey, node) | ||
if (!state.opts.keepDeclarations) { | ||
path.remove() | ||
} | ||
} | ||
state.set(stateKey, node) | ||
}, | ||
// StyleSheets must be processed on exit so that other babel plugins that transform | ||
// inline expressions into literals can do their work first | ||
// TODO: Deduplicate | ||
exit(path, state) { | ||
if (!isZacsDeclaration(t, path.node)) { | ||
return | ||
} | ||
if (!state.opts.keepDeclarations) { | ||
path.remove() | ||
const zacsMethod = path.node.init.callee.property.name | ||
if (zacsMethod !== '_experimentalStyleSheet') { | ||
return | ||
} | ||
} | ||
transformStyleSheet(t, state, path) | ||
}, | ||
}, | ||
@@ -1014,0 +1032,0 @@ JSXElement(path, state) { |
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
83164
1418