getAdjustImportVisitor = (filePath, packageDir, importMap) => ({
  // @ts-ignore
  enter({ node }) {
    const isImportNode = isImportDeclaration(node);
    if (!isImportNode) {
      return;
    }
    // @ts-ignore
    const { source } = node;
    const initialSource = source?.value;
    if (!initialSource) {
      return;
    }
    const fileDir = path.dirname(filePath);
    // @ts-ignore
    const { pattern, replacement } = getMatchingPatternAndReplacement(
      initialSource,
      fileDir,
      packageDir,
      importMap,
    );
    if (pattern === replacement) {
      return;
    }
    const adjustedSource = initialSource.replace(pattern, replacement);
    try {
      const require = createRequire(import.meta.url);
      require.resolve(adjustedSource, { paths: [fileDir] });
    } catch (error) {
      throw new Error(ERROR_CAN_NOT_RESOLVE_SOURCE);
    }
    // register the new source value
    source.value = adjustedSource;
  },
})
Adjusts the source value of an import declaration.
  Example: `import sth from source;`
The new source value is calculated with respect to `imports` defined in package.json
And checked to be resolvable with Node.js require.resolve

https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md#visitors
@param {string} filePath
@param {string} packageDir
@param {object} importMap
@throws ERROR_ADJUSTED_SOURCE_IS_INVALID