use esbuild replace webpack

This commit is contained in:
Qiming Zhao 2021-01-06 17:42:01 +08:00
parent a24ce777ee
commit 6d3036523e
5 changed files with 34 additions and 1176 deletions

18
esbuild.js Normal file
View file

@ -0,0 +1,18 @@
async function start() {
await require('esbuild').build({
entryPoints: ['src/index.ts'],
bundle: true,
minify: process.env.NODE_ENV === 'production',
sourcemap: process.env.NODE_ENV === 'development',
mainFields: ['module', 'main'],
external: ['coc.nvim', 'typescript'],
platform: 'node',
target: 'node10.12',
outfile: 'lib/index.js'
})
}
start().catch(e => {
console.error(e)
})

View file

@ -5,7 +5,7 @@
"main": "lib/index.js",
"publisher": "chemzqm",
"engines": {
"coc": "^0.0.79"
"coc": "^0.0.80"
},
"repository": {
"type": "git",
@ -17,8 +17,7 @@
"typescript"
],
"scripts": {
"build": "webpack",
"prepare": "webpack"
"build": "node esbuild.js"
},
"activationEvents": [
"onLanguage:javascript",
@ -622,13 +621,11 @@
"license": "MIT",
"devDependencies": {
"@types/node": "^10.12.0",
"coc.nvim": "^0.0.79-next.18",
"coc.nvim": "^0.0.80",
"semver": "^7.3.2",
"ts-loader": "^8.0.1",
"vscode-languageserver-protocol": "^3.15.3",
"which": "^2.0.2",
"webpack": "^5.11.0",
"webpack-cli": "^4.2.0"
"esbuild": "^0.8.29",
"which": "^2.0.2"
},
"dependencies": {
"typescript": "^4.1.3"

View file

@ -7,9 +7,6 @@ import fs from 'fs'
import path from 'path'
import API from './api'
import { TypeScriptServiceConfiguration } from './configuration'
declare var __webpack_require__: any
declare var __non_webpack_require__: any
const requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require
export class TypeScriptVersion {
private _api: API | null | undefined
@ -125,7 +122,7 @@ export class TypeScriptVersionProvider {
public get bundledVersion(): TypeScriptVersion | null {
try {
const file = requireFunc.resolve('typescript')
const file = require.resolve('typescript')
const bundledVersion = new TypeScriptVersion(
path.dirname(file),
'')

View file

@ -1,41 +0,0 @@
const path = require('path')
module.exports = {
entry: './src/index.ts',
target: 'node',
mode: 'none',
resolve: {
mainFields: ['module', 'main'],
extensions: ['.js', '.ts']
},
externals: {
'coc.nvim': 'commonjs coc.nvim',
'typescript': 'commonjs typescript'
},
module: {
rules: [{
test: /\.ts$/,
exclude: /node_modules/,
use: [{
loader: 'ts-loader',
options: {
compilerOptions: {
"sourceMap": true,
}
}
}]
}]
},
output: {
path: path.join(__dirname, 'lib'),
filename: 'index.js',
libraryTarget: "commonjs",
},
plugins: [
],
node: {
__dirname: false,
__filename: false
}
}

1133
yarn.lock

File diff suppressed because it is too large Load diff