mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-11 05:18:55 +00:00
Reorganize monorepo structure
* Move all config files to './configs' * Simplify './scripts' folder.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Creates a map of exported modules, allowing the RNW babel plugin to rewrite
|
||||
* paths only for modules it knows are exported by RNW.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const isDirectory = (source) => fs.lstatSync(source).isDirectory();
|
||||
const getDirectories = (source) =>
|
||||
fs.readdirSync(source).filter((name) => isDirectory(path.join(source, name)));
|
||||
|
||||
const packagesDir = path.join(__dirname, '../packages/');
|
||||
const exportsDir = path.join(packagesDir, 'react-native-web/src/exports');
|
||||
const moduleMapOutfile = path.join(packagesDir, 'babel-plugin-react-native-web/src/moduleMap.js');
|
||||
|
||||
const moduleMap = getDirectories(exportsDir).reduce((acc, curr) => {
|
||||
acc[curr] = true;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const data = `// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
||||
module.exports = ${JSON.stringify(moduleMap, null, 2)}`;
|
||||
|
||||
fs.writeFileSync(moduleMapOutfile, data);
|
||||
Reference in New Issue
Block a user