Skip to content

Commit

Permalink
Merge pull request #67 from marlencrabapple/vscodeignore-webpack
Browse files Browse the repository at this point in the history
Compile main extension with webpack and add .vscodeignore
  • Loading branch information
bscan authored Jan 8, 2024
2 parents a56989a + 8a563a0 commit fc14c47
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 7 deletions.
10 changes: 10 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/*
!images/camel_icon.png
!syntaxes
!LICENSE
!client/dist/*
!server/dist/*
!server/src/perl
!perlimports.toml
!server/perl.tmLanguage.json
!server/node_modules/vscode-oniguruma/release/onig.wasm
2 changes: 1 addition & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let client: LanguageClient;
export function activate(context: ExtensionContext) {
// The server is implemented in node
const serverModule = context.asAbsolutePath(
path.join('server', 'out', 'server.js')
path.join('server', 'dist', 'serverMain.js')
);
// The debug options for the server
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"activationEvents": [
"onLanguage:perl"
],
"main": "./client/out/extension",
"main": "./client/dist/clientMain",
"browser": "./client/dist/browserClientMain",
"contributes": {
"configuration": {
Expand Down Expand Up @@ -341,7 +341,7 @@
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"vscode:prepublish": "npm run package",
"compile": "tsc -b",
"watch": "tsc -b -w",
"web-compile": "export NODE_OPTIONS=--openssl-legacy-provider; webpack",
Expand Down Expand Up @@ -376,9 +376,9 @@
"ts-loader": "^9.3.0",
"path-browserify": "^1.0.1"
},
"bin": "server/out/server.js",
"bin": "server/dist/serverMain.js",
"pkg": {
"scripts": "server/out/server.js",
"scripts": "server/dist/serverMain.js",
"assets": "server/src/**/*",
"targets": [
"node16-linux-x64",
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"vscode-oniguruma": "^2.0.1"
},
"scripts": {},
"main": "./src/out/server.js",
"main": "./src/dist/serverMain.js",
"bin": {
"perlnavigator": "./bin/perlnavigator"
},
Expand Down
99 changes: 98 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,103 @@

const path = require('path');

/** @type WebpackConfig */
const clientConfig = {
context: path.join(__dirname, 'client'),
target: 'node', // web extensions run in a webworker context
entry: {
clientMain: './src/extension.ts',
},
output: {
filename: '[name].js',
path: path.join(__dirname, 'client', 'dist'),
libraryTarget: 'commonjs',
},
resolve: {
mainFields: ['module', 'main'],
extensions: ['.ts', '.js'], // support ts-files and js-files
alias: {},
fallback: {
// path: require.resolve('path-browserify'),
path: false,
process: false,
os: false,
fs: false,
child_process: false,
util: false
},
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
},
],
},
],
},
externals: {
vscode: 'commonjs vscode', // ignored because it doesn't exist
},
performance: {
hints: false,
},
devtool: 'source-map',
};

/** @type WebpackConfig */
const serverConfig = {
context: path.join(__dirname, 'server'),
target: 'node', // web extensions run in a webworker context
entry: {
serverMain: './src/server.ts',
},
output: {
filename: '[name].js',
path: path.join(__dirname, 'server', 'dist'),
libraryTarget: 'var',
library: 'serverExportVar',
},
resolve: {
mainFields: ['module', 'main'],
extensions: ['.ts', '.js'], // support ts-files and js-files
alias: {},
fallback: {
//path: require.resolve("path-browserify")
path: false,
process: false,
os: false,
fs: false,
child_process: false,
util: false
},
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
},
],
},
],
},
externals: {
vscode: 'commonjs vscode', // ignored because it doesn't exist
},
performance: {
hints: false,
},
devtool: 'source-map',
};

/** @type WebpackConfig */
const browserClientConfig = {
context: path.join(__dirname, 'client'),
Expand Down Expand Up @@ -100,4 +197,4 @@ const browserServerConfig = {
devtool: 'source-map',
};

module.exports = [browserClientConfig, browserServerConfig];
module.exports = [browserClientConfig, browserServerConfig, clientConfig, serverConfig];

0 comments on commit fc14c47

Please sign in to comment.