Skip to content

Import source code of a Component #131

Answered by meteorlxy
laruiss asked this question in Q&A
Discussion options

You must be logged in to vote

It would be listed in the Node API documentation, which is not finished yet.

In fact, the clientDynamicModules is just writing a temp file, i.e.:

clientDynamicModules: () => ({
  name: 'foo.js',
  content: 'export default {}',
})

equals to:

async onPrepared(app) {
  await app.writeTemp('foo.js', 'export default {}')
}

You can use it in client via @temp alias:

import foo from '@temp/foo'

They are literally equal, so that's the reason why we remove the clientDynamicModules hook in v2 - it's redundant.

The app.writeTemp (or called ctx.writeTemp) also exists in v1

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by meteorlxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants