File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 66'use strict'
77const instrumentedLibraries = require ( './lib/instrumentations' ) ( ) || { }
88const libNames = Object . keys ( instrumentedLibraries )
9+ const subscriptions = require ( './lib/subscriber-configs' )
10+ const subscribers = Object . keys ( subscriptions )
11+ const packages = [ ...libNames , ...subscribers ]
12+
13+ /**
14+ * This is to be used with bundlers. It will add all of our instrumented 3rd party modules
15+ * into the `externals` array.
16+ *
17+ * **Note** Only tested with `webpack`, [see](https://webpack.js.org/configuration/externals/)
18+ *
19+ * @param {object } config bundler config
20+ */
921module . exports = function loadExternals ( config ) {
1022 if ( config . target . includes ( 'node' ) ) {
11- config . externals . push ( ...libNames )
23+ config . externals . push ( ...packages )
1224 }
1325
1426 return config
Original file line number Diff line number Diff line change @@ -13,19 +13,20 @@ const loadExternals = require('../../load-externals')
1313test ( 'should load libs to webpack externals' , async ( ) => {
1414 const config = {
1515 target : 'node-20.x' ,
16- externals : [ 'next ' ]
16+ externals : [ 'test-pkg ' ]
1717 }
1818 loadExternals ( config )
19+ // This number is arbitrary but accounts for legacy instrumentation + subscriber instrumentation
1920 assert . ok (
20- config . externals . length > 1 ,
21- ' should add all libraries agent supports to the externals list'
21+ config . externals . length > 40 ,
22+ ` should add all libraries agent supports to the externals list, got ${ config . externals . length } `
2223 )
2324} )
2425
2526test ( 'should not add externals when target is not node' , async ( ) => {
2627 const config = {
2728 target : 'web' ,
28- externals : [ 'next ' ]
29+ externals : [ 'test-pkg ' ]
2930 }
3031 loadExternals ( config )
3132 assert . ok ( config . externals . length === 1 , 'should not agent libraries when target is not node' )
You can’t perform that action at this time.
0 commit comments