Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check build has happened before running bundler #2453

Merged
merged 1 commit into from
May 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions vnext/rn-cli.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,10 @@ if (fs.existsSync(path.resolve(__dirname, '../../scripts/metro-resources.js')))
config.resolver.extraNodeModules['SnapshotViewIOS'] = path.resolve(__dirname, 'Libraries/RCTTest/SnapshotViewIOS');
config.resolver.hasteImplModulePath = path.resolve(__dirname, 'jest/hasteImpl.js');

// Check that we have built our JS files before running the bundler, otherwise we'll get a harder to diagnose "Unable to resolve module" error
if (!fs.existsSync(path.resolve(__dirname, 'lib/Libraries/Components/AccessibilityInfo/AccessibilityInfo.uwp.js'))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something special about this file versus some other file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I could have picked any of the files that are produced from build.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you can tell whether a build has been done by whether a directory exists or having anything named .js or uwp.js. This is just fragile if this particular file ever is changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its true that this file could stop being produced, but its something that would be found immediately, since then you wouldn't be able to bundle anything. I don't think its worth writing code to troll through the whole directory looking looking for any .js file.

I also expect that in the future there will be other processes than just tsc that will put js files in the lib folder. -- In particular the change to support 0.61 when they get rid of hastemaps will involve other js files being in the lib folder.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine.

throw new Error(`\nThis package must be built before running the bundler. Did you mean to run "yarn build" first?\n`);
}

module.exports = config;