Skip to content

Commit

Permalink
Merge pull request #3306 from FranklyDev/master
Browse files Browse the repository at this point in the history
Update react-native symlink resolving and add support for flow
  • Loading branch information
Hypnosphi authored Mar 29, 2018
2 parents 9edbb96 + 5cb3f93 commit 01a2fe6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
"babel-plugin-transform-regenerator": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-minify": "^0.3.0",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.26.0",
"babel-runtime": "^6.26.0",
"case-sensitive-paths-webpack-plugin": "^2.1.2",
"commander": "^2.15.1",
Expand Down
20 changes: 15 additions & 5 deletions app/react-native/src/bin/storybook-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,25 @@ if (!program.skipPackager) {
roots = roots.concat(program.root.split(',').map(root => path.resolve(root)));
}


try {
const findSymlinksPaths = require('react-native/local-cli/util/findSymlinksPaths'); // eslint-disable-line global-require
symlinks = findSymlinksPaths(path.join(projectDir, 'node_modules'), [projectDir]);
// eslint-disable-next-line global-require
require("babel-register")({
"presets": ["flow"],
ignore: false,
babelrc: false});

// eslint-disable-next-line global-require
const findSymlinkedModules = require('react-native/local-cli/util/findSymlinkedModules');
symlinks = roots.reduce(
(arr, rootPath) => arr.concat(findSymlinkedModules(rootPath, roots)),
[...roots]
);
} catch (e) {
console.warn(`Unable to load findSymlinksPaths: ${e.message}`);
console.warn(`Unable to load findSymlinksPaths: ${e.message}`, e);
}

let projectRoots = (configDir === projectDir ? [configDir] : [configDir, projectDir]).concat(
let projectRoots = (configDir === projectDir ? [] : [configDir]).concat(
symlinks
);

Expand All @@ -85,7 +96,6 @@ if (!program.skipPackager) {
[
cliCommand,
`--projectRoots ${projectRoots.join(',')}`,
`--root ${roots.join(',')}`,
program.resetCache && '--reset-cache',
program.packagerPort && `--port=${program.packagerPort}`,
]
Expand Down

0 comments on commit 01a2fe6

Please sign in to comment.