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

Detect when a source tree has been completed #2017

Closed
Mwni opened this issue Feb 15, 2022 · 6 comments
Closed

Detect when a source tree has been completed #2017

Mwni opened this issue Feb 15, 2022 · 6 comments

Comments

@Mwni
Copy link

Mwni commented Feb 15, 2022

I have the following problem:

import App from './app.js'
import Extensions from 'internal:extensions'

new App([...], Extensions)

The internal:extensions code is generated by extracing specific "custom markup" code somewhere in the app.js source tree. These snippets are then transformed, composed and injected back via the internal:extenions import.

The issue: I cannot tell when every import of the app.js tree has been resolved before resolving the extensions. I hack around this by waiting 1 second before resolving internal:extensions and hoping the app tree has resolved entirely.

Is there a way to tap into the internal workings of esbuild to know this?

@evanw
Copy link
Owner

evanw commented Feb 15, 2022

Is there a way to tap into the internal workings of esbuild to know this?

No. Even if you waited forever, the source tree won't be completed because your plugin is holding up the source tree from being completed.

@Mwni
Copy link
Author

Mwni commented Feb 15, 2022

Well that in part was my question. Technically the internal:extensions import is just one single file and does never cross anything from the app.js import, so they can be regarded as separate trees.

A other way to phrase the problem is, is it possible to make esbuild import specific namespaces last?

@Mwni
Copy link
Author

Mwni commented Feb 15, 2022

Illustration

@evanw
Copy link
Owner

evanw commented Feb 15, 2022

Not really, although you could do two builds in succession. The first one would have internal:extensions as external or empty or something, and the second one could use the list of files from the first build.

@Mwni
Copy link
Author

Mwni commented Feb 15, 2022

I was afraid of this. Nevertheless, thank you for your time and the library, Evan.

@Mwni Mwni closed this as completed Feb 15, 2022
@hyrious
Copy link

hyrious commented Feb 16, 2022

I mentioned similar request in #1902. I'm not sure how your magic module works, but my situation is I have to scan files to get enough data to make a virtual module. It turns out that I could just add an option glob to search files instead of hacking into esbuild on-load callbacks. https://github.com/hyrious/esbuild-repl/blob/main/scripts/plugins/icons.ts#L168-L168

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