-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dev): output esbuild metafiles for bundle analysis (#6772)
- Loading branch information
Showing
5 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@remix-run/dev": minor | ||
--- | ||
|
||
Output esbuild metafiles for bundle analysis | ||
|
||
Written to server build directory (`build/` by default): | ||
- `metafile.css.json` | ||
- `metafile.js.json` (browser JS) | ||
- `metafile.server.json` (server JS) | ||
|
||
Metafiles can be uploaded to https://esbuild.github.io/analyze/ for analysis. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import type { Metafile } from "esbuild"; | ||
|
||
import type { Context } from "./context"; | ||
|
||
export let writeMetafile = ( | ||
ctx: Context, | ||
filename: string, | ||
metafile: Metafile | ||
) => { | ||
let buildDir = path.dirname(ctx.config.serverBuildPath); | ||
if (!fs.existsSync(buildDir)) { | ||
fs.mkdirSync(buildDir, { recursive: true }); | ||
} | ||
fs.writeFileSync(path.join(buildDir, filename), JSON.stringify(metafile)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters