one
Version:
One is a new React Framework that makes Vite serve both native and web.
32 lines (31 loc) • 1.02 kB
JavaScript
import { isBuiltin } from "module";
import path from "path";
function nodeExternals() {
return {
name: `node-externals`,
enforce: "pre",
resolveId: {
order: "pre",
async handler(specifier, importer, options) {
if (options === null || options === void 0 ? void 0 : options.scan) return null;
if ((options === null || options === void 0 ? void 0 : options.isEntry) ||
// Ignore entry points (they should always be resolved)
/^(?:\0|\.{1,2}\/)/.test(specifier) ||
// Ignore virtual modules and relative imports
path.isAbsolute(specifier)) {
return null;
}
if (isBuiltin(specifier)) {
var stripped = specifier.replace(/^node:/, "");
return {
id: !isBuiltin(stripped) ? "node:" + stripped : stripped,
external: true,
moduleSideEffects: false
};
}
}
}
};
}
export { nodeExternals };
//# sourceMappingURL=customNodeExternals.native.js.map