Skip to content

Commit

Permalink
Webpack bundling (#377)
Browse files Browse the repository at this point in the history
* Webpack bundling

* Build webpack also in CI step, add Test PreLaunch task for local dev

* use webpack env plugin to stop neovim winston spam
  • Loading branch information
asvetliakov committed Sep 21, 2020
1 parent 6f2e797 commit e0c909b
Show file tree
Hide file tree
Showing 9 changed files with 2,362 additions and 114 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build_test.yml
Expand Up @@ -29,7 +29,9 @@ jobs:
- name: Yarn install
run: yarn --silent --frozen-lockfile
- name: Build
run: yarn run compile
run: yarn run test-compile
- name: Webpack
run: yarn run webpack
- name: Lint
run: yarn run lint
- name: Test
Expand All @@ -55,10 +57,10 @@ jobs:
- name: Install VSCE
run: yarn add vsce
- name: Create extension
run: yarn run vsce package -o vscode-neovim-${{github.sha}}.vsix
run: yarn run vsce package -o vscode-neovim-${{github.sha}}.vsix
- name: Upload extension
if: runner.os == 'Linux'
uses: actions/upload-artifact@v2
with:
name: vscode-neovim
path: vscode-neovim-${{github.sha}}.vsix
name: vscode-neovim
path: vscode-neovim-${{github.sha}}.vsix
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
out
dist
node_modules
yarn-error.log
.vscode-test/
Expand Down
10 changes: 4 additions & 6 deletions .vscode/extensions.json
@@ -1,7 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"ms-vscode.vscode-typescript-tslint-plugin"
]
}
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": []
}
74 changes: 35 additions & 39 deletions .vscode/launch.json
Expand Up @@ -3,43 +3,39 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
// "--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch",
"smartStep": true,
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"smartStep": true,
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "npm: watch",
"env": {
"NEOVIM_DEBUG": "1",
"NEOVIM_DEBUG_HOST": "127.0.0.1",
"NEOVIM_DEBUG_PORT": "4000",
}
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
// "--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"smartStep": true,
"preLaunchTask": "Watch"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"smartStep": true,
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js", "${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "Test PreLaunch",
"env": {
"NEOVIM_DEBUG": "1",
"NEOVIM_DEBUG_HOST": "127.0.0.1",
"NEOVIM_DEBUG_PORT": "4000"
}
}
]
}
100 changes: 84 additions & 16 deletions .vscode/tasks.json
@@ -1,20 +1,88 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
"version": "2.0.0",
"tasks": [
{
"label": "Watch",
"type": "npm",
"script": "webpack-dev",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "typescript",
"source": "ts",
"applyTo": "closedDocuments",
"fileLocation": "absolute",
"severity": "error",
"pattern": [
{
"regexp": "\\[tsl\\] (ERROR|WARNING) in (.*)?\\((\\d+),(\\d+)\\)",
"severity": 1,
"file": 2,
"line": 3,
"column": 4
},
{
"regexp": "\\s*TS(\\d+):\\s*(.*)$",
"code": 1,
"message": 2
}
],
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "Compiling.*?|Compilation .*?starting"
},
"endsPattern": {
"regexp": "Compiled .*?successfully|Compilation .*?finished"
}
}
}
},
{
"label": "Compile - Webpack",
"type": "npm",
"script": "webpack",
"isBackground": false,
"presentation": {
"echo": false,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": false
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Compile TS",
"type": "npm",
"script": "test-compile",
"isBackground": false,
"presentation": {
"echo": false,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": false
},
"problemMatcher": "$tsc"
},
{
"label": "Test PreLaunch",
"dependsOn": ["Compile TS", "Compile - Webpack"],
"dependsOrder": "parallel"
}
]
}
4 changes: 2 additions & 2 deletions .vscodeignore
@@ -1,10 +1,10 @@
.vscode/**
.vscode-test/**
out/test/**
out/
node_modules
src/**
.gitignore
vsc-extension-quickstart.md
**/tsconfig.json
**/tslint.json
**/*.map
**/*.ts
24 changes: 14 additions & 10 deletions package.json
Expand Up @@ -32,7 +32,7 @@
"activationEvents": [
"*"
],
"main": "./out/extension.js",
"main": "./dist/extension.js",
"contributes": {
"configuration": {
"title": "Neovim",
Expand Down Expand Up @@ -269,9 +269,9 @@
},
"vscode-neovim.textDecorationsAtTop": {
"type": "boolean",
"description": "If turned on, text decorations will appear on top of the associated text instead of behind it. Consider turning this on with the EasyMotion plugin.",
"default": false
}
"description": "If turned on, text decorations will appear on top of the associated text instead of behind it. Consider turning this on with the EasyMotion plugin.",
"default": false
}
}
},
"commands": [
Expand Down Expand Up @@ -1074,12 +1074,13 @@
]
},
"scripts": {
"vscode:prepublish": "yarn run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile",
"lint": "eslint --ext .ts src",
"test": "node ./out/test/runTest.js"
"test": "node ./out/test/runTest.js",
"pretest": "yarn run test-compile",
"vscode:prepublish": "webpack --mode production",
"webpack": "webpack --mode development",
"webpack-dev": "webpack --mode development --watch --info-verbosity verbose",
"test-compile": "tsc -p ./"
},
"devDependencies": {
"@types/glob": "^7.1.1",
Expand All @@ -1098,8 +1099,11 @@
"mocha": "^8.1.1",
"prettier": "^2.0.5",
"source-map-support": "^0.5.16",
"ts-loader": "^8.0.4",
"typescript": "^4.0.2",
"vscode-test": "^1.3.0"
"vscode-test": "^1.3.0",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12"
},
"dependencies": {
"fast-diff": "^1.2.0",
Expand Down
50 changes: 50 additions & 0 deletions webpack.config.js
@@ -0,0 +1,50 @@
//@ts-check

"use strict";

const path = require("path");

const webpack = require("webpack");

/**@type {import('webpack').Configuration}*/
const config = {
target: "node", // vscode extensions run in a Node.js-context πŸ“– -> https://webpack.js.org/configuration/node/

entry: "./src/extension.ts", // the entry point of this extension, πŸ“– -> https://webpack.js.org/configuration/entry-context/
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",
libraryTarget: "commonjs2",
devtoolModuleFilenameTemplate: "../[resource-path]",
},
devtool: "source-map",
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/
},
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",
},
],
},
],
},
plugins: [
new webpack.EnvironmentPlugin({
// stop neovim winston spam
NVIM_NODE_LOG_LEVEL: "error",
ALLOW_CONSOLE: true,
}),
],
};
module.exports = config;

0 comments on commit e0c909b

Please sign in to comment.