server-cli.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. import "./bootstrap-server.js" // this MUST come before other imports as it changes global state
  6. import { dirname, join } from "path"
  7. import { fileURLToPath } from "url"
  8. import { devInjectNodeModuleLookupPath } from "./bootstrap-node.js"
  9. import { bootstrapESM } from "./bootstrap-esm.js"
  10. import { resolveNLSConfiguration } from "./deps/vscode/vs/base/node/nls.js"
  11. import { product } from "./bootstrap-meta.js"
  12. const __dirname = dirname(fileURLToPath(import.meta.url))
  13. // NLS
  14. const nlsConfiguration = await resolveNLSConfiguration({
  15. userLocale: "en",
  16. osLocale: "en",
  17. commit: product.commit,
  18. userDataPath: "",
  19. nlsMetadataPath: __dirname,
  20. })
  21. process.env["VSCODE_NLS_CONFIG"] = JSON.stringify(nlsConfiguration) // required for `bootstrap-esm` to pick up NLS messages
  22. if (process.env["VSCODE_DEV"]) {
  23. // When running out of sources, we need to load node modules from remote/node_modules,
  24. // which are compiled against nodejs, not electron
  25. process.env["VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH"] =
  26. process.env["VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH"] || join(__dirname, "..", "remote", "node_modules")
  27. devInjectNodeModuleLookupPath(process.env["VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH"])
  28. } else {
  29. delete process.env["VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH"]
  30. }
  31. // Bootstrap ESM
  32. await bootstrapESM()
  33. // Load Server
  34. await import("./deps/vscode/vs/server/node/server.cli.js")