Can Facet.from work for Facets and not just StateFields?

I was curious if there was a particular reason that the .from shorthand only worked for StateFields and not for other Facets. Here’s an example of a pattern we follow in our codebase:

const MyConfigFacet = Facet.define<MyConfig>();

export const MyExternalFacet = Facet.define<MyConfig>({
  enables: (f) => [
    MyConfigFacet.compute([f], (state) => state.facet(f))
    AnotherExtensionThatReadsFromMyConfigFacet,
   ]
});

But .compute([f], (state) => state.facet(f)) feels more verbose than it needs to be (unless, of course, I’m missing a reason it has to be this way). I’m wondering if the same shorthand that is used for state fields could also work for other facets, so I could do:

const MyConfigFacet = Facet.define<MyConfig>();

export const MyExternalFacet = Facet.define<MyConfig>({
  enables: (f) => [
    MyConfigFacet.from(f),
    AnotherExtensionThatReadsFromMyConfigFacet,
   ]
});

I believe it can’t work like this today, but wondering if this change would be doable.
Thanks!

My thinking is that a facet that just mirrors another facet’s value is not a common enough thing to need a shortcut for. What is the use case you’re doing this for?

Totally fair, we have a somewhat unique use-case. We often use them in part to avoid circular imports.

If you imagine the following file structure:

///////////////
// in index.ts
import { MyViewPlugin } from './otherExtension';

export const MyExternalFacet = Facet.define<MyConfig>({
  enables: (f) => [
    MyViewPlugin,
   ]
});

///////////////
// in otherExtension.ts
import { MyExternalFacet } from '.' // circular import!

export const MyViewPlugin = ViewPlugin.define(() => {
  return {
    update: (u) => { console.log(u.state.facet(MyExternalFacet)) }
  }
})

we can (and do) work around this by having a separate “config” facet:

///////////////
// in index.ts
import { MyViewPlugin } from './otherExtension';
import { MyConfigFacet } from './config';

export const MyExternalFacet = Facet.define<MyConfig>({
  enables: (f) => [
    MyConfigFacet.compute([f], state => state.facet(f)),
    MyViewPlugin,
   ]
});

///////////////
// in config.ts
export const MyConfigFacet = Facet.define<MyConfig>();

///////////////
// in otherExtension.ts
import { MyConfigFacet } from '.' // no circular import

export const MyViewPlugin = ViewPlugin.define(() => {
  return {
    update: (u) => { console.log(u.state.facet(MyConfigFacet)) }
  }
})