Skip to content

Commit caf7cb5

Browse files
authored
chore: update to webpack 5 (open-telemetry#2269)
* chore: update webpack * chore: sync package-lock.json * chore: re-format deps * fix: use correct api dependency, remove unused * chore: remove unused codecov * chore: remove unused deps * chore: add assert package * chore: remove more unused packages * chore: remove more unused dependencies
1 parent dadf308 commit caf7cb5

File tree

12 files changed

+24704
-19290
lines changed

12 files changed

+24704
-19290
lines changed

examples/web/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@babel/core": "^7.21.8",
3131
"babel-loader": "^8.3.0",
3232
"ts-loader": "^6.2.2",
33-
"webpack": "^4.46.0",
33+
"webpack": "5.89.0",
3434
"webpack-cli": "^3.3.12",
3535
"webpack-dev-server": "^3.11.3",
3636
"webpack-merge": "^4.2.2"

karma.base.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ module.exports = {
1919
hostname: 'localhost',
2020
browsers: ['ChromeHeadless'],
2121
frameworks: ['mocha'],
22-
coverageIstanbulReporter: {
23-
reports: ['json'],
24-
dir: '.nyc_output',
25-
fixWebpackSourcePaths: true
22+
coverageReporter: {
23+
type : 'json',
24+
subdir: '.',
25+
dir : '.nyc_output/'
2626
},
27-
reporters: ['spec', 'coverage-istanbul'],
27+
reporters: ['spec', 'coverage'],
2828
files: ['test/index-webpack.ts'],
29-
preprocessors: { 'test/index-webpack.ts': ['webpack'] },
29+
preprocessors: {
30+
'test/index-webpack*.ts': ['webpack']
31+
},
3032
webpackMiddleware: { noInfo: true }
3133
};

karma.webpack.js

+41-13
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,61 @@
1414
* limitations under the License.
1515
*/
1616

17-
const webpackNodePolyfills = require('./webpack.node-polyfills.js');
17+
const webpack = require('webpack')
1818

1919
// This is the webpack configuration for browser Karma tests with coverage.
2020
module.exports = {
2121
mode: 'development',
2222
target: 'web',
23-
output: { filename: 'bundle.js' },
24-
resolve: { extensions: ['.ts', '.js', '.tsx'] },
25-
devtool: 'inline-source-map',
23+
output: {filename: 'bundle.js'},
24+
resolve: {
25+
extensions: ['.ts', '.js', '.tsx'],
26+
fallback: {
27+
// Enable the assert library polyfill because that is used in tests
28+
"assert": require.resolve('assert/'),
29+
"util": require.resolve('util/'),
30+
},
31+
},
32+
devtool: 'eval-source-map',
33+
plugins: [
34+
new webpack.ProvidePlugin({
35+
// Make a global `process` variable that points to the `process` package,
36+
// because the `util` package expects there to be a global variable named `process`.
37+
// Thanks to https://stackoverflow.com/a/65018686/14239942
38+
// NOTE: I wish there was a better way as this pollutes the tests with a defined 'process' global.
39+
process: 'process/browser'
40+
})
41+
],
2642
module: {
2743
rules: [
2844
{ test: /\.tsx?$/, use: 'ts-loader' },
45+
{
46+
test: /\.js$/,
47+
exclude: {
48+
and: [/node_modules/], // Exclude libraries in node_modules ...
49+
not: [
50+
// Except for a few of them that needs to be transpiled because they use modern syntax
51+
/zone.js/,
52+
],
53+
},
54+
use: {
55+
loader: 'babel-loader',
56+
options: {
57+
presets: ['@babel/preset-env'],
58+
}
59+
},
60+
},
2961
{
3062
enforce: 'post',
3163
exclude: /(node_modules|\.test\.[tj]sx?$)/,
3264
test: /\.ts$/,
3365
use: {
34-
loader: '@jsdevtools/coverage-istanbul-loader',
66+
loader: 'babel-loader',
3567
options: {
36-
produceSourceMap: false,
37-
esModules: true
68+
plugins: ['babel-plugin-istanbul'],
3869
}
39-
}
70+
},
4071
},
41-
// This setting configures Node polyfills for the browser that will be
42-
// added to the webpack bundle for Karma tests.
43-
{ parser: { node: webpackNodePolyfills } }
44-
]
45-
}
72+
],
73+
},
4674
};

metapackages/auto-instrumentations-web/package.json

+19-16
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,33 @@
3535
"zone.js": "^0.11.4 || ^0.13.0 || ^0.14.0"
3636
},
3737
"devDependencies": {
38-
"@babel/core": "7.22.17",
39-
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
38+
"@babel/core": "7.24.6",
39+
"@babel/preset-env": "7.24.6",
4040
"@opentelemetry/api": "^1.3.0",
41-
"@types/mocha": "8.2.3",
41+
"@types/mocha": "10.0.6",
4242
"@types/node": "18.6.5",
43-
"@types/sinon": "10.0.18",
44-
"@types/webpack-env": "1.16.2",
45-
"babel-loader": "8.2.2",
46-
"karma": "6.3.16",
47-
"karma-chrome-launcher": "^3.1.1",
48-
"karma-coverage-istanbul-reporter": "3.0.3",
43+
"@types/sinon": "17.0.3",
44+
"@types/webpack-env": "1.16.3",
45+
"assert": "2.0.0",
46+
"babel-loader": "8.3.0",
47+
"babel-plugin-istanbul": "6.1.1",
48+
"cross-var": "1.1.0",
49+
"karma": "6.4.3",
50+
"karma-chrome-launcher": "3.1.0",
51+
"karma-coverage": "2.2.1",
4952
"karma-mocha": "2.0.1",
5053
"karma-spec-reporter": "0.0.36",
51-
"karma-webpack": "4.0.2",
52-
"mocha": "7.2.0",
54+
"karma-webpack": "5.0.1",
55+
"mocha": "10.2.0",
5356
"nyc": "15.1.0",
5457
"rimraf": "5.0.5",
55-
"sinon": "15.2.0",
56-
"ts-loader": "8.3.0",
58+
"sinon": "15.1.2",
59+
"ts-loader": "9.5.1",
5760
"ts-mocha": "10.0.0",
5861
"typescript": "4.4.4",
59-
"webpack": "4.46.0",
60-
"webpack-cli": "4.7.2",
61-
"webpack-merge": "5.8.0"
62+
"webpack": "5.89.0",
63+
"webpack-cli": "5.1.4",
64+
"webpack-merge": "5.10.0"
6265
},
6366
"dependencies": {
6467
"@opentelemetry/instrumentation": "^0.52.0",

0 commit comments

Comments
 (0)