MCPcopy Index your code
hub / github.com/tleunen/babel-plugin-module-resolver / mapPathString

Function mapPathString

src/mapPath.js:3–21  ·  view source on GitHub ↗
(nodePath, state)

Source from the content-addressed store, hash-verified

1import defaultResolvePath from './resolvePath';
2
3export default function mapPathString(nodePath, state) {
4 if (!state.types.isStringLiteral(nodePath)) {
5 return;
6 }
7
8 const sourcePath = nodePath.node.value;
9 const currentFile = state.file.opts.filename;
10 const resolvePath = state.normalizedOpts.customResolvePath || defaultResolvePath;
11
12 const modulePath = resolvePath(sourcePath, currentFile, state.opts);
13 if (modulePath) {
14 if (nodePath.node.pathResolved) {
15 return;
16 }
17
18 nodePath.replaceWith(state.types.stringLiteral(modulePath));
19 nodePath.node.pathResolved = true;
20 }
21}

Callers 2

transformImportFunction · 0.85
transformCallFunction · 0.85

Calls 1

resolvePathFunction · 0.70

Tested by

no test coverage detected