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

EDITOR: Cannot resolve import paths in some cases #1747

Open
catloversg opened this issue Nov 2, 2024 · 4 comments
Open

EDITOR: Cannot resolve import paths in some cases #1747

catloversg opened this issue Nov 2, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@catloversg
Copy link
Contributor

catloversg commented Nov 2, 2024

TypeScript support will be available on the stable version via #1216. In some cases, monaco cannot resolve the import paths. This is just a problem with the script editor UI. It does not affect anything else. It may be fixed by #1477, but I don't think that fix can be merged easily.

MRE:
lib.ts

export const multiply = (a: number, b: number) => a * b;

test.ts

import { multiply } from "/lib";

export async function main(ns: NS) {
  ns.print(`multiply: ${multiply(2, 3)}`);
}

Screenshot:
Capture

With this case (use an absolute path), the player can work around by using a relative path (./lib instead of /lib).

I'll use this issue to keep track of the problem and potential fixes. Other reports can be marked "duplicate" and linked back to here.

Test suite:
test suite for editor.gz

@d0sboots
Copy link
Collaborator

d0sboots commented Nov 4, 2024

Yes, we should assume #1477 is dead in the water and steal pieces from it that are useful or mergeable.

@lucebac
Copy link
Contributor

lucebac commented Dec 19, 2024

I've seen this error in the past as well when I updated the import resolution. However, I believe I wasn't able to fix this because from what I understand this is an edge case of the way we interact with and provide model data to monaco.

@catloversg
Copy link
Contributor Author

Update:
The workaround (using a relative path) still has some problems. In #1661, we added loadAllServerScripts function to preload models. The new function has some problems. I tried to fix them in #1865 and #1867. However, a player reported another problem in #1877. If we preload too many models, monaco fails to provide type hints via JSDoc. It still works in TS files, though. I'm too lazy to debug the internal of monaco to see why it happens. Based on microsoft/monaco-editor#3895, I conclude that monaco is not supposed to support loading hundreds of models at the same time, so the "preloading all scripts" solution is only a workaround until we find a proper way to load modules on demand. I'll take a look at the idea in #1477.

@catloversg
Copy link
Contributor Author

Update:
The workaround works properly now with the fix in #1893.

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

No branches or pull requests

4 participants