.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-eslint / esbuild.js
1 const path = require('path')
2 const isProduction = process.env.NODE_ENV == 'production'
3
4 let entryPlugin = {
5   name: 'entry',
6   setup(build) {
7     build.onResolve({filter: /^(index|server)\.ts$/}, args => {
8       return {
9         path: args.path,
10         namespace: 'entry-ns'
11       }
12     })
13     build.onLoad({filter: /.*/, namespace: 'entry-ns'}, args => {
14       let contents = ''
15       if (args.path == 'index.ts') {
16         contents = `
17         import {activate, deactivate} from './src/index'
18         export {activate, deactivate}
19         `
20       } else if (args.path == 'server.ts') {
21         contents = `require('./server/eslintServer')`
22       } else {
23         throw new Error('Bad path')
24       }
25       return {
26         contents,
27         resolveDir: __dirname
28       }
29     })
30   }
31 }
32
33 async function start() {
34   await require('esbuild').build({
35     entryPoints: ['index.ts', 'server.ts'],
36     define: {'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')},
37     bundle: true,
38     platform: 'node',
39     target: 'node12.16',
40     mainFields: ['module', 'main'],
41     minify: isProduction,
42     sourcemap: !isProduction,
43     external: ['coc.nvim'],
44     outdir: path.resolve(__dirname, 'lib'),
45     plugins: [entryPlugin]
46   })
47 }
48
49 start().catch(e => {
50   console.error(e)
51 })