Skip to content

Commit

Permalink
Make 'npm run webpack' produce multiple dedicated bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Apr 14, 2022
1 parent fecc84e commit c35db23
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
// listBuckets,
AWSConfig,
S3Client,
} from 'https://jslib.k6.io/aws/0.2.0/index.js'
} from 'https://jslib.k6.io/aws/0.3.0/s3.js'

const testFile = open('./bonjour.txt', 'r')

Expand Down Expand Up @@ -69,7 +69,7 @@ export default function () {
```javascript
import exec from 'k6/execution'

import { AWSConfig, SecretsManagerClient } from 'https://jslib.k6.io/aws/0.2.0/index.js'
import { AWSConfig, SecretsManagerClient } from 'https://jslib.k6.io/aws/0.3.0/secrets-manager.js'

const awsConfig = new AWSConfig(
__ENV.AWS_REGION,
Expand Down
2 changes: 2 additions & 0 deletions build/s3.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/s3.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions build/secrets-manager.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/secrets-manager.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/s3.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import exec from 'k6/execution'

import { AWSConfig, S3Client } from '../build/aws.min.js'
import { AWSConfig, S3Client } from '../build/s3.min.js'

const testFile = open('./bonjour.txt', 'r')

Expand Down
2 changes: 1 addition & 1 deletion examples/secrets-manager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import exec from 'k6/execution'

import { AWSConfig, SecretsManagerClient } from '../build/aws.min.js'
import { AWSConfig, SecretsManagerClient } from '../build/secrets-manager.min.js'

const awsConfig = new AWSConfig(
__ENV.AWS_REGION,
Expand Down
19 changes: 19 additions & 0 deletions src/s3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Import only symbols we wish to re-export publicly
import { InvalidSignatureError, URIEncodingConfig } from './internal/signature'
import { AWSConfig, InvalidAWSConfigError } from './internal/config'
import { S3Client, S3Bucket, S3Object, S3ServiceError } from './internal/s3'

// Re-Export public symbols
export {
// AWS Signature V4
InvalidSignatureError,
URIEncodingConfig,
// Aws Config
AWSConfig,
InvalidAWSConfigError,
// S3
S3Client,
S3Bucket,
S3Object,
S3ServiceError,
}
19 changes: 19 additions & 0 deletions src/secrets-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Import only symbols we wish to re-export publicly
import { signHeaders, InvalidSignatureError, URIEncodingConfig } from './internal/signature'
import { AWSConfig, InvalidAWSConfigError } from './internal/config'
import { SecretsManagerClient, Secret, SecretsManagerError } from './internal/secrets-manager'

// Re-Export public symbols
export {
// AWS Signature V4
signHeaders,
InvalidSignatureError,
URIEncodingConfig,
// Aws Config
AWSConfig,
InvalidAWSConfigError,
// SecretsManager
SecretsManagerClient,
Secret,
SecretsManagerError,
}
10 changes: 6 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ const TerserPlugin = require('terser-webpack-plugin')

module.exports = {
mode: 'production',
// entry: './src/index.js',
entry: GlobEntries('./src/index.ts'),
entry: {
aws: path.resolve(__dirname, './src/index.ts'),
s3: path.resolve(__dirname, './src/s3.ts'),
'secrets-manager': path.resolve(__dirname, './src/secrets-manager.ts'),
},
output: {
path: path.resolve(__dirname, 'build'),
libraryTarget: 'commonjs',
filename: 'aws.min.js',
filename: '[name].min.js',
},
resolve: {
extensions: ['.ts', '.js'],
Expand All @@ -34,7 +37,6 @@ module.exports = {
},
plugins: [
new CleanWebpackPlugin(),

// Copy assets to the destination folder
// see `src/post-file-test.ts` for an test example using an asset
new CopyPlugin({
Expand Down

0 comments on commit c35db23

Please sign in to comment.