generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathesbuild.config.mjs
54 lines (51 loc) · 1.46 KB
/
esbuild.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// @ts-check
import {build} from 'esbuild'
import {copy} from 'esbuild-plugin-copy'
import {readFileSync} from 'fs'
/** @type {import('esbuild').Plugin} */
const fixHcl2jsonDirnamePlugin = {
name: 'fixHcl2jsonDirname',
setup(build) {
build.onLoad({filter: /bridge.js/}, ({path: filePath}) => {
// trying to fix the issue with file paths when loading main.wasm.gz from @cdktf/hcl2json
let contents = readFileSync(filePath, 'utf8')
const loader = 'js'
contents = contents.replace('"..", "main.wasm.gz"', `".", "main.wasm.gz"`)
return {
contents,
loader
}
})
}
}
await build({
entryPoints: ['src/index.ts'],
bundle: true,
platform: 'node',
target: 'node20',
external: ['re2', 'dtrace-provider', 'performance'],
outdir: 'dist',
minify: true,
// fix for https://github.com/microsoft/node-jsonc-parser/issues/57
mainFields: ['module', 'main'],
plugins: [
copy({
// this is equal to process.cwd(), which means we use cwd path as base path to resolve `to` path
// if not specified, this plugin uses ESBuild.build outdir/outfile options as base path.
resolveFrom: 'cwd',
assets: [
{
from: ['./node_modules/@cdktf/hcl2json/*.gz'],
to: ['./dist']
},
{
from: ['./node_modules/@one-ini/wasm/*.wasm'],
to: ['./dist']
}
]
}),
fixHcl2jsonDirnamePlugin
],
legalComments: 'linked',
logLevel: 'info'
})