Problem/Motivation
One of the things that #3064854: Allow Twig templates to use front matter for metadata support made clear is that our current implementation of Twig makes a lot of assumptions; specifically around not being consumed outside of Drupal. This makes it more difficult for 3rd party software to consume Twig templates (originally intended for core/contrib) as doing so requires a specific environment and varying extensions created for use in Drupal.
Current 3rd party implementations are left to recreate/mimic said code on their own, e.g.: https://github.com/pattern-lab/plugin-drupal-twig-components
It would be nice if they could simply require a single Drupal component that allowed them to integrated more easily.
Proposed resolution
Move our current Twig environment and extensions into the \Drupal\Component\Twig
namespace; providing a way to tie into core (when it's present) or gracefully fail when it's not.
Remaining tasks
TBD
User interface changes
None
API changes
TBD
Data model changes
None
Release notes snippet
TBD