Skip to content

Commit

Permalink
chore: enable source maps for package bundles (#7540)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars authored Sep 25, 2024
1 parent 38eca25 commit 0396ec2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/@repo/package.bundle/src/package.bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const defaultConfig: UserConfig = {
plugins: [react(), tsconfigPaths()],
build: {
emptyOutDir: true,
sourcemap: true,
lib: {
entry: {},
formats: ['es'],
Expand Down
15 changes: 13 additions & 2 deletions scripts/uploadBundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ const corePkgs = ['sanity', '@sanity/vision'] as const

const appVersion = 'v1'

const mimeTypes: Record<string, string | undefined> = {
'.mjs': 'application/javascript',
'.map': 'application/json',
}

/**
* Replaces all slashes with double underscores
*/
Expand Down Expand Up @@ -60,16 +65,22 @@ async function copyPackages() {
packageVersions.set(pkg, version)

// Convert slashes to double underscores
// Needed for `@sanity/vision`
// Needed for `@sanity/vision` and other scoped packages
const cleanDir = cleanDirName(pkg)

for await (const filePath of getFiles(`packages/${pkg}/dist`)) {
try {
const fileName = path.basename(filePath)
const ext = path.extname(fileName)
const contentType = mimeTypes[ext]
if (!contentType) {
throw new Error(`Unknown content type for file ${filePath}`)
}

const options: UploadOptions = {
destination: `modules/${appVersion}/${cleanDir}/${version}/bare/${fileName}`,
gzip: true,
contentType: 'application/javascript',
contentType,
metadata: {
// 1 year cache
cacheControl: 'public, max-age=31536000, immutable',
Expand Down

0 comments on commit 0396ec2

Please sign in to comment.