So, there are a few issues with your example:

- the two first lines are irrelevant if you don't also include the content of the imported script, because a) we have no idea what `DoSomething()` does and b) the rest doesn't use the vim9script syntax anyway,
- the use of `<unique>` makes it impossible to iterate while testing,
- the conditional check is also irrelevant.

Here is an actual *minimal reproducible example*:

    noremap <script> <Plug>DoSomething :echo 'Do something.'
    tmap <silent> <F2> <c-w><Plug>DoSomething<cr>

The problem is that your `<Plug>` mapping is defined for normal mode, visual mode, and operator-pending mode (`:help :map`) while you are trying to consume it in a terminal mode mapping. Changing it to a terminal mode mapping is an easy fix:

    tnoremap <script> <Plug>DoSomething :echo 'Do something.'

[![Do something.][1]][1]


  [1]: https://i.sstatic.net/um5gN.png