-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
* fix: add node-gyp to native module detection * feat: detect modules with native file * chore: doh
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
// eslint-disable-next-line complexity | ||
const isNativeModule = ({ binary, dependencies = {}, devDependencies = {}, gypfile }) => | ||
Boolean( | ||
dependencies.bindings || | ||
dependencies.prebuild || | ||
dependencies.nan || | ||
dependencies['node-pre-gyp'] || | ||
dependencies['node-gyp-build'] || | ||
devDependencies.prebuild || | ||
devDependencies['node-pre-gyp'] || | ||
devDependencies['node-gyp-build'] || | ||
gypfile || | ||
binary, | ||
) | ||
const { extname } = require('path') | ||
|
||
const markerModules = ['bindings', 'nan', 'node-gyp', 'node-gyp-build', 'node-pre-gyp', 'prebuild'] | ||
|
||
const isNativeModule = ({ binary, dependencies = {}, devDependencies = {}, files = [], gypfile }) => { | ||
if (binary || gypfile) { | ||
return true | ||
} | ||
|
||
const hasMarkerModule = markerModules.some((marker) => dependencies[marker] || devDependencies[marker]) | ||
|
||
if (hasMarkerModule) { | ||
return true | ||
} | ||
|
||
const hasBinaryFile = files.some((path) => !path.startsWith('!') && extname(path) === '.node') | ||
|
||
return hasBinaryFile | ||
} | ||
|
||
module.exports = { isNativeModule } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
module.exports = require('test') | ||
const moduleWithNodeFile = require('module-with-node-file') | ||
const moduleWithNodeGyp = require('module-with-node-gyp') | ||
const moduleWithPrebuild = require('module-with-prebuild') | ||
|
||
module.exports = [moduleWithNodeFile, moduleWithNodeGyp, moduleWithPrebuild] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
2de5426
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏱ Benchmark results
largeDepsEsbuild: 12.8s
largeDepsZisi: 1m 9.5s