Get rid of @remove-on-publish step
Created by: gaearon
In #257, we introduced two special “annotations” that our scripts use to cut out some parts of the code at different stages: @remove-on-eject
and @remove-on-publish
.
@remove-on-eject
Code between @remove-on-eject-begin
and @remove-on-eject-end
gets cut out during ejecting. This is useful for simplifying configuration during ejection because some things become unnecessary. We also use it to strip out Facebook license headers because we don’t want them in generated code after ejecting. Here’s a few examples of how we use it: stripping comments, changing paths, simplifying configuration after ejecting.
@remove-on-publish
Code between @remove-on-publish-begin
and @remove-on-publish-end
gets cut out during publish of react-scripts
package. We use this for cutting out code we only use for local development of Create React App itself. It turns out that while @remove-on-eject
is super useful, @remove-on-publish
is not. We only use @remove-on-publish
in one place to override the paths to the template in development, and I just don’t think it’s worth it.
@remove-on-publish
Let’s get rid of In the past we used to check our parent directory to figure out if we’re inside Create React App repo or inside somebody’s node_modules
. I think we should get back to that approach. As long as that code is behind @remove-on-eject
, user won’t see it anyway.
When we get rid of @remove-on-publish
, we can make our local end-to-end flow task and release task simpler because we can remove the code that moves files into a separate “clean” folder and run both scripts right from the local project folder instead.
What needs to be done?
- Remove all
@remove-on-publish
annotations (AFAIK there’s only one). - Figure out another way to make
npm start
/npm run build
/npm test
work in the root of Create React App repo. Switching to “local development“ mode whenreact-scripts
is inside a folder namedpackages
seems reasonable to me. - Change
tasks/cra.sh
to run from the project folder and remove the copying step. Thetasks/cra.sh
script is the “local end-to-end flow” you can check by runningnpm run create-react-app ../whatever
from the repo root. It is meant for testing that CRA works locally. - Change
tasks/release.sh
to run from the project folder and remove the copying step. Thetasks/release.sh
script is what we use to publishreact-scripts
and friends to npm.
I know this is pretty involved so feel free to ask any details in this thread. The whole setup is a bit messy and has some issues so don’t be surprised if something doesn’t quite work.