-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathbuild.mjs
61 lines (49 loc) · 1.92 KB
/
build.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
55
56
57
58
59
60
61
import { build } from 'esbuild';
import * as process from 'node:process'
const buildOptions = {
// Produce the build results in the dist folder
outdir: 'dist',
// Map source code typescript files to their output files (dist/*.js)
entryPoints: [
{ in: 'src/index.ts', out: 'index' },
{ in: 'src/s3.ts', out: 's3' },
{ in: 'src/secrets-manager.ts', out: 'secrets-manager' },
{ in: 'src/sqs.ts', out: 'sqs' },
{ in: 'src/ssm.ts', out: 'ssm' },
{ in: 'src/kms.ts', out: 'kms' },
{ in: 'src/kinesis.ts', out: 'kinesis' },
{ in: 'src/event-bridge.ts', out: 'event-bridge' },
{ in: 'src/lambda.ts', out: 'lambda' },
{ in: 'src/signature.ts', out: 'signature' },
],
// k6 supports the ES module format, and using it avoids transpiling and leads
// to faster time to start a test, and better overall test performance.
format: 'esm',
// k6 JS runtime is browser-like.
platform: 'browser',
// Bundle all dependencies into the output file(s)
bundle: true,
// Generate source maps for the output files
sourcemap: true,
// Allow importing modules from the 'k6' package, all its submodules, and
// all HTTP(S) URLs (jslibs).
external: [
'k6', // Mark the 'k6' package as external
'k6/*', // Mark all submodules of 'k6' as external
"/^https:\\/\\/jslib\\.k6\\.io\\/.*" // Regex to mark all jslib imports as external
],
// By default, no minification is applied
minify: false,
};
// Determine if this is a release build or a development build
if (process.env.NODE_ENV === 'production') {
// Setup release build options
Object.assign(buildOptions, {
// Minify the output files
minify: true,
// Drop debugger and console statements
drop: ['debugger', 'console'],
})
}
// Build the project
build(buildOptions).catch(() => process.exit(1))