-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
refactor(dev): simplify compiler #4410
Conversation
|
6e69ead
to
9867975
Compare
808c104
to
346211f
Compare
bf346af
to
1a67594
Compare
b91bdde
to
225bdea
Compare
…ports since caching is perf improvement that is purely an implementation detail. also remove export for uncached route exports since that is not used anywhere.
using string constant unions instead of enums
…ts manifest promise
since it depends on the assets manifest
also, split out compile failure logging into its own module
…o `compiler/` directory
test was hardcoded to be skipped everytime and referenced the old rollup-based compiler and old gist app
225bdea
to
f644f86
Compare
@@ -87,7 +87,7 @@ export async function createAssetsManifest( | |||
); | |||
let route = routesByFile.get(entryPointFile); | |||
invariant(route, `Cannot get route for entry point ${output.entryPoint}`); | |||
let sourceExports = await getRouteModuleExportsCached(config, route.id); | |||
let sourceExports = await getRouteModuleExports(config, route.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why aren't we using the cached one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are. I renamed getRouteModuleExportsCached
to just getRouteModuleExports
since we only ever use the cached version.
🤖 Hello there, We just published version Thanks! |
* refactor(dev): rename getRouteModuleExportsCached to getRouteModuleExports since caching is perf improvement that is purely an implementation detail. also remove export for uncached route exports since that is not used anywhere. * refactor(dev): simplify build options using string constant unions instead of enums * refactor(dev): split up browser and server builds into their own modules * refactor(dev): factor out logic for finding externals * refactor(dev): compiler interfaces for browser and server * refactor(dev): change server assets manifest plugin to accept an assets manifest promise * refactor(dev): do not compile server incrementally since it depends on the assets manifest * refactor(dev): split up build and watch into separate modules also, split out compile failure logging into its own module * refactor(dev): implement `build` function based on new remix compiler * refactor(dev): rename `BuildOptions` to `CompileOptions` and move into `compiler/` directory * refactor(dev): watch * refactor(dev): compiler index module * refactor(dev): camelCase filenames * refactor(dev): update imports and types for compiler in `commands` * test(dev): fix type errors * test(dev): remove outdated, unused test test was hardcoded to be skipped everytime and referenced the old rollup-based compiler and old gist app * refactor(dev): rename `onBuildFailure` to `onCompileFailure`
https://github.com/remix-run/remix/releases/tag/remix%401.7.0 https://github.com/remix-run/remix/releases/tag/remix%401.7.4 du -ckd1 node_modules -795648 +798524 Not much changes though I found since [1.7.5](https://github.com/remix-run/remix/releases/tag/remix%401.7.5) build started to hang when run with turbo or recursive pnpm run. Looks like in this commit some stream or connection not closed when build is finished. remix-run/remix#4410 Let's see if not fixed in newer versions and then file an issue.
https://github.com/remix-run/remix/releases/tag/remix%401.7.0 https://github.com/remix-run/remix/releases/tag/remix%401.7.4 du -ckd1 node_modules -795648 +798524 Not much changes though I found since [1.7.5](https://github.com/remix-run/remix/releases/tag/remix%401.7.5) build started to hang when run with turbo or recursive pnpm run. Looks like in this commit some stream or connection not closed when build is finished. remix-run/remix#4410 Let's see if not fixed in newer versions and then file an issue.
Refactored the compiler to be architected around
BrowserCompiler
,ServerCompiler
. Notably, each of these have acompile
function that can be called once for the initial build, but can be called again subsequently for rebuilds. This greatly simplifies the mental model for the Remix compiler and cuts down the code inwatch
. Other changes include:Previously, we used a a ref to the assets manifest promise to coordinate the browser and server builds. The ref was also reused across rebuilds. There were checks in
watch
and within theserverAssetsManifestPlugin
to make sure the ref was set before being accessed. Overall, this approach was error prone and hard to reason about. This has now been replaced with a Golang-style channel so that the browser build can explicitly communicate the assets manifest to the server build.Previously, writing the assets manifest and the server build to the file system needed to be done anywhere in the code where we built the browser and server bundles. This was easy to forget and resulted in duplication. Now, the
compile
function for the browser and server compilers managed writing the results (including the assets manifest) to the filesystem.Note that the
build
andwatch
APIs for the compiler stayed the same (with the minor exception of renamingonBuildFailure
toonCompilerFailure
).