
Emotion Babel
coding十月 15, 20221mins
Frontend Babel
.babelrcH2
"emotion" must be the first plugin in your babel config plugins list.
bash
{"plugins": ["@emotion"]}
@emotion 会使用@emotion/babel-plugin
而之前的emotion 会使用[babel-plugin-emotion](https://www.npmjs.com/package/babel-plugin-emotion)
可能是根据plugin返回的name匹配的
bash
export default function (babel: *, options: *) {if (options.autoLabel !== undefined &&!AUTO_LABEL_VALUES.includes(options.autoLabel)) {throw new Error(`The 'autoLabel' option must be undefined, or one of the following: ${AUTO_LABEL_VALUES.map(s => `"${s}"`).join(', ')}`)}let t = babel.typesreturn {name: '@emotion',inherits: syntaxJsx,visitor: ...
但是babel官方的手册是根据包名匹配的,推测是出了包名,还有其他的规则,例如@emotion 会找@emotion/babel-plugin
bash
const EXACT_RE = /^module:/;const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
评论
新的评论
上一篇
ES idle search
ES是近实时查询,根据 refresh_interval 设置的时间间隔将数据刷新到可被搜索的段后,才能被查询到。 ES 7.2加入了 index.search.idle.after 的设置。如果 refresh_interval 没有显示设置,则默认1s刷新一次,并且如…
下一篇
Chakra-UI
Chakra-UI是我用的最好的用的UI库,没有之一。对于UI库的使用,通常来说,我们就是引入它们,然后按照既定的HTML标签和样式书写,对他们的修改或者扩展,主要是对它们主题文件中的变量的修改。而Chakra-UI,比起说是UI库,我更愿意它说是UI框架,因为它拥有极强的扩展…
