Skip to content

Commit f986a64

Browse files
committed
bundle autoinstrumentation package with webpack
1 parent 225ce69 commit f986a64

File tree

5 files changed

+867
-8
lines changed

5 files changed

+867
-8
lines changed

aws-distro-opentelemetry-node-autoinstrumentation/package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"repository": "aws-observability/aws-otel-js-instrumentation",
2323
"scripts": {
2424
"clean": "rimraf build/*",
25-
"compile": "tsc -p .",
25+
"compile:tsc": "tsc -p .",
26+
"compile:webpack": "webpack",
27+
"compile": "npm run compile:webpack",
2628
"lint": "eslint . --ext .ts",
2729
"lint:fix": "eslint . --ext .ts --fix",
2830
"create-version": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
@@ -93,8 +95,11 @@
9395
"proxyquire": "^2.1.3",
9496
"rimraf": "5.0.5",
9597
"sinon": "15.2.0",
98+
"ts-loader": "^9.5.2",
9699
"ts-mocha": "10.0.0",
97-
"typescript": "4.4.4"
100+
"typescript": "4.4.4",
101+
"webpack": "^5.98.0",
102+
"webpack-cli": "^6.0.1"
98103
},
99104
"dependencies": {
100105
"@opentelemetry/api": "1.9.0",
@@ -119,8 +124,8 @@
119124
},
120125
"files": [
121126
"build/src/**/*.js",
122-
"build/src/**/*.js.map",
123127
"build/src/**/*.d.ts",
124-
"build/src/**/*.json"
128+
"build/src/**/*.d.ts.map",
129+
"build/workspace/node_modules/**"
125130
]
126131
}

aws-distro-opentelemetry-node-autoinstrumentation/test/patches/instrumentation-patch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { AWSXRAY_TRACE_ID_HEADER, AWSXRayPropagator } from '@opentelemetry/propa
2525
import { Context } from 'aws-lambda';
2626
import { SinonStub } from 'sinon';
2727
import { Lambda } from '@aws-sdk/client-lambda';
28-
import nock = require('nock');
28+
import * as nock from 'nock';
2929
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
3030
import { getTestSpans } from '@opentelemetry/contrib-test-utils';
3131
import { instrumentationConfigs } from '../../src/register';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "es2020",
5+
"target": "es2020",
6+
"moduleResolution": "node",
7+
},
8+
"exclude": [
9+
"node_modules",
10+
]
11+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
entry: './src/register.ts',
5+
target: 'node',
6+
mode: 'production',
7+
externalsPresets: { node: true },
8+
externals: [
9+
'import-in-the-middle',
10+
],
11+
output: {
12+
path: path.resolve('./build/src'),
13+
filename: 'register.js',
14+
library: {
15+
type: 'commonjs2',
16+
}
17+
},
18+
resolve: {
19+
extensions: ['.ts', '.js'],
20+
modules: [
21+
path.resolve('./src'),
22+
'node_modules',
23+
],
24+
},
25+
module: {
26+
rules: [
27+
{
28+
test: /\.ts$/,
29+
use: [
30+
{
31+
loader: 'ts-loader',
32+
options: {
33+
configFile: 'tsconfig.webpack.json'
34+
},
35+
}
36+
],
37+
exclude: /node_modules/,
38+
},
39+
],
40+
},
41+
optimization: {
42+
minimize: true,
43+
providedExports: true,
44+
usedExports: true,
45+
},
46+
};

0 commit comments

Comments
 (0)