Skip to content

Commit 0396ec2

Browse files
authored
chore: enable source maps for package bundles (#7540)
1 parent 38eca25 commit 0396ec2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/@repo/package.bundle/src/package.bundle.ts

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const defaultConfig: UserConfig = {
1515
plugins: [react(), tsconfigPaths()],
1616
build: {
1717
emptyOutDir: true,
18+
sourcemap: true,
1819
lib: {
1920
entry: {},
2021
formats: ['es'],

scripts/uploadBundles.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ const corePkgs = ['sanity', '@sanity/vision'] as const
1919

2020
const appVersion = 'v1'
2121

22+
const mimeTypes: Record<string, string | undefined> = {
23+
'.mjs': 'application/javascript',
24+
'.map': 'application/json',
25+
}
26+
2227
/**
2328
* Replaces all slashes with double underscores
2429
*/
@@ -60,16 +65,22 @@ async function copyPackages() {
6065
packageVersions.set(pkg, version)
6166

6267
// Convert slashes to double underscores
63-
// Needed for `@sanity/vision`
68+
// Needed for `@sanity/vision` and other scoped packages
6469
const cleanDir = cleanDirName(pkg)
6570

6671
for await (const filePath of getFiles(`packages/${pkg}/dist`)) {
6772
try {
6873
const fileName = path.basename(filePath)
74+
const ext = path.extname(fileName)
75+
const contentType = mimeTypes[ext]
76+
if (!contentType) {
77+
throw new Error(`Unknown content type for file ${filePath}`)
78+
}
79+
6980
const options: UploadOptions = {
7081
destination: `modules/${appVersion}/${cleanDir}/${version}/bare/${fileName}`,
7182
gzip: true,
72-
contentType: 'application/javascript',
83+
contentType,
7384
metadata: {
7485
// 1 year cache
7586
cacheControl: 'public, max-age=31536000, immutable',

0 commit comments

Comments
 (0)