Skip to content

Commit 5abe6f2

Browse files
committed
feat: support environments without require
Add runtime check for require availability before accessing module.builtinModules, allowing the package to work in non-CommonJS environments like ESM or browsers. close #124
1 parent 312acad commit 5abe6f2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
const { builtinModules: builtins } = require('module')
2+
const builtins = typeof require !== 'undefined' ? require('module').builtinModules : []
33

44
var scopedPackagePattern = new RegExp('^(?:@([^/]+?)[/])?([^/]+?)$')
55
var exclusionList = [

0 commit comments

Comments
 (0)