Agent skill
troubleshooting-bundler-compatibility
Diagnose and fix third-party library loading failures in Vite, Webpack, or other bundlers. Use when encountering "Failed to fetch dynamically imported module", worker loading failures, CDN 404 errors, "Invalid type" errors when importing library assets, or assets loading in wrong format. Covers version mismatches, worker loading patterns, and bundler-specific solutions.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/troubleshooting-bundler-compatibility
SKILL.md
Troubleshooting Bundler Compatibility Issues
Systematic approach for diagnosing library compatibility issues with modern bundlers.
Diagnostic Checklist
1. Version Verification
- Check installed npm version vs CDN availability (CDNs often lag behind npm)
- Use Context7 to get latest library documentation
- Check library changelog for breaking changes in asset loading
2. Identify Asset Type
- What does the library need: worker, wasm, static asset, CSS?
- Expected format: URL string, blob, or module import?
- ES module vs CommonJS vs raw text?
3. Bundler Investigation
Vite:
?urlsuffix returns URL reference, not content?rawsuffix imports as text string- Check
publicDirin vite.config.js - Verify asset not treated as ES module incorrectly
Webpack:
- Check loader configuration for asset type
- Verify
asset/resourcevsasset/sourcehandling
Solution Patterns
Pattern A: Blob URL (Most Reliable for Workers)
const workerCode = await import("library/worker.js?raw");
const blob = new Blob([workerCode.default], { type: "application/javascript" });
const workerUrl = URL.createObjectURL(blob);
library.workerSrc = workerUrl;
Pattern B: Public Directory
// Copy asset to public/ folder, reference with absolute path
library.assetSrc = "/asset-file.js";
Pattern C: CDN with Verified Version
// MUST verify version exists on CDN first
const cdnUrl = `https://cdn.example.com/library/${VERIFIED_VERSION}/asset.js`;
Common Pitfalls
- npm version != CDN version - npm releases faster than CDN updates
- Protocol-relative URLs -
//cdn.example.comcan resolve tohttp: - ?url misconception - Returns URL to bundled asset, not the content itself
- ES module workers - Some workers must load as classic scripts
- MIME type issues - Blob URLs need correct MIME type
Validation
After applying fix:
- Test in dev mode (
npm run dev) - Test in production build (
npm run build && npm run preview) - Verify no console errors
- Test actual functionality
- Check network tab for failed requests
Documentation
After resolving, log in ConPort:
- Root cause (e.g., "npm version not on CDN")
- Solution applied (e.g., "blob URL pattern")
- Why other approaches failed
- Create system pattern if reusable
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?