Compare commits

..

2 Commits

Author SHA1 Message Date
Derrick Hammer 366ffe1ac9
*Update dist 2022-12-31 22:45:26 -05:00
Derrick Hammer d220d9831e
*Add support for node-gyp-build-optional-packages 2022-12-31 22:45:07 -05:00
2 changed files with 70 additions and 57 deletions

11
dist/index.js vendored
View File

@ -69,7 +69,8 @@ function bundleNativeModulesPlugin() {
// Not edited
return edits.push([node.start, node.end]);
}
const findLoady = (0, ast_matcher_1.default)("require('loady')(__str_aName, __any)");
for (const matchString of ["require('loady')(__str_aName, __any)"]) {
const findLoady = (0, ast_matcher_1.default)(matchString);
const loadyMatches = findLoady(ast);
if (loadyMatches?.length) {
for (const match of loadyMatches) {
@ -81,7 +82,12 @@ function bundleNativeModulesPlugin() {
}
}
}
const findNodeBuildGyp = (0, ast_matcher_1.default)("require('node-gyp-build')(__any)");
}
for (const matchString of [
"require('node-gyp-build')(__any)",
"loadNAPI(__any)",
]) {
const findNodeBuildGyp = (0, ast_matcher_1.default)(matchString);
const nodeBuildGypMatches = findNodeBuildGyp(ast);
if (nodeBuildGypMatches?.length) {
for (const match of nodeBuildGypMatches) {
@ -99,6 +105,7 @@ function bundleNativeModulesPlugin() {
}
}
}
}
if (edits.length === 0) {
return null;
}

View File

@ -80,7 +80,8 @@ export default function bundleNativeModulesPlugin() {
return edits.push([node.start, node.end]);
}
const findLoady = astMatcher("require('loady')(__str_aName, __any)");
for (const matchString of ["require('loady')(__str_aName, __any)"]) {
const findLoady = astMatcher(matchString);
const loadyMatches = findLoady(ast);
if (loadyMatches?.length) {
@ -97,8 +98,13 @@ export default function bundleNativeModulesPlugin() {
}
}
}
}
const findNodeBuildGyp = astMatcher("require('node-gyp-build')(__any)");
for (const matchString of [
"require('node-gyp-build')(__any)",
"loadNAPI(__any)",
]) {
const findNodeBuildGyp = astMatcher(matchString);
const nodeBuildGypMatches = findNodeBuildGyp(ast);
if (nodeBuildGypMatches?.length) {
@ -121,7 +127,7 @@ export default function bundleNativeModulesPlugin() {
}
}
}
}
if (edits.length === 0) {
return null;
}