barthy-koeln/browserslist-check-bundle
.browserslistrc parsing.encore config) but could theoretically adapt to other build tools (e.g., Vite) with minor adjustments.browserslist_check) and a PHP service (BrowserslistCheckService) for runtime checks. Minimal invasive changes to existing codebase..browserslistrc (a standard in frontend tooling), reducing custom configuration overhead..browserslistrc at compile-time (Symfony cache), avoiding runtime parsing overhead..browserslistrc? Default to modern/legacy?.browserslistrc with [modern] and [legacy] sections (follow package’s constraints).// webpack.config.js
Encore
.setOutputPath('public/build/modern')
.addEntry('modern', './assets/modern.js')
.enableSingleRuntimeChunk()
// ... modern config
.configureBabel(() => { /* modern babel config */ })
.configureBabelPresetEnv({ useBuiltIns: 'usage', corejs: 3 });
Encore.createSharedConfig('legacy')
.setOutputPath('public/build/legacy')
.addEntry('legacy', './assets/legacy.js')
.configureBabelPresetEnv({ useBuiltIns: 'entry', corejs: 3 });
composer require barthy-koeln/browserslist-check-bundle
config/bundles.php:
return [
// ...
BarthyKoeln\BrowserslistCheckBundle\BrowserslistCheckBundle::class => ['all' => true],
];
.browserslistrc is in the project root (or configured in config/packages/browserslist_check.yaml)..browserslistrc:
[modern]
Chrome >= 97
Firefox >= 91
Safari >= 15.4
Edge >= 97
[legacy]
defaults
ie 11
Safari >= 10
{# templates/base.html.twig #}
{% if browserslist_check('modern') %}
<script src="{{ asset('build/modern/js/app.js') }}"></script>
{% else %}
<script src="{{ asset('build/legacy/js/app.js') }}"></script>
{% endif %}
use BarthyKoeln\BrowserslistCheckBundle\Service\BrowserslistCheckService;
class SomeController {
public function __construct(private BrowserslistCheckService $checker) {}
public function index() {
$isModern = $this->checker->isModern();
// ...
}
}
cache:clear is part of deployments..browserslistrc updates require cache rebuilds (php bin/console cache:clear).donatj/PhpUserAgent (UA parsing library) for accuracy improvements..browserslistrc updates.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| UA parsing fails | All users served default build | Fallback to modern/legacy based on IP/headers. |
.browserslistrc syntax error |
Bundle fails to load | Validate config during CI/CD. |
| Symfony cache corruption | Stale UA rules | Clear |
How can I help you explore Laravel packages today?