import type { InputPluginOption } from "rollup"; import reactPlugins, { type EditableSourceCodeOnInstanceOptions, } from "./react-plugins"; import type { RegisterExplicitIdFunction, Credential } from "./types"; import type { IsomorphicRollupFs } from "../fs-iface"; interface ServicenowFrontEndPluginsOptions { type?: "react"; scope: string; rootDir: string; /** * Absolute path to the project root directory. Required when * `editableSourceCodeOnInstance` is true. */ projectRootDir?: string; registerExplicitId?: RegisterExplicitIdFunction; // not called when dev: true dev?: boolean; enableCacheBusting?: boolean; /** * When true, embeds the original source code (via `jsxSource`) and * emits a `uiPageSourceManifest` so the shipped bundle can be edited * in-place on a ServiceNow instance and with ServiceNow Build Agent. * * @default false */ editableSourceCodeOnInstance?: boolean | EditableSourceCodeOnInstanceOptions; /** * @deprecated Use `editableSourceCodeOnInstance` instead. */ embedSourceCodeAndHints?: boolean; // The following options only apply when dev: true watchPaths?: string[]; proxyPaths?: string[]; credential?: Credential; httpProxy?: string; omitDevUxGlobals?: boolean; fs?: IsomorphicRollupFs; } export const servicenowFrontEndPlugins = async ({ type = "react", scope, rootDir, projectRootDir, registerExplicitId, dev = false, enableCacheBusting = true, editableSourceCodeOnInstance, embedSourceCodeAndHints, watchPaths = [], proxyPaths = [ "/api", "/amb", "/scripts/", "/images/@servicenow/", "/uxasset/externals", "/$uxappimmutables.do", "/uxta", ], credential, httpProxy, omitDevUxGlobals = false, fs, }: ServicenowFrontEndPluginsOptions): Promise => { switch (type) { case "react": { return await reactPlugins({ scope, rootDir, projectRootDir, registerExplicitId, dev, enableCacheBusting, editableSourceCodeOnInstance, embedSourceCodeAndHints, credential, httpProxy, watchPaths, proxyPaths, omitDevUxGlobals, fs, }); } default: { return []; } } };