Skip to content

Commit

Permalink
Handle package.json:main correctly on eject.
Browse files Browse the repository at this point in the history
  • Loading branch information
anp committed Feb 25, 2017
1 parent 7136d6e commit 2be0609
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions react-native-scripts/src/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ If you have a .babelrc in your project, make sure to change the preset to \`reac
console.log(chalk.red(e));
}

delete pkgJson.main;

// NOTE: exponent won't work after performing a raw eject, so we should delete this
// it will be a better error message for the module to not be found than for whatever problems
// missing native modules will cause
Expand Down
9 changes: 9 additions & 0 deletions react-native-scripts/src/util/exponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ publish it there. See this StackOverflow question for more information:
process.stdin.pause();

const pkgJson = JSON.parse((await fsp.readFile(path.resolve('package.json'))).toString());

const entryPoint = `import Exponent from "exponent";
import App from "../../../../root.js";
Exponent.registerRootComponent(App);
`;
await fsp.writeFile('index.js', entryPoint);
pkgJson.main = 'index.js';

delete pkgJson.scripts.start;
delete pkgJson.scripts.build;
delete pkgJson.scripts.eject;
Expand Down

0 comments on commit 2be0609

Please sign in to comment.