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
parent
00e4af3d94
commit
f7dd9c8d46
|
@ -3,6 +3,7 @@
|
||||||
*.todo
|
*.todo
|
||||||
*.zip
|
*.zip
|
||||||
**/out
|
**/out
|
||||||
|
**/dist
|
||||||
|
|
||||||
### General generated List
|
### General generated List
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
|
||||||
"stopOnEntry": false,
|
"stopOnEntry": false,
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"outFiles": [ "${workspaceRoot}/**/out/**/*.js" ],
|
"outFiles": [ "${workspaceRoot}/**/dist/**/*.js" ],
|
||||||
"preLaunchTask": "npm"
|
"preLaunchTask": "npm"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
|
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
|
||||||
"stopOnEntry": false,
|
"stopOnEntry": false,
|
||||||
"sourceMaps": true,
|
"sourceMaps": true,
|
||||||
"outFiles": [ "${workspaceRoot}/out/test/**/*.js" ],
|
"outFiles": [ "${workspaceRoot}/client/out/test/**/*.js" ],
|
||||||
"preLaunchTask": "npm"
|
"preLaunchTask": "npm"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,13 +1,29 @@
|
||||||
|
#General
|
||||||
.vscode/**
|
.vscode/**
|
||||||
.vscode-test/**
|
.vscode-test/**
|
||||||
out/test/**
|
.github/**
|
||||||
test/**
|
**/*.ts
|
||||||
src/**
|
|
||||||
**/*.map
|
**/*.map
|
||||||
.gitignore
|
.gitignore
|
||||||
tsconfig.json
|
**/tsconfig.json
|
||||||
ISSUE_TEMPLATE.md
|
**/tsconfig.base.json
|
||||||
CONTRIBUTING.md
|
**/tslint.json
|
||||||
LICENSE.md
|
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
|
AUTHORS
|
||||||
project-orga/*
|
azure-pipelines.yml
|
||||||
|
CHANGELOG.md
|
||||||
|
CONTRIBUTING.md
|
||||||
|
NOTICE
|
||||||
|
project-orga/*
|
||||||
|
docs/**
|
||||||
|
|
|
@ -1604,32 +1604,39 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vscode-jsonrpc": {
|
"vscode-jsonrpc": {
|
||||||
"version": "4.0.0",
|
"version": "5.0.0-next.2",
|
||||||
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-5.0.0-next.2.tgz",
|
||||||
"integrity": "sha512-perEnXQdQOJMTDFNv+UF3h1Y0z4iSiaN9jIlb0OqIYgosPCZGYh/MCUlkFtV2668PL69lRDO32hmvL2yiidUYg=="
|
"integrity": "sha512-Q3/jabZUNviCG9hhF6hHWjhrABevPF9mv0aiE2j8BYCAP2k+aHTpjMyk+04MzaAqWYwXdQuZkLSbcYCCqbzJLg=="
|
||||||
},
|
},
|
||||||
"vscode-languageclient": {
|
"vscode-languageclient": {
|
||||||
"version": "5.2.1",
|
"version": "6.0.0-next.1",
|
||||||
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-5.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.0.0-next.1.tgz",
|
||||||
"integrity": "sha512-7jrS/9WnV0ruqPamN1nE7qCxn0phkH5LjSgSp9h6qoJGoeAKzwKz/PF6M+iGA/aklx4GLZg1prddhEPQtuXI1Q==",
|
"integrity": "sha512-eJ9VjLFNINArgRzLbQ11YlWry7dM93GEODkQBXTRfrSypksiO9qSGr4SHhWgxxP26p4FRSpzc/17+N+Egnnchg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"semver": "5.6.0",
|
"semver": "6.3.0",
|
||||||
"vscode-languageserver-protocol": "3.14.1"
|
"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": {
|
"vscode-languageserver-protocol": {
|
||||||
"version": "3.14.1",
|
"version": "3.15.0-next.9",
|
||||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.14.1.tgz",
|
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.0-next.9.tgz",
|
||||||
"integrity": "sha512-IL66BLb2g20uIKog5Y2dQ0IiigW0XKrvmWiOvc0yXw80z3tMEzEnHjaGAb3ENuU7MnQqgnYJ1Cl2l9RvNgDi4g==",
|
"integrity": "sha512-b9PAxouMmtsLEe8ZjbIMPb7wRWPhckGfgjwZLmp/dWnaAuRPYtY3lGO0/rNbLc3jKIqCVlnEyYVFKalzDAzj0g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"vscode-jsonrpc": "4.0.0",
|
"vscode-jsonrpc": "5.0.0-next.2",
|
||||||
"vscode-languageserver-types": "3.14.0"
|
"vscode-languageserver-types": "3.15.0-next.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vscode-languageserver-types": {
|
"vscode-languageserver-types": {
|
||||||
"version": "3.14.0",
|
"version": "3.15.0-next.5",
|
||||||
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.14.0.tgz",
|
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.15.0-next.5.tgz",
|
||||||
"integrity": "sha512-lTmS6AlAlMHOvPQemVwo3CezxBp0sNB95KNPkqp3Nxd5VFEnuG1ByM0zlRWos0zjO3ZWtkvhal0COgiV1xIA4A=="
|
"integrity": "sha512-7hrELhTeWieUgex3+6692KjCkcmO/+V/bFItM5MHGcBotzwmjEuXjapLLYTYhIspuJ1ibRSik5MhX5YwLpsPiw=="
|
||||||
},
|
},
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
|
|
|
@ -24,6 +24,6 @@
|
||||||
"request": "^2.83.0",
|
"request": "^2.83.0",
|
||||||
"request-promise-native": "^1.0.5",
|
"request-promise-native": "^1.0.5",
|
||||||
"vscode": "^1.1.26",
|
"vscode": "^1.1.26",
|
||||||
"vscode-languageclient": "^5.2.1"
|
"vscode-languageclient": "6.0.0-next.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// --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 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
|
// If the extension is launched in debug mode then the debug server options are used
|
||||||
// Otherwise the run options are used
|
// Otherwise the run options are used
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
"outDir": "out",
|
"outDir": "out",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"lib": ["es6"],
|
"lib": ["es6"],
|
||||||
"types":["node"]
|
"types":["node"],
|
||||||
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"exclude": ["node_modules", ".vscode-test"]
|
"exclude": ["node_modules", ".vscode-test"]
|
||||||
|
|
|
@ -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')
|
||||||
|
}
|
||||||
|
});
|
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
|
@ -342,11 +342,16 @@
|
||||||
"watch": "tsc -b -w",
|
"watch": "tsc -b -w",
|
||||||
"postinstall": "cd client && npm install && cd ../serverJS && npm install && cd ..",
|
"postinstall": "cd client && npm install && cd ../serverJS && npm install && cd ..",
|
||||||
"test": "cd client && npm test && cd ../serverJS && npm test && cd ..",
|
"test": "cd client && npm test && cd ../serverJS && npm test && cd ..",
|
||||||
"clean": "rm -rf node_modules && rm -rf **/node_modules && rm -rf **/out",
|
"clean:node_modules": "rimraf client/node_modules && rimraf serverJS/node_modules",
|
||||||
"pruneProduction": "npm prune --production && cd client && npm prune --production && cd ../serverJS && npm prune --production && cd ..",
|
"clean:out": "rimraf client/out && rimraf serverJS/out",
|
||||||
"build": "npm run clean && npm install && npm run compile && npm run test && npm run pruneProduction",
|
"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",
|
"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": {
|
"devDependencies": {
|
||||||
"@types/form-data": "^2.2.1",
|
"@types/form-data": "^2.2.1",
|
||||||
|
@ -355,7 +360,12 @@
|
||||||
"@types/request": "^2.48.1",
|
"@types/request": "^2.48.1",
|
||||||
"@types/request-promise-native": "^1.0.15",
|
"@types/request-promise-native": "^1.0.15",
|
||||||
"jest": "^23.6.0",
|
"jest": "^23.6.0",
|
||||||
|
"merge-options": "^1.0.1",
|
||||||
"request-promise-native": "^1.0.5",
|
"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
|
@ -10,7 +10,7 @@
|
||||||
"url": "https://github.com/openhab/openhab-vscode.git"
|
"url": "https://github.com/openhab/openhab-vscode.git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vscode-languageserver": "^5.2.1",
|
"vscode-languageserver": "6.0.0-next.1",
|
||||||
"eventsource": "^1.0.7",
|
"eventsource": "^1.0.7",
|
||||||
"lodash": "^4.17.11",
|
"lodash": "^4.17.11",
|
||||||
"request": "^2.88.0"
|
"request": "^2.88.0"
|
||||||
|
|
|
@ -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')
|
||||||
|
}
|
||||||
|
});
|
|
@ -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/
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src"
|
"src"
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue