Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dependent info to metafile #1694

Closed
hardfist opened this issue Oct 19, 2021 · 4 comments
Closed

add dependent info to metafile #1694

hardfist opened this issue Oct 19, 2021 · 4 comments

Comments

@hardfist
Copy link
Contributor

It seems that metafile doesn't contains dependent(A depends on B, then A is B's dependent, B is A's dependency) information about module, which is hard to use for some scenario.(for example I want to track which entryPoints import specific js file)
image

@hyrious
Copy link

hyrious commented Oct 19, 2021

This info is totally able to be calculated from the metafile, I think you can write a little script to build a dependent graph.

@hardfist
Copy link
Contributor Author

This info is totally able to be calculated from the metafile, I think you can write a little script to build a dependent graph.

of course it can be calculated, but it would be better if meta provides this info, and the calculation has come cost for large projects

@evanw
Copy link
Owner

evanw commented Oct 24, 2021

It's intentional that redundant information has to be computed. Including all combinations of redundant information forms in the metafile would make it really big and would slow down all builds. Instead, you should use the information in the metafile to compute the information you need.

I want to track which entryPoints import specific js file

Here's an example of doing that:

const inputsForEntryPoint = {}
for (const output of Object.values(meta.outputs)) {
  if (!output.entryPoint) continue
  const visited = new Set()
  const visit = input => {
    if (visited.has(input)) return
    visited.add(input)
    for (const { path } of meta.inputs[input].imports) visit(path)
  }
  for (const input in output.inputs) visit(input)
  inputsForEntryPoint[output.entryPoint] = [...visited]
}

the calculation has come cost for large projects

I tried this on a large project of mine and it only took 10ms to run. Computing this information yourself shouldn't be an issue.

Closing since this is by design.

@evanw evanw closed this as completed Oct 24, 2021
@hardfist
Copy link
Contributor Author

It seems that only js outputs has entryPoint, and css doesn't have entryPoint
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants