code-d icon indicating copy to clipboard operation
code-d copied to clipboard

support running in browser

Open WebFreak001 opened this issue 3 years ago • 0 comments

https://code.visualstudio.com/docs/editor/vscode-web#_extensions https://code.visualstudio.com/api/extension-guides/web-extensions

e.g. on https://vscode.dev, where the entire extension, serve-d, dmd, dub, etc. needs to run in the browser, with webassembly

in this mode need to:

  • disable things that just can't be done in a browser
  • remove all node.js API usage
    • replace direct file access with vscode filesystem APIs
    • abstract requests to use axiom/fetch based on platform
    • ...
  • remove all system dependencies
    • bundle or download phobos/druntime
    • extend DCD to support virtual filesystems (would also allow coding over FTP, etc. with regular code-d)
      • and/or implement the read system calls for this just in webassembly with the vscode fs api
    • extend DUB or make a more lightweight API to support our usecases
    • ...
  • compile serve-d and dependencies to webassembly (see https://forum.dlang.org/thread/[email protected] for example)
  • bundle compiled webassembly
  • ...

advantages:

  • ability to ship a full D IDE online, anywhere
  • easier to quickly edit full projects on setups without D installed
  • more supported platforms (anywhere where a browser with webassembly runs)
  • standardized environment: testable, avoids crashes/bugs with rare system configurations

use-cases:

  • alternative / extension to run.dlang.io
  • users first time trying out D
  • making quick PRs on D repositories without cloning the entire repository or needing a D setup (but still getting all the nice IDE features!)

Replacing direct file access with vscode filesystem APIs of course also makes the extension better compatible with remote filesystems like FTP or others provided by extensions, even if this issue is not going to be implemented.

Things that I think should just work already (using virtual documents, no system access) once working with webassembly:

  • formatting code
  • dscanner linting
  • syntax highlighting
  • dub.json editor
  • smart snippets
  • dub dependency view (maybe, probably need to strip out networking from dub)

if we use the wasm dmd-fe linked above we could also support dub building for full diagnostics.

just an idea for the future :)

WebFreak001 avatar Jan 10 '22 12:01 WebFreak001