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

View file

@ -7,9 +7,6 @@ import fs from 'fs'
import path from 'path' import path from 'path'
import API from './api' import API from './api'
import { TypeScriptServiceConfiguration } from './configuration' 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 { export class TypeScriptVersion {
private _api: API | null | undefined private _api: API | null | undefined
@ -125,7 +122,7 @@ export class TypeScriptVersionProvider {
public get bundledVersion(): TypeScriptVersion | null { public get bundledVersion(): TypeScriptVersion | null {
try { try {
const file = requireFunc.resolve('typescript') const file = require.resolve('typescript')
const bundledVersion = new TypeScriptVersion( const bundledVersion = new TypeScriptVersion(
path.dirname(file), 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