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