Conversation
| module: moduleID, | ||
| raw: await fs.readFile(moduleFilepath, { encoding: 'utf-8' }), | ||
| }; | ||
| const raw = await fs.readFile(moduleFilepath, { encoding: 'utf-8' }); |
There was a problem hiding this comment.
I'm assigning the demo source to a variable so that I can analyse it later for import statements. That way I don't have to read it twice from the file system.
| }) | ||
| .join('\n')}}; | ||
|
|
||
| export async function resolveDemoImports(requests) { |
There was a problem hiding this comment.
@Janpot From what I understood, this function will dynamically import the modules for each demo when called (presumably in the resolveImports prop, like this?).
I'm not sure what the value of the requests parameter will be when the function is called - is it the list of imports of that demo? If yes, should we also add a an export const imports = ${JSON.stringify(Array.from(demoImportedModuleIDs)};?
There was a problem hiding this comment.
This function can have two signatures. You can see here: https://jquense.github.io/jarle/#resolveImports
requests is just an array of module identifiers that jarle wants to have resolved.
You can just import that function here and pass it down to MarkdownDocs to get it in the demo component where you can directly pass it to jarle
Alternative strategy to handle demo imports from #24640
We could generate a
resolveImportsfunction that can be directly consumed byjarle. It's probably good enough to have one function for the whole docs page. alternatively we could generate one per demo, but I'm not sure how much that would confusewebpack.