Add webpack support (#155)

* Add webpack support

Signed-off-by: Jerome Luckenbach <github@luckenba.ch>

* Adaption to multi package extension. (Language Server). ALso build improvements

Signed-off-by: Jerome Luckenbach <github@luckenba.ch>
pull/162/head
Jerome Luckenbach 2019-10-26 21:06:29 +02:00 committed by GitHub
parent 00e4af3d94
commit f7dd9c8d46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 4362 additions and 1159 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
*.todo
*.zip
**/out
**/dist
### General generated List

4
.vscode/launch.json vendored
View File

@ -10,7 +10,7 @@
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/**/out/**/*.js" ],
"outFiles": [ "${workspaceRoot}/**/dist/**/*.js" ],
"preLaunchTask": "npm"
},
{
@ -21,7 +21,7 @@
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/out/test/**/*.js" ],
"outFiles": [ "${workspaceRoot}/client/out/test/**/*.js" ],
"preLaunchTask": "npm"
},
{

View File

@ -1,13 +1,29 @@
#General
.vscode/**
.vscode-test/**
out/test/**
test/**
src/**
.github/**
**/*.ts
**/*.map
.gitignore
tsconfig.json
ISSUE_TEMPLATE.md
CONTRIBUTING.md
LICENSE.md
**/tsconfig.json
**/tsconfig.base.json
**/tslint.json
client/**
!client/out/extension.js
serverJS/**
!serverJS/out/LSPServer.js
shared.webpack.config.js
*.zip
**/node_modules
#Exclude vscode-language server because it is configured as external in shared.webpack.config.js
!**/node_modules/vscode-languageserver
# openHAB vscode repo meta files
AUTHORS
project-orga/*
azure-pipelines.yml
CHANGELOG.md
CONTRIBUTING.md
NOTICE
project-orga/*
docs/**

View File

@ -1604,32 +1604,39 @@
}
},
"vscode-jsonrpc": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-4.0.0.tgz",
"integrity": "sha512-perEnXQdQOJMTDFNv+UF3h1Y0z4iSiaN9jIlb0OqIYgosPCZGYh/MCUlkFtV2668PL69lRDO32hmvL2yiidUYg=="
"version": "5.0.0-next.2",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-5.0.0-next.2.tgz",
"integrity": "sha512-Q3/jabZUNviCG9hhF6hHWjhrABevPF9mv0aiE2j8BYCAP2k+aHTpjMyk+04MzaAqWYwXdQuZkLSbcYCCqbzJLg=="
},
"vscode-languageclient": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-5.2.1.tgz",
"integrity": "sha512-7jrS/9WnV0ruqPamN1nE7qCxn0phkH5LjSgSp9h6qoJGoeAKzwKz/PF6M+iGA/aklx4GLZg1prddhEPQtuXI1Q==",
"version": "6.0.0-next.1",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.0.0-next.1.tgz",
"integrity": "sha512-eJ9VjLFNINArgRzLbQ11YlWry7dM93GEODkQBXTRfrSypksiO9qSGr4SHhWgxxP26p4FRSpzc/17+N+Egnnchg==",
"requires": {
"semver": "5.6.0",
"vscode-languageserver-protocol": "3.14.1"
"semver": "6.3.0",
"vscode-languageserver-protocol": "3.15.0-next.9"
},
"dependencies": {
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
}
}
},
"vscode-languageserver-protocol": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.14.1.tgz",
"integrity": "sha512-IL66BLb2g20uIKog5Y2dQ0IiigW0XKrvmWiOvc0yXw80z3tMEzEnHjaGAb3ENuU7MnQqgnYJ1Cl2l9RvNgDi4g==",
"version": "3.15.0-next.9",
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.0-next.9.tgz",
"integrity": "sha512-b9PAxouMmtsLEe8ZjbIMPb7wRWPhckGfgjwZLmp/dWnaAuRPYtY3lGO0/rNbLc3jKIqCVlnEyYVFKalzDAzj0g==",
"requires": {
"vscode-jsonrpc": "4.0.0",
"vscode-languageserver-types": "3.14.0"
"vscode-jsonrpc": "5.0.0-next.2",
"vscode-languageserver-types": "3.15.0-next.5"
}
},
"vscode-languageserver-types": {
"version": "3.14.0",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.14.0.tgz",
"integrity": "sha512-lTmS6AlAlMHOvPQemVwo3CezxBp0sNB95KNPkqp3Nxd5VFEnuG1ByM0zlRWos0zjO3ZWtkvhal0COgiV1xIA4A=="
"version": "3.15.0-next.5",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.15.0-next.5.tgz",
"integrity": "sha512-7hrELhTeWieUgex3+6692KjCkcmO/+V/bFItM5MHGcBotzwmjEuXjapLLYTYhIspuJ1ibRSik5MhX5YwLpsPiw=="
},
"wrappy": {
"version": "1.0.2",

View File

@ -24,6 +24,6 @@
"request": "^2.83.0",
"request-promise-native": "^1.0.5",
"vscode": "^1.1.26",
"vscode-languageclient": "^5.2.1"
"vscode-languageclient": "6.0.0-next.1"
}
}

View File

@ -23,7 +23,7 @@ export class LocalLanguageClientProvider {
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
const serverModule = context.asAbsolutePath(path.join("serverJS", "src", "LSPServer.js"));
const serverModule = context.asAbsolutePath(path.join("serverJS", "out", "LSPServer.js"));
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used

View File

@ -7,7 +7,8 @@
"outDir": "out",
"rootDir": "src",
"lib": ["es6"],
"types":["node"]
"types":["node"],
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", ".vscode-test"]

17
client/webpack.config.js Normal file
View File

@ -0,0 +1,17 @@
//@ts-check
'use strict';
const withDefaults = require('../shared.webpack.config');
const path = require('path');
module.exports = withDefaults({
context: path.join(__dirname),
entry: {
extension: './src/extension.ts',
},
output: {
filename: 'extension.js',
path: path.join(__dirname, 'out')
}
});

4081
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -342,11 +342,16 @@
"watch": "tsc -b -w",
"postinstall": "cd client && npm install && cd ../serverJS && npm install && cd ..",
"test": "cd client && npm test && cd ../serverJS && npm test && cd ..",
"clean": "rm -rf node_modules && rm -rf **/node_modules && rm -rf **/out",
"pruneProduction": "npm prune --production && cd client && npm prune --production && cd ../serverJS && npm prune --production && cd ..",
"build": "npm run clean && npm install && npm run compile && npm run test && npm run pruneProduction",
"clean:node_modules": "rimraf client/node_modules && rimraf serverJS/node_modules",
"clean:out": "rimraf client/out && rimraf serverJS/out",
"pruneProduction": "cd client && npm prune --production && cd ../serverJS && npm prune --production && cd ..",
"build": "npm run clean:out && npm install && npm run compile && npm run test",
"package": "npm run build && vsce package",
"publish": "npm run build && vsce publish"
"publish": "npm run build && vsce publish",
"vscode:prepublish": "npm run webpack",
"webpack": "webpack --mode production --config ./client/webpack.config.js && webpack --mode production --config ./serverJS/webpack.config.js",
"webpack-dev": "webpack --mode none --config ./client/webpack.config.js && webpack --mode none --config ./serverJS/webpack.config.js",
"test-compile": "tsc -p ./"
},
"devDependencies": {
"@types/form-data": "^2.2.1",
@ -355,7 +360,12 @@
"@types/request": "^2.48.1",
"@types/request-promise-native": "^1.0.15",
"jest": "^23.6.0",
"merge-options": "^1.0.1",
"request-promise-native": "^1.0.5",
"typescript": "^3.2.2"
"rimraf": "^3.0.0",
"ts-loader": "^6.2.1",
"typescript": "^3.2.2",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.9"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
"url": "https://github.com/openhab/openhab-vscode.git"
},
"dependencies": {
"vscode-languageserver": "^5.2.1",
"vscode-languageserver": "6.0.0-next.1",
"eventsource": "^1.0.7",
"lodash": "^4.17.11",
"request": "^2.88.0"

View File

@ -0,0 +1,17 @@
//@ts-check
'use strict';
const withDefaults = require('../shared.webpack.config');
const path = require('path');
module.exports = withDefaults({
context: path.join(__dirname),
entry: {
extension: './src/LSPServer.js',
},
output: {
filename: 'LSPServer.js',
path: path.join(__dirname, 'out')
}
});

52
shared.webpack.config.js Normal file
View File

@ -0,0 +1,52 @@
//@ts-check
/** @typedef {import('webpack').Configuration} WebpackConfig **/
'use strict';
const path = require('path');
const merge = require('merge-options');
module.exports = function withDefaults(/**@type WebpackConfig*/extConfig) {
/** @type WebpackConfig */
let defaultConfig = {
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
node: {
__dirname: false // leave the __dirname-behaviour intact
},
resolve: {
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader'
}
]
}
]
},
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/
},
output: {
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
path: path.join(extConfig.context, 'out'),
filename: '[name].js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]'
},
devtool: 'source-map'
};
return merge(defaultConfig, extConfig);
}
//entry: './client/src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/

View File

@ -1,4 +1,7 @@
{
"compilerOptions": {
"skipLibCheck": true
},
"include": [
"src"
],