Skip to content

Commit

Permalink
usage: report require usage
Browse files Browse the repository at this point in the history
It will be nice to know how many people use require and potentially
commonJS.

Note: this reports each invocation of `require` but adding sync.Once to
this seems overkill and it is probably okay to have the statistics
either way.
  • Loading branch information
mstoykov committed Sep 13, 2024
1 parent 8d44f44 commit 88629d3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions js/modules/require_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (

// Require is the actual call that implements require
func (ms *ModuleSystem) Require(specifier string) (*sobek.Object, error) {
if err := ms.resolver.usage.Uint64("usage/require", 1); err != nil {
ms.resolver.logger.WithError(err).Warn("couldn't report usage")
}

if specifier == "" {
return nil, errors.New("require() can't be used with an empty specifier")
}
Expand Down

0 comments on commit 88629d3

Please sign in to comment.