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 if there is a .babelrc file before ejecting #1066 #3803

Conversation

gustavogodoi
Copy link

To verify this change:

  1. I ran the tests (yarn test).
  2. I ran the react-scripts eject in a project with .babelrc in the root (eject failed with the message).
  3. I ran the react-scripts eject in a project without .babelrc in the root and it was ejected.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

Copy link
Contributor

@gaearon gaearon left a comment

Choose a reason for hiding this comment

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

This is not enough because there might be a .babelrc higher up in the tree. There are also other ways to specify Babel config, such as package.json files up the tree.

I think we should somehow let the Babel do resolution, and complain if it found anything.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@ahmadawais
Copy link

@gaearon In a recent app that I built I chose to put .babelrc in the package.json for this very reason.

// Add Babel config.
		console.log( `  ➕  Adding ${ green( 'Babel' ) } preset.` );
		appPackage.babel = {
			presets: [
				[
					'env',
					{
						modules: false,
						targets: {
							browsers: [
								'last 2 Chrome versions',
								'last 2 Firefox versions',
								'last 2 Safari versions',
								'last 2 iOS versions',
								'last 1 Android version',
								'last 1 ChromeAndroid version',
								'ie 11',
							],
						},
					},
				],
			],
			plugins: [
				[ 'transform-object-rest-spread' ],
				[
					'transform-object-rest-spread',
					{
						useBuiltIns: true,
					},
				],
				[
					'transform-react-jsx',
					{
						pragma: 'wp.element.createElement',
					},
				],
				[
					'transform-runtime',
					{
						helpers: false,
						polyfill: false,
						regenerator: true,
					},
				],
			],
		};

		fs.writeFileSync(
			path.join( appPath, 'package.json' ),
			JSON.stringify( appPackage, null, 2 ) + '\n'
		);

@Timer Timer closed this Sep 26, 2018
@Timer Timer reopened this Sep 26, 2018
@gaearon gaearon closed this Nov 1, 2018
@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants