MCPcopy
hub / github.com/umijs/babel-plugin-import / importMethod

Method importMethod

src/Plugin.js:65–101  ·  view source on GitHub ↗
(methodName, file, pluginState)

Source from the content-addressed store, hash-verified

63 }
64
65 importMethod(methodName, file, pluginState) {
66 if (!pluginState.selectedMethods[methodName]) {
67 const { style, libraryDirectory } = this;
68 const transformedMethodName = this.camel2UnderlineComponentName // eslint-disable-line
69 ? transCamel(methodName, '_')
70 : this.camel2DashComponentName
71 ? transCamel(methodName, '-')
72 : methodName;
73 const path = winPath(
74 this.customName
75 ? this.customName(transformedMethodName, file)
76 : join(this.libraryName, libraryDirectory, transformedMethodName, this.fileName), // eslint-disable-line
77 );
78 pluginState.selectedMethods[methodName] = this.transformToDefaultImport // eslint-disable-line
79 ? addDefault(file.path, path, { nameHint: methodName })
80 : addNamed(file.path, methodName, path);
81 if (this.customStyleName) {
82 const stylePath = winPath(this.customStyleName(transformedMethodName, file));
83 addSideEffect(file.path, `${stylePath}`);
84 } else if (this.styleLibraryDirectory) {
85 const stylePath = winPath(
86 join(this.libraryName, this.styleLibraryDirectory, transformedMethodName, this.fileName),
87 );
88 addSideEffect(file.path, `${stylePath}`);
89 } else if (style === true) {
90 addSideEffect(file.path, `${path}/style`);
91 } else if (style === 'css') {
92 addSideEffect(file.path, `${path}/style/css`);
93 } else if (typeof style === 'function') {
94 const stylePath = style(path, file);
95 if (stylePath) {
96 addSideEffect(file.path, stylePath);
97 }
98 }
99 }
100 return { ...pluginState.selectedMethods[methodName] };
101 }
102
103 buildExpressionHandler(node, props, path, state) {
104 const file = (path && path.hub && path.hub.file) || (state && state.file);

Callers 4

CallExpressionMethod · 0.95
MemberExpressionMethod · 0.95

Calls 2

transCamelFunction · 0.85
winPathFunction · 0.85

Tested by

no test coverage detected