Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion apps/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,33 @@ export default defineConfig(({ mode, command }) => {
? [clerkEarlyLoad(clerkKey)]
: []),
],
build: { manifest: true },
build: {
manifest: true,
rolldownOptions: {
// Eager chunks under ~2.5 MB, so each source map stays under the 10 MiB upload cap.
// `entriesAware` keeps `boot` off the app's chunks; strict order keeps module init
// order across them (without it the app throws at startup).
output: {
strictExecutionOrder: true,
codeSplitting: {
groups: [
{ name: "vendor", test: /node_modules/, maxSize: 2_500_000, entriesAware: true },
{
name: "kit",
test: /\/(packages|lib)\//,
maxSize: 2_500_000,
entriesAware: true,
},
{
name: "app",
test: /\/apps\/web\/src\//,
maxSize: 2_500_000,
entriesAware: true,
},
],
},
},
},
},
}
})
6 changes: 4 additions & 2 deletions packages/alchemy-maple/src/SourceMaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
findJsFiles,
isIndexMap,
MANIFEST_FILE,
mapsNoSources,
mapDebugId,
mapUsers,
SourceMapsManifest,
Expand Down Expand Up @@ -186,8 +187,9 @@ const hasRelease = (props: SourceMapsProps) => props.release !== undefined && pr
/** Why a map is not uploaded, or none when it is. */
const skipReason = (props: SourceMapsProps, map: PlannedMap): Option.Option<string> => {
if (map.bytes.byteLength > SOURCE_MAP_MAX_BYTES) return Option.some("it is over 10 MiB")
if (isIndexMap(new TextDecoder().decode(map.bytes)))
return Option.some("index source maps are not supported")
const text = new TextDecoder().decode(map.bytes)
if (isIndexMap(text)) return Option.some("index source maps are not supported")
if (mapsNoSources(text)) return Option.some("it maps no sources")
if (byRelease(props) && !hasRelease(props)) return Option.some('`matchBy: "release"` needs a release')
if (Option.isNone(map.debugId) && !hasRelease(props))
return Option.some("it has no debug id and no release is set")
Expand Down
6 changes: 6 additions & 0 deletions packages/alchemy-maple/test/source-maps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ describe("Maple.SourceMaps", () => {
join(root, "big/huge.js.map"),
`${Str.slice(0, -1)(map("src/huge.ts"))},"pad":"${Str.repeat(10 * 1024 * 1024)("x")}"}`,
)
// A prebuilt worker's map that lists no sources: the server refuses it, so it stays behind.
writeFileSync(join(root, "worker.js"), "w()\n")
writeFileSync(
join(root, "worker.js.map"),
JSON.stringify({ version: 3, sources: [], names: [], mappings: "" }),
)
return h.run(
Effect.gen(function* () {
// No release and no debug id: nothing can match the map, so nothing goes up.
Expand Down
14 changes: 14 additions & 0 deletions packages/sourcemaps/src/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@
onSuccess: (map) => map["sections"] !== undefined,
})

/**
* Whether a plain map has no `mappings` string or no sources, which the server refuses. A prebuilt
* worker's map can list none.
*/
export const mapsNoSources = (mapText: string): boolean =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

New no-sources skip missing from maple sourcemaps upload

F1 · Warning · maintainability

The upload rule now exists in two copies and only this PR's copy learned it. apps/cli/src/core/sourcemaps-upload.ts:174 still checks just isIndexMap, so the CLI keeps posting the elk worker's source-less map, the server's 400 becomes SourceMapUploadError, and the command exits ${n} source map upload(s) failed (apps/cli/src/commands/sourcemaps.ts:129).

Import `mapsNoSources` in `apps/cli/src/core/sourcemaps-upload.ts` and return a `skipped` outcome with the same reason beside its `isIndexMap` check, with a test case for a `sources: []` map.
🤖 Prompt to fix with an AI agent
In `packages/sourcemaps/src/inject.ts:170-178`: New no-sources skip missing from `maple sourcemaps upload`.

The upload rule now exists in two copies and only this PR's copy learned it. `apps/cli/src/core/sourcemaps-upload.ts:174` still checks just `isIndexMap`, so the CLI keeps posting the elk worker's source-less map, the server's 400 becomes `SourceMapUploadError`, and the command exits `${n} source map upload(s) failed` (`apps/cli/src/commands/sourcemaps.ts:129`).

Suggested fix: Import `mapsNoSources` in `apps/cli/src/core/sourcemaps-upload.ts` and return a `skipped` outcome with the same reason beside its `isIndexMap` check, with a test case for a `sources: []` map.

Verify the problem exists at that location before changing it, and keep the fix to those lines.

Result.match(decodeMap(mapText), {
onFailure: () => false,
onSuccess: (map) =>
map["sections"] === undefined &&
(!Predicate.isString(map["mappings"]) ||
!Arr.isArray(map["sources"]) ||
map["sources"].length === 0),
})

Check warning on line 178 in packages/sourcemaps/src/inject.ts

View check run for this annotation

Maple Review Bot / Maple / review

maintainability: New no-sources skip missing from `maple sourcemaps upload`

The upload rule now exists in two copies and only this PR's copy learned it. `apps/cli/src/core/sourcemaps-upload.ts:174` still checks just `isIndexMap`, so the CLI keeps posting the elk worker's source-less map, the server's 400 becomes `SourceMapUploadError`, and the command exits `${n} source map upload(s) failed` (`apps/cli/src/commands/sourcemaps.ts:129`).

/** A version 3 source map as a JSON object; anything else is never rewritten. */
const decodeV3Map = (mapText: string) =>
Option.filter(Result.getSuccess(decodeMap(mapText)), (map) => map["version"] === 3)
Expand Down
Loading