react-native-web icon indicating copy to clipboard operation
react-native-web copied to clipboard

babel-plugin add custom module map.

Open sLin90 opened this issue 7 years ago • 1 comments

I want to add a custom module map babel config. Easy to extend custom components or apis

const getDistLocation = (importName, opts) => {
  const format = isCommonJS(opts) ? 'cjs/' : '';
  if (importName === 'index') {
    return `react-native-web/dist/${format}index`;
  } else if (opts.customMap && opts.customMap[importName]){
    return opts.customMap[importName];
  } else if (importName && moduleMap[importName]) {
    return `react-native-web/dist/${format}exports/${importName}`;
  }
};

sLin90 avatar Dec 18 '18 09:12 sLin90

Using babel to add arbitrary modules to the imports is not something I plan to support at this stage. It introduces too much fragility. You can do this in user-land if you must

necolas avatar Dec 20 '18 17:12 necolas