Skip to content
Open
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
3 changes: 2 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"allow": [
"Bash(find node_modules/.pnpm -path */start-plugin-core/dist/esm/index.d.ts)",
"Bash(find node_modules/.pnpm -path */start-plugin-core/dist/esm/*.d.ts)",
"Bash(NITRO_PRESET=cloudflare-pages pnpm build)"
"Bash(NITRO_PRESET=cloudflare-pages pnpm build)",
"Bash(timeout 12 npx wrangler pages dev .)"
]
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "lingui compile && vite build",
"build": "lingui compile && vite build && node scripts/clean-worker-statics.mjs",
"build:analyze": "ANALYZE=true lingui compile && vite build",
"serve": "vite preview",
"format": "biome format",
Expand Down
11 changes: 11 additions & 0 deletions scripts/clean-worker-statics.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { readdirSync, rmSync } from 'node:fs'
import { join } from 'node:path'

const workerDir = 'dist/_worker.js'
const keep = new Set(['index.js', 'wrangler.json', 'chunks'])

for (const entry of readdirSync(workerDir)) {
if (!keep.has(entry)) {
rmSync(join(workerDir, entry), { recursive: true, force: true })
}
}
Comment on lines +7 to +11

Choose a reason for hiding this comment

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

medium

The script currently assumes the dist/_worker.js directory exists when readdirSync is called. If the directory is not created for any reason (e.g., a preceding build step fails), the script will throw an error and cause the entire build to fail. It would be more robust to handle this case gracefully, for instance by wrapping the file operations in a try...catch block to check for an ENOENT error.

Suggested change
for (const entry of readdirSync(workerDir)) {
if (!keep.has(entry)) {
rmSync(join(workerDir, entry), { recursive: true, force: true })
}
}
try {
for (const entry of readdirSync(workerDir)) {
if (!keep.has(entry)) {
rmSync(join(workerDir, entry), { recursive: true, force: true })
}
}
} catch (error) {
if (error.code === 'ENOENT') {
console.log(`Worker directory '${workerDir}' not found, skipping cleanup.`)
} else {
throw error
}
}

3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ const config = defineConfig({
compressPublicAssets: true,
minify: true,
rollupConfig: {
output: {
inlineDynamicImports: true,
},
treeshake: {
moduleSideEffects: false,
propertyReadSideEffects: false,
Expand Down
Loading