blob: 048fe58d71e64465b036bb7d4511bf4f3f6b5a04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/**
* File defines babel prest for Linaria.
* It uses ./extract function that is an entry point for styles extraction.
* It also bypass babel options defined in Linaria config file with it's defaults (see ./utils/loadOptions).
*/
import type { ConfigAPI, TransformCaller } from '@babel/core';
import { debug } from '@linaria/logger';
import type { PluginOptions } from './utils/loadOptions';
import loadOptions from './utils/loadOptions';
export * as EvalCache from './eval-cache';
export { default as buildOptions } from './evaluators/buildOptions';
export { default as JSXElement } from './evaluators/visitors/JSXElement';
export { default as ProcessCSS } from './evaluators/visitors/ProcessCSS';
export { default as ProcessStyled } from './evaluators/visitors/ProcessStyled';
export { default as Module } from './module';
export {
default as transform,
extractCssFromAst,
shouldTransformCode,
} from './transform';
export * from './types';
export type { PluginOptions } from './utils/loadOptions';
export { default as isNode } from './utils/isNode';
export { default as getVisitorKeys } from './utils/getVisitorKeys';
export { default as peek } from './utils/peek';
export { default as slugify } from './utils/slugify';
export { default as CollectDependencies } from './visitors/CollectDependencies';
export { default as DetectStyledImportName } from './visitors/DetectStyledImportName';
export { default as GenerateClassNames } from './visitors/GenerateClassNames';
function isEnabled(caller?: TransformCaller & { evaluate?: true }) {
return caller?.name !== 'linaria' || !caller.evaluate;
}
export default function linaria(babel: ConfigAPI, options: PluginOptions) {
if (!babel.caller(isEnabled)) {
return {};
}
debug('options', JSON.stringify(options));
return {
plugins: [[require('./extract'), loadOptions(options)]],
};
}
|