Copilot instructions
.github/instructions/rails-importmaps.instructions.mdRails Import Maps Guide
Copilot instructions
Quality
56/100
Scores the file, not the repository.Length
592 words
15 headings · 0 code blocksRepository
54
— · pushed 410 days agoLast changed
3 days ago
First indexed 3 days ago.123456# Rails Import Maps Guide78## Core Philosophy910- Eliminate JavaScript build steps while maintaining modern development practices11- Send JavaScript modules directly to the browser without bundling or transpiling12- Reference external modules using standardized module specifiers13- Embrace simplicity and developer happiness - this is the Rails Way™1415## Configuration Principles1617- Define all JavaScript dependencies in `config/importmap.rb`18- Pin external libraries to specific versions for production stability19- Use semantic versioning when pinning dependencies20- Prefer CDN URLs for popular libraries to leverage browser caching21- Vendor critical dependencies that cannot tolerate CDN failures22- Always specify `preload: true` for essential modules2324## File Organization2526- Keep all JavaScript files in the `app/javascript` directory27- Use `controllers/` subdirectory exclusively for Stimulus controllers28- Create `components/` for reusable UI JavaScript modules29- Create `utilities/` for shared helper functions30- Follow Rails naming conventions consistently3132## Naming Conventions for AI Agents3334- Name Stimulus controllers with `*_controller.js` suffix35- Use descriptive nouns for component files (`modal.js`, `dropdown.js`)36- Use action-based names for utilities (`debounce.js`, `format_currency.js`)37- Maintain consistent naming patterns across the codebase38- Document module purpose at the top of each file3940## Module Management4142- Import modules using standard ESM syntax43- Avoid polluting the global namespace44- Use named exports for better code discoverability45- Keep modules focused on a single responsibility46- Export only what needs to be public4748## Dependency Management4950- Pin to exact versions in production for stability51- Use version ranges only in development52- Regularly audit and update dependencies53- Remove unused dependencies promptly54- Document why each dependency is needed5556## Performance Optimization5758- Use `preload: true` only for critical dependencies59- Implement lazy loading for features not needed on initial load60- Leverage browser caching by using CDN URLs61- Evaluate module size before adding dependencies62- Consider vendoring large libraries that change infrequently6364## Security Best Practices6566- Pin to specific versions to prevent supply chain attacks67- Include subresource integrity hashes for CDN resources68- Validate external scripts before including them69- Use Content Security Policy headers appropriately70- Regularly update dependencies for security patches7172## Integration with Rails7374- Import Turbo and Stimulus at the application root75- Register Stimulus controllers automatically76- Use import maps for all JavaScript dependencies77- Avoid mixing import maps with other bundling solutions78- Keep initialization code in `application.js`7980## Testing Considerations8182- Test JavaScript behavior through system tests83- Use Capybara for integration testing84- Test Stimulus controllers in isolation when complex85- Ensure all imports resolve correctly86- Verify lazy-loaded modules load properly8788## Migration Strategy8990- Remove Node.js dependencies incrementally91- Convert webpack/esbuild imports to import map pins92- Delete package.json and node_modules after migration93- Update deployment scripts to remove build steps94- Verify all functionality works without bundling9596## Development Workflow9798- Run `bin/importmap` to manage dependencies99- Use `pin` command to add new libraries100- Use `unpin` command to remove libraries101- Audit pins regularly for unused dependencies102- Keep import map file organized and commented103104## Debugging Guidelines105106- Check browser console for module loading errors107- Verify all pinned URLs are accessible108- Ensure import paths match exactly109- Use browser developer tools to inspect loaded modules110- Check for version conflicts between dependencies111112## Best Practices113114- Prefer simplicity over clever abstractions115- Write modules that work without transpilation116- Use modern JavaScript features supported by target browsers117- Keep import map configuration readable and well-organized118- Document any non-obvious pinning decisions119
Also in levifig/rails-instructions
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| levifig/rails-instructions.github/instructions/rails-core.instructions.md · 54 | Copilot instructions | teststylearchtesting-strategy+5 | 68/100 | 3 days ago | |
| levifig/rails-instructions.cursor/rules/guidelines.mdc · 54 | Cursor rules | teststyletesting-strategysecurity+4 | 71/100 | 3 days ago | |
| levifig/rails-instructions.cursor/rules/rails-rules.mdc · 54 | Cursor rules | testlint-formatstylearch+9 | 84/100 | 3 days ago | |
| levifig/rails-instructions.github/copilot-instructions.md · 54 | Copilot instructions | teststyletesting-strategysecurity+4 | 71/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-api.instructions.md · 54 | Copilot instructions | testlint-formatstyletesting-strategy+7 | 67/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-background-jobs.instructions.md · 54 | Copilot instructions | teststyletesting-strategydatabase+2 | 63/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-controllers.instructions.md · 54 | Copilot instructions | teststylesecurityapi+1 | 56/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-deployment.instructions.md · 54 | Copilot instructions | setupstylesecuritydatabase+2 | 52/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-hotwire.instructions.md · 54 | Copilot instructions | teststylesecurityperformance+1 | 56/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-mobile.instructions.md · 54 | Copilot instructions | styleuiperformance | 66/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-models.instructions.md · 54 | Copilot instructions | teststylearchtypes+4 | 60/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-performance.instructions.md · 54 | Copilot instructions | teststylegitdatabase+2 | 56/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-security.instructions.md · 54 | Copilot instructions | teststylesecuritydependencies+3 | 63/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-services.instructions.md · 54 | Copilot instructions | teststylearchtesting-strategy+4 | 75/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-styling.instructions.md · 54 | Copilot instructions | styledatabaseuiperformance+3 | 59/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-testing.instructions.md · 54 | Copilot instructions | teststyletesting-strategysecurity+2 | 56/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails-views.instructions.md · 54 | Copilot instructions | teststylearchsecurity+3 | 60/100 | 3 days ago | |
| levifig/rails-instructions.github/instructions/rails.instructions.md · 54 | Copilot instructions | testlint-formatstylearch+9 | 84/100 | 3 days ago |
Diff against .github/instructions/rails-core.instructions.md Diff against .cursor/rules/guidelines.mdc Diff against .cursor/rules/rails-rules.mdc Diff against .github/copilot-instructions.md Diff against .github/instructions/rails-api.instructions.md Diff against .github/instructions/rails-background-jobs.instructions.md Diff against .github/instructions/rails-controllers.instructions.md Diff against .github/instructions/rails-deployment.instructions.md Diff against .github/instructions/rails-hotwire.instructions.md Diff against .github/instructions/rails-mobile.instructions.md Diff against .github/instructions/rails-models.instructions.md Diff against .github/instructions/rails-performance.instructions.md Diff against .github/instructions/rails-security.instructions.md Diff against .github/instructions/rails-services.instructions.md Diff against .github/instructions/rails-styling.instructions.md Diff against .github/instructions/rails-testing.instructions.md Diff against .github/instructions/rails-views.instructions.md Diff against .github/instructions/rails.instructions.md
