fix: use stable bundle name in dev mode to avoid CDN mismatch#221
fix: use stable bundle name in dev mode to avoid CDN mismatch#221happy-edge wants to merge 4 commits into
Conversation
Problem:
When bumping package.json version, the homepage would try to load
plugin-{new-version}-app.js from CDN, but it doesn't exist yet.
This broke local development when making version changes.
Solution:
When NEXT_PUBLIC_IS_PLUGIN_DEV=true:
- Webpack outputs to plugin-dev.js (stable name)
- library.tsx loads plugin-dev.js instead of versioned file
- Local builds work regardless of package.json version
Changes:
- webpack.config.js: Use 'plugin-dev' bundle name in dev mode
- library.tsx: Same logic for runtime bundle loading
- .env: Enable dev mode by default for local development
- DEVELOPER_NOTES.md: Document the dev build workflow
|
Someone is attempting to deploy a commit to the wowcats Team on Vercel. A member of the Team first needs to authorize it. |
- Check VERCEL_ENV=preview in webpack and NEXT_PUBLIC_VERCEL_ENV in library.tsx - Add vercel.json to run build-widget:dev before Next.js build - Vercel previews now automatically load new code without manual env var setup
Instead of changing bundle names, we switch where we load from: - Dev/Preview: load from local /public (relative path) - Production: load from CDN This way: - Bundles are always versioned (plugin-1.0.14.js) - Local dev loads /public/plugin-1.0.14.js - Vercel preview loads /public/plugin-1.0.14.js - Production loads https://plugin.jup.ag/plugin-1.0.14.js
thejesh23
left a comment
There was a problem hiding this comment.
The title and PR description say webpack will output plugin-dev.js as a stable bundle name, but the diff doesn't actually change webpack.config.js — bundleName is still plugin-${packageJson.version}. The real fix here is in library.tsx: switching scriptDomain to '' (relative path) when NEXT_PUBLIC_IS_PLUGIN_DEV === 'true' or on Vercel preview, so the loader picks up whatever versioned bundle is in /public/.
That's a cleaner solution than the description suggests — worth updating the title/description so reviewers and future git-blame readers aren't hunting for a plugin-dev.js rename that doesn't exist.
Minor: === 'true' is stricter than the previous truthy check (!process.env.X); harmless here, but anyone setting the var to 1 or yes will silently get production behavior.
Problem
When bumping
package.jsonversion during development, the homepage breaks because:bundleNamebecomesplugin-{new-version}plugin-{new-version}-app.jsfrom CDNThis forced developers to either:
Solution
When
NEXT_PUBLIC_IS_PLUGIN_DEV=true:plugin-dev.js(stable name)plugin-dev.jsUsage
Changes
plugin-devbundle name when dev flag is setBackwards Compatible
Production builds (without the env var) work exactly as before.