File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const { build } = require('esbuild')
2
2
const { polyfillNode } = require ( 'esbuild-plugin-polyfill-node' ) ;
3
3
const { rimraf } = require ( 'rimraf' )
4
4
const fs = require ( 'fs' )
5
+ const { version } = require ( './package.json' ) ;
5
6
6
7
const outdir = 'dist'
7
8
@@ -15,6 +16,9 @@ const options = {
15
16
format : 'iife' ,
16
17
platform : 'browser' ,
17
18
globalName : 'mqtt' ,
19
+ define : {
20
+ 'process.env.npm_package_version' : JSON . stringify ( version ) ,
21
+ } ,
18
22
sourcemap : false , // this can be enabled while debugging, if we decide to keep this enabled we should also ship the `src` folder to npm
19
23
plugins : [
20
24
polyfillNode ( {
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import {
38
38
import TopicAliasSend from './topic-alias-send'
39
39
import { TypedEventEmitter } from './TypedEmitter'
40
40
import PingTimer from './PingTimer'
41
+ import isBrowser , { isWebWorker } from './is-browser'
41
42
42
43
const setImmediate =
43
44
globalThis . setImmediate ||
@@ -488,6 +489,17 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac
488
489
this . log = this . options . log || _debug ( 'mqttjs:client' )
489
490
this . noop = this . _noop . bind ( this )
490
491
492
+ this . log ( 'MqttClient :: version:' , process . env . npm_package_version )
493
+
494
+ if ( isWebWorker ) {
495
+ this . log ( 'MqttClient :: environment' , 'webworker' )
496
+ } else {
497
+ this . log (
498
+ 'MqttClient :: environment' ,
499
+ isBrowser ? 'browser' : 'node' ,
500
+ )
501
+ }
502
+
491
503
this . log ( 'MqttClient :: options.protocol' , options . protocol )
492
504
this . log (
493
505
'MqttClient :: options.protocolVersion' ,
You can’t perform that action at this time.
0 commit comments