Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP1stack specificStack: Vite
buildlibrarybundlingpeer-dependencies
Externalize framework deps when bundling a library
A shared component library must externalize react/react-dom and their subpaths (react-dom/client, react/jsx-runtime) so the host app provides a single instance, not a bundled duplicate.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejavascript
| 1 | rollupOptions: { |
| 2 | external: ['react', 'react-dom'], // misses react-dom/client, react/jsx-runtime |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | rollupOptions: { |
| 2 | external: [/^react(\/.*)?$/, /^react-dom(\/.*)?$/], |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)