Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to esbuild for building the library #116

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,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?://" // Regex to mark all HTTP imports as external
oleiade marked this conversation as resolved.
Show resolved Hide resolved
],

// 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))
2 changes: 1 addition & 1 deletion examples/signature-presign.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import http from 'k6/http'
import { check } from 'k6'

import { AWSConfig, Endpoint, SignatureV4, AMZ_CONTENT_SHA256_HEADER } from '../dist/aws.js'
import { AWSConfig, Endpoint, SignatureV4, AMZ_CONTENT_SHA256_HEADER } from '../dist/index.js'

const awsConfig = new AWSConfig({
region: __ENV.AWS_REGION,
Expand Down
Loading
Loading