Skip to content

Commit

Permalink
Merge pull request #68 from Dwarf1er/develop
Browse files Browse the repository at this point in the history
Webpack config fix
  • Loading branch information
Dwarf1er authored Oct 23, 2024
2 parents d636c95 + 9acd1f5 commit 1291eb2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-tigers-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"sqlanydb-tools-vscode": patch
---

Fixed Webpack configuration to bundle internal dependencies with the .VSIX package
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ By bundling both command-line utilities and an integrated VSCode experience in a

## VSCode extension

There are 2 ways to install the VSCode extension:
1. Navigate to the `Extensions` tab in VSCode and search for `sqlanydb-tools-vscode`
2. Download the VSIX file from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=dwarf1er.sqlanydb-tools-vscode)

## sqlanydb-manager CLI

[(Back to top)](#table-of-contents)
Expand Down
7 changes: 5 additions & 2 deletions apps/sqlanydb-tools-vscode/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"target": "ES2022",
"lib": ["ES2022"],
"sourceMap": true,
"rootDir": "src",
"rootDir": "../../",
"outDir": "dist",
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true
},
"include": ["src/**/*"],
"include": [
"../../apps/**/*",
"../../packages/**/*"
],
"exclude": ["node_modules", "dist"]
}
33 changes: 29 additions & 4 deletions apps/sqlanydb-tools-vscode/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,45 @@
"use strict";

const path = require("path");
const fs = require("fs");

const getInternalPackages = (dir) => {
return fs.readdirSync(dir)
.filter((item) => {
const itemPath = path.join(dir, item);
return fs.statSync(itemPath).isDirectory() && item !== 'sqlanydb-tools-vscode';
})
.map((item) => path.join(dir, item, 'src', 'index.ts'));
};

const packagesDir = path.resolve(__dirname, '../../packages');
const appsDir = path.resolve(__dirname, '../../apps');

//@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",
mode: "none",

entry: "./src/extension.ts", // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
entry: {
extension: "./src/extension.ts",
...getInternalPackages(packagesDir).reduce((acc, packageEntry) => {
const packageName = path.basename(path.dirname(packageEntry));
acc[packageName] = packageEntry;
return acc;
}, {}),
...getInternalPackages(appsDir).reduce((acc, appEntry) => {
const appName = path.basename(path.dirname(appEntry));
acc[appName] = appEntry;
return acc;
}, {}),
},
output: {
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, "dist"),
filename: "extension.js",
filename: "[name].js",
libraryTarget: "commonjs2",
},
externals: {
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

0 comments on commit 1291eb2

Please sign in to comment.