remix
remix copied to clipboard
🗺 make remix dev install as fast as possible
Discussed in https://github.com/remix-run/remix/discussions/4818
Originally posted by mjackson December 9, 2022 We should bundle everything we can in the production build of remix-dev. The current way it is built is not optimal and was just done so we could have something that worked.
Goals
- Speed up install times when installing remix-dev. This is particularly noticeable when installing it on the fly with
npx, i.e.npx @remix-run/dev ... - Make remix-dev releases more predictable by effectively "vendoring" everything at publish time
Deep Imports
Some folks are deep-importing from @remix-run/dev. However, when we bundle it we won't have separate files in the @remix-run/dev npm package anymore, i.e. the file structure of the @remix-run/dev package will change. Instead of separate files in the Rollup output, we'll likely have a single index.js script.
Although we do not consider this to be a breaking change (we do not support deep imports in any of our packages) we would like to make sure that users who are deep importing from @remix-run/dev have a path forward after this work ships. As far as I can tell, the main thing people are importing is loadConfig. We could expose this on the public interface of @remix-run/dev like this:
import { loadConfig } from "@remix-run/dev";
I'd love to hear from anyone else who is deep importing something from @remix-run/dev to see if we can also support them. If you are doing this, please comment in this proposal. /cc @sergiodxa @kiliman @MichaelDeBoey Are you aware of anyone who is doing this?
In addition, after we make this change we should use package.json's exports field to make our exports in @remix-run/dev explicit.
Implementation Notes
- This work should build on our existing Rollup build and not introduce a dependency on any other bundler.
/cc @jacob-ebey for feedback on this proposal 🙏
Just a thought. Instead of actually bundling with rollup, you could just use bundleDependencies in package.json: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#bundledependencies
What this does is it publishes everything in your node_modules necessary for the deps you list in that property along with the rest of your module. So you don't have to worry about resolving those deps at install time. They just come along for the download.
Just to throw it into the field of view in case it's not there already, there's https://github.com/vercel/ncc which may be helpful for the bundling aspect of this issue :+1:
Bundle dependencies had some problems as @jacob-ebey dug into it, need to explore other options, reprioritizing for now. Jacob to add notes here about what the problems were.
bundleDependencies failed for us here due to:
- building into root directory instead of package dirs
- requires node_modules installed, can't do because of the above build directories not participating in workspaces.
You can ditch express as a first step. It really does nothing. @remix-run/http would just work with both http and express servers.
