Dymanamic expressions in import() statement

I have an import statement with a dynamic expression in my code running on a worker:

await import(`./…/…/src/${component}`)

This results in the error:

TypeError: A dynamic import callback was not specified.

This surprised me, as this behavior is supported in Webpack (webpack docs → Module Methods → Dynamic expressions in import())

Is there any way I can make this work?

Dynamic imports are not yet supported in Workers - but should be landing in the next runtime release (or the one after that) if all goes well.

Is it working now ?

It’s working, I’m able to dynamically import modules, but since it’s using the function import instead of the keyword, it goes like this (my example):

const polk_keyring = await import('@polkadot/keyring');

The problem now is that wasm isn’t supported this way, only via import.

Is this supposed to work with non-js imports? E.g. if I await import('file.txt') and also have the [[rules]] ... type="Text" ... "**/*.txt" in my wrangler.toml, the value returned seems to be Module, is it possible to get the value as a string?