- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 27.1k
Description
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.
Let’s get rid of @remove-on-publish
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-publishannotations (AFAIK there’s only one).
- Figure out another way to make npm start/npm run build/npm testwork in the root of Create React App repo. Switching to “local development“ mode whenreact-scriptsis inside a folder namedpackagesseems reasonable to me.
- Change tasks/cra.shto run from the project folder and remove the copying step. Thetasks/cra.shscript is the “local end-to-end flow” you can check by runningnpm run create-react-app ../whateverfrom the repo root. It is meant for testing that CRA works locally.
- Change tasks/release.shto run from the project folder and remove the copying step. Thetasks/release.shscript is what we use to publishreact-scriptsand 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. 😄 If you get stuck please leave a comment and push work in progress as a PR so we can take a look at what’s failing.