-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Proposal: Additional JS pre-processing on module build #5161
Comments
Things that need to be worked out:
|
Using "raw" could be for "all" or "specific", in both cases responsibility relies on application. As out-of-the-box it is "off", applying this kind of behavior should be aware. Let's check the main goal here: for me it is ability to build packages with same kind of sources the same way. Transitive dependencies by default is probably "as is"; also could be included if required. New dependencies in this case are also on application. Usually if I use a library, like Not sure how ejecting works right now, but I suppose this could just extend configuration for modules from the config. A good question anyway. I'd not extend testing wider that app itself, usually packages have own tests which are used before releases, in own CI pipelines etc. Same for watch mode: usually you stop it before Can't say about monorepo, didn't work with it yet in a context. About public/private: I'd not care, to be honest. Plus, there already are repos with 2 kinds of export including "next", just sources etc, and you choose what suits better. Module can export ES5, but you will be able to use their sources with flat imports to make build actually better than that if you build for modern browsers only. |
I'm a monorepo user using a slight fork of react-scripts to make it sure. Here are my quick answers:
It could support the config format for the tools that manage monorepos, like lerna and yarn. For yarn these are all already listed in
I wouldn't think so. I'd treat only files underneath the explicit packages as "raw". For what it's worth, in my react-scripts fork I removed the line which only includes files underneath Curiously it works with Not sure what the right solution here is though. I understand wanting the
If we're thinking just of monorepos, I don't think this is an issue. If you're trying to find a slightly more general solution though, these questions are harder. For monorepos I think only ever sticking to the packages list would work.
If you stick with monorepos + an explicit package list this isn't a problem. You're only ever dealing with packages that you own so it's up to you to upgrade.
Not sure
I don't have enough context to answer some these other questions, but it you only support monorepos & local packages that you own with this these answers seem to have easy answers (yes, support running tests for those packages)
Yes, assume it's raw by default. Why would you want to opt out? I don't think that necessarily has to be a feature.
Not sure about this one. I don't publish mine. I would discourage publishing raw to npm for now though.
Do you need to run the watcher in older folders? Right now watching "just works" for me by using the If a "raw" dependency wants its own build step, it's probably for a different environment (where you have to compile less or more features), and I'd ignore it and say that create-react-app will always import the raw version.
This is a largely unsolved problem, so I think you should find whatever is the best for create-react-app. My only experience is with |
While I'm not able to answer every question explicitly. My approach, in a monorepo, is that the sibling packages have a While you can set constraints/policy for an internal dependency, things get dramatically complex when considering the wider ecosystem. Though this is a very important conversation to have as everyone in the greater node/babel community will need to orchestrate this transition together. It will certainly be a huge push and may need coordination between node/npm/babel and other leaders in the community. |
We actually tried that and it ended up being a bad decision (and removed in 2.0 stable). People can have monorepos but not want to compile stuff inside of them with host app setup because they might already have a different compile step for a subset of packages. And similarly, people sometimes want to get "raw" packages from a private npm registry rather than a monorepo, in which case putting them in monorepo config wouldn't work or make sense. |
It seems like in that case they could do For the case of packages from a private registry, that seems like a hard problem to solve without allowing raw packages from the public registry as well. I am very much entrenched in my view as a user of a specific setup though. I have no idea what the right path is for CRA, but I'm always happy to put forth what my setup is for feedback. |
Added a reference to #5164 (pre-processing for modules in tests) into description. |
Just a thought and question regarding this proposal. There is a definitely a use-case where people would want to create separate ES6 modules and import them (non-transpiled) into a CRA2 module (ala yarn workspaces). What is the possibility of this proposal being worked on to address this need? |
My proposal :
both type of packages are managed using workspaces |
As started in #5103, would like to propose a bit more of module processing than v2 is intended to have.
My first impression on module build was "finally, the same build for all the code!", but as I see it is not actually true, @gaearon explained that modules should be in a valid JavaScript format already.
Our use case: several projects depend on "core" package which was decided to use as a node module via git (not a git submodule for couple of reasons on convenience). Now have to build "core" project files with a separate script and Babel setup. It has some components, helpers, etc. And we want to have ability to use flat imports mainly. Components use JSX, which is not supported by module build as it figured out.
Proposal: Additional JS pre-processing on module build
Let's have couple options I see for the consideration:
Those options would probably have a better use with ability to specify this for the "list of modules/mask", or "per module".
The text was updated successfully, but these errors were encountered: