Skip to content

Lazily load library #572

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

Closed
willemneal opened this issue Apr 10, 2019 · 4 comments
Closed

Lazily load library #572

willemneal opened this issue Apr 10, 2019 · 4 comments
Labels

Comments

@willemneal
Copy link
Contributor

Currently when adding libraries, each file found in the library paths is parsed. However, this should be done when a file is referenced. I ran into this problem because the compiler I'm writing for wasmos finds all **/assembly folders in a projects node_modules and adds it as a library path.

@dcodeIO
Copy link
Member

dcodeIO commented Apr 10, 2019

One reason for this is that there could be @global elements in a library file that would be missed otherwise.. Not too happy with this mechanism myself, though.

Related: #448

@willemneal
Copy link
Contributor Author

So we could have that each globals.d.ts found in the list of libraries is always read in. Otherwise just parse in imported files as referenced.

I'm also experimenting with lerna and moving dependencies like typescript to the top level package. However, different tooling expects there to be local binaries like ts-node or tsc.

To solve this after the lerna bootstrap step, which symlinks all local dependencies, I also symlink each of the contents of top level node_modules/.bin/ to each package's node_modules/.bin.

Taking this a step further, in each package I create a hidden directory node_modules/.assembly/, and create a symlink for each project's assembly folder. Then just add node_modules/.assembly to the library path. I realized that when I was adding just the assembly folders it would just treat each index.ts in the path to be the same as every index.ts.

@dcodeIO
Copy link
Member

dcodeIO commented Apr 11, 2019

Another solution to this might be to not add everything to lib paths, but to have a fallback handler in case a file is not found in either baseDir or libDir that then looks up the file in node_modules etc.

@stale
Copy link

stale bot commented May 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 11, 2019
@stale stale bot closed this as completed May 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants