-
Notifications
You must be signed in to change notification settings - Fork 146
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
Is it possible to edit client, server, and shared TypeScript files all at once? #297
Comments
Here's some relevant info from Microsoft's TypeScript team. To help bridge the gap between TypeScript and modern JavaScript modules, they added an interesting feature. If you say It pains me to ask, but would you consider adding the same feature to Deno? If Deno knows that |
@TradeIdeasPhilip Oh, nice seeing you here. You see Phillip, the problem is that if you tell an OS to look for Deno works the same way, right now you can have two files |
Here's the solution that I'm on the verge of. Run two separate instances of VS Code, one with the Deno files and the other with the client and shared files. To avoid VS Code crashing. Create a script which will watch the client's library directory. Any time a *.ts file changes, automatically copy it to the server's library directory. And create a sed script to change /(?<=import.from ".)js(?=")/ to "ts" in the server's copy. And mark the server's copy read only so I don't accidentally edit the wrong copy. @Soremwar , yeah, my suggestion to follow Microsoft was somewhat tongue in cheek. But I feel like I'm missing something. I know I'm not the first person to try to reuse a module between the client and the server. The default template for new GWT projects comes with a client, server, and shared directories, for example! Surely someone's done this in JavaScript? It's frustrating because I can see how close I am. For goodness sake, Deno goes out of it's way to match the modern Browser's built in libraries. What was the intent of that? It really seems like there is a very simple solution close by. https://www.youtube.com/watch?v=yijQRhPvJhQ |
@TradeIdeasPhilip I just think that you are overcomplicating things too much. I don't know why do you need two instances of VSCode running to be honest, there is probably something wrong with your setup. Transpiling the code you already have should be just enough, or am I missing something? Since the code you already have in TS and the final code in JS for the browser are going to be pretty much the same |
When I try to run with normal typescript and Deno typescript in the same instance of VS Code, VS Code frequently crashes. It's very repeatable. Go to the code I posted and open the workspace at the top level. This is a bug. I'm assuming it's a bug in Deno's VS Code component, so I reported it on this project.
It's almost identical. That's why I'm so frustrated. I can basically make it work if I'm willing to put ".ts" into all my exports, then start my Deno software running, then changes those exports to say ".js" and then call tsc on my web facing files. If you look at my example you will see that I got close. The server side main program and a client side script both share the useful-stuff.ts library. However, my server script is not able to access my high-security.ts library. The difference is that my high-security.ts library references the useful-stuff.ts library. That's the point where I get stuck. Short of changing line 1 of high-security.ts every time I switch between client work and server work, I can't make any progress. I want to share a typescript library between Deno and the browser. In this example, I want to uncomment line 4 of my server script so I can import that typescript library file. |
@TradeIdeasPhilip I opened a PR in your repo that tries to come close to the structure you should have in order to share files with Deno and the browser, so further discussion can be carried there if you have any doubts (this is an issue tracker so not really a place to ask questions like this) |
Thanks, @Soremwar , I'm looking at that now. Were you able to reproduce my problems with a multi root workspace? It appears that the Deno extension doesn't work well in that case. I think I need to move that bug into it's own issue report. It's hard for me to describe because the details change every time I try it, but I've never gotten it to work right. (100% repeatable that something goes wrong, but it looks different every time.) This morning, for example, the Deno extension is trying enforce rules on things outside of my deno/ folder. In the past the problem usually went the other direction. |
@Soremwar I'm still looking at all the tricks you used. However, I don't think this will solve my biggest problems.
I should have been more clear. This is at least my 3rd serious prototype of this project. I had already solved the DOM issue in my second prototype. That was too ugly, so I wrote this 3rd version from scratch. I've tried working in TypeScript when TypeScript was looking at the wrong libraries. That was terrible. I would go back to plain JavaScript before I'd use TypeScript with the wrong libraries again. Better to have no one trying to enforce the rules than an AI that's wrong a lot! I look forward to investigating the bundler, starting with the code in your PR. It sounds like that will solve my problem with the file extensions. However, the bundler is downstream from the editor. If we could just get Intellesense working in the editor, we might be done! Note that I have three directories full of *.ts files. Each one requires different libraries. I attacked that problem by creating different tsconfig files in the web directory and the shared directory. I relied on the defaults built into Deno for the third. That's what I want fixed. I think it's a legit bug report / feature request for the vscode_deno project. I know Deno doesn't like tsconfig files, but we need to way to tell the TypeScript service that different directories use different libraries. It works outside of Deno. It seems like an oversight in the deno plugin, like no one thought to test it. PS Thanks for fixing the directory bug in my server. This is just a prototype. There are a lot of small holes in the code. I'm really focused on a proof of concept. I want to make sure Deno can fulfil my basic requirements before I get lost in the details. |
I think this can be solved with "workspace folders" which we will add to the Deno language server and the extension. |
My team and I have also been doing this.
This way Deno's formatter/linter/etc doesn't choke on any non-Deno TS files. If you accidentally view and save client/shared code in the Deno editor it'll format/rewrite the file. Hoping we can soon tell Deno to ignore directories 🤞🤞 It gets messy when I want to use Deno as a general purpose script runner. Where should project wide build scripts live? The project root...ohno. |
* feat: code lens for references (denoland#308) * feat: disable most of builtin language service when deno enabled (denoland#307) * 0.0.8 * feat: add applyCodeActionCommand command (denoland#312) * fix: remove deno/applyCodeActionCommand (denoland#315) * New high-res logo (denoland#274) * feat: add implementations code lens configuration option (denoland#319) * feat: add initialize workspace command (denoland#316) * feat: support deno cache quick fix (denoland#322) * chore: add screenshot to README (denoland#323) * 0.0.9 * 0.0.10 * fix: typo in init command (denoland#327) * feat: add a welcome screen for extension (denoland#329) * feat: use preview instead of display for status (denoland#330) * chore: README improvements (denoland#331) * Release 3.0.0, canary is now main (denoland#332) * 3.0.1 * Fix typo (denoland#337) Grammar + context * chore: activate extension on command (denoland#336) * docs: recommend import_map.json instead of import-map.json (denoland#340) Resolves denoland#338 * chore: move Releases.md to CHANGELOG.md for better marketplace integration (denoland#344) Closes denoland#342 * feat: add deno.path setting (denoland#350) * 3.1.0 * feat: read-add debug support (denoland#351) Co-authored-by: CGQAQ <[email protected]> * feat: add settings to affect completions (denoland#368) * fix: manual `deno` command resolution on windows. (denoland#367) Fixes denoland#361 * 3.2.0 * feat: support for relative path resolution (using workspaces) in deno.path (denoland#381) Co-authored-by: Kitson Kelly <[email protected]> * feat: add version notification message (denoland#383) * feat: add restart language server command (denoland#385) Resolves denoland#372 * feat: add support for import registry completions (denoland#380) * 3.3.0 * typo in ImportCompletions.md (denoland#390) * fix: activate on reloadImportRegistries command (denoland#407) Fixes: denoland#394 * feat: handle per resource configuration (denoland#411) Requires Deno with denoland/deno#10488. Ref: denoland#348 Resolves: denoland#314 Resolves: denoland#297 * feat: add internalDebug config flag (denoland#406) Also integrate upstream formatting changes in deno fmt. Ref: denoland/deno#10368 * 3.4.0 * feat: recognise json(c) & markdown files (denoland#404) * 3.5.0 * docs: fix broken link in README (denoland#426) * feat: support registry auto discovery (denoland#427) * fix: bump semver of extension (denoland#429) * 3.5.1 * feat: add support for tasks and test code lens (denoland#436) * 3.6.0 * fix: update packaging and pin vsce version (denoland#440) Fixes denoland#439 * 3.6.1 * feat: add support for import map in test code lens (denoland#446) * fix: activate extension on markdown / json / jsonc (denoland#447) * fix: setting then clearing "deno.path" config should not use empty string for path (denoland#452) * fix: better handling when language server fails to start (denoland#454) * 3.7.0 * fix: remove trailing slash in example (denoland#471) * chore: remove test header from bug report issue template (denoland#479) * feat: add ability to set cache directory in settings (denoland#477) Closes denoland#287 * fix: properly handle plugin configuration at startup (denoland#474) Fixes denoland#473 Co-authored-by: Kitson Kelly <[email protected]> Co-authored-by: Luca Casonato <[email protected]> Co-authored-by: Kirill Reunov <[email protected]> Co-authored-by: Liam Murphy <[email protected]> Co-authored-by: Ryan Dahl <[email protected]> Co-authored-by: Jesse Jackson <[email protected]> Co-authored-by: CGQAQ <[email protected]> Co-authored-by: David Sherret <[email protected]> Co-authored-by: Hector Menendez <[email protected]> Co-authored-by: Heyward Fann <[email protected]> Co-authored-by: Satya Rohith <[email protected]> Co-authored-by: yaegassy <[email protected]> Co-authored-by: Cedric Vangout <[email protected]>
Is your feature request related to a problem? Please describe.
I want to use shared TypeScript libraries between the client and the server. Even when I'm working on files that are specific to one side or the other, I still want them all in the same IDE at the same time.
Describe the solution you'd like
I've created a template to show how far I've gotten, and where I'm stuck: Deno Client Server Template. I'm running into two major problems.
I'd love to know how other people handle these issues. Is there already a working template out there? Is there a fix or work-around I can do on my side? Or do I need to wait for bug fixes and/or new features?
Thanks!
The text was updated successfully, but these errors were encountered: