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

[Archive] Lsp task expression #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions configurations/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = {
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
project: "./tsconfig.json",
// I need to create another dummy tsconfig within this folder for these files to be linted
project: ["./tsconfig.json", "lsp-task-expression/tsconfig.json"],
},

plugins: ["@typescript-eslint", "unused-imports", "prettier"],
Expand Down Expand Up @@ -68,8 +69,8 @@ module.exports = {
"out",
"dist",
"**/*.d.ts",
"**/*.js",
"**/*.mjs",
"**/out",
"testing-sandbox",
"configurations"
],
};
80 changes: 51 additions & 29 deletions configurations/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,98 @@
/* eslint-disable @typescript-eslint/no-var-requires */
//@ts-check

"use strict";
'use strict'

const resolve = require("path").resolve;
const fs = require("fs");
const path = require('path')
const fs = require('fs')

// Assumes the script is executed from the root of the project
const projectRoot = process.cwd();
const projectRoot = process.cwd()

// Generate the alias object for all the folders in the 'src' folder to use absolute import paths
const srcDir = resolve(projectRoot, "src");
/* Generate the alias object for all the folders in the 'src' folder to use
absolute import paths */
const srcDir = path.resolve(projectRoot, 'src')

// Read the directories in the 'src' folder
// To allow absolute imports from all the folders in 'src'
// For example instead of using 'src/extension' we can use 'extension'
/* Read the directories in the 'src' folder
To allow absolute imports from all the folders in 'src'
For example instead of using 'src/extension' we can use 'extension' */
const dirs = fs
.readdirSync(srcDir, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
.map((dirent) => dirent.name)

// Augment with the 'src' folder itself for files like 'src/execution-context.ts'?.
// Ignoring this problem for now and disallowing top level files
/* Augment with the 'src' folder itself for files like
'src/execution-context.ts'?. Ignoring this problem for now and disallowing
top level files */

// Generate the alias object
const aliasForAllSrcFolders = dirs.reduce((acc, dir) => {
acc[dir] = resolve(srcDir, dir);
return acc;
}, {});
acc[dir] = path.resolve(srcDir, dir)
return acc
}, {})

//@ts-check
/** @typedef {import('webpack').Configuration} WebpackConfig **/

/** @type WebpackConfig */
const extensionConfig = {
target: "node", // VS Code extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
mode: "none", // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
target: 'node', // VS Code extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')

entry: "./src/extension.ts", // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
// the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
entry: {
extension: './src/extension.ts',
server: './lsp-task-expression/src/server.ts',
},
output: {
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
path: resolve(projectRoot, "dist"),
filename: "extension.js",
libraryTarget: "commonjs2",
path: path.resolve(projectRoot, 'dist'),
filename: '[name].js',
libraryTarget: 'commonjs2',
clean: true, // clean the output folder before building
},
externals: {
vscode: "commonjs vscode", // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
vscode: 'commonjs vscode', // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
// modules added here also need to be added in the .vscodeignore file
},
resolve: {
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
extensions: [".ts", ".js"],
extensions: ['.ts', '.js'],

alias: aliasForAllSrcFolders,
},
module: {
rules: [
{
test: /src\/.*\.ts$/,
exclude: /node_modules/,
exclude: [/node_modules/, /lsp-task-expression/],
use: [
{
loader: 'ts-loader',
},
],
},
{
test: /lsp-task-expression\/.*\.ts$/,
include: path.resolve(projectRoot, 'lsp-task-expression/src'),
exclude: path.resolve(projectRoot, 'lsp-task-expression/node_modules'),
use: [
{
loader: "ts-loader",
loader: 'ts-loader',
options: {
configFile: path.resolve(
projectRoot,
'lsp-task-expression/tsconfig.json',
),
},
},
],
},
],
},
devtool: "nosources-source-map",
devtool: 'inline-source-map',
infrastructureLogging: {
level: "log", // enables logging required for problem matchers
level: 'log', // enables logging required for problem matchers
},
};
module.exports = [extensionConfig];
}
module.exports = [extensionConfig]
58 changes: 58 additions & 0 deletions lsp-task-expression/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions lsp-task-expression/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "lsp-sample-server",
"description": "Example implementation of a language server in node.",
"version": "1.0.0",
"author": "Microsoft Corporation",
"license": "MIT",
"engines": {
"node": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-extension-samples"
},
"dependencies": {
"vscode-languageserver": "^8.1.0",
"vscode-languageserver-textdocument": "^1.0.8"
},
"scripts": {}
}
Loading