JavaScriptAppResource

Handle
📦 Aspire.Hosting.JavaScript v17.0.0
interface JavaScriptAppResource
extends IComputeResource,
IResource,
IResourceWithArgs,
IResourceWithEndpoints,
IResourceWithEnvironment,
IResourceWithProbes,
IResourceWithWaitSupport,
IResourceWithContainerFiles,
IResourceWithServiceDiscovery {
readonly resourceTypeDisplayName: string;
publishAsNodeServer(
entryPoint: string,
outputPath?: string): JavaScriptAppResource;
publishAsPackageScript(
scriptName?: string,
runScriptArguments?: string): JavaScriptAppResource;
publishAsStaticWebsite(
apiPath?: string,
apiTarget?: IResourceWithServiceDiscovery,
outputPath?: string,
stripPrefix?: boolean,
targetEndpointName?: string): JavaScriptAppResource;
withBrowserDebugger(browser?: string): JavaScriptAppResource;
withBuildScript(
scriptName: string,
args?: string[]): JavaScriptAppResource;
withBun(
install?: boolean,
installArgs?: string[]): JavaScriptAppResource;
withDeno(
install?: boolean,
installArgs?: string[]): JavaScriptAppResource;
withNpm(
install?: boolean,
installCommand?: string,
installArgs?: string[]): JavaScriptAppResource;
withPnpm(
install?: boolean,
installArgs?: string[]): JavaScriptAppResource;
withRunScript(
scriptName: string,
args?: string[]): JavaScriptAppResource;
withYarn(
install?: boolean,
installArgs?: string[]): JavaScriptAppResource;
}

Properties

propertyresourceTypeDisplayNamestringget
Gets the ResourceTypeDisplayName property

Methods

methodpublishAsNodeServerbuilder
Configures the JavaScript application to publish as a standalone Node.js server that runs a built artifact directly.
publishAsNodeServer(
entryPoint: string,
outputPath?: string): JavaScriptAppResource
entryPointstringThe relative path to the Node.js entry point to execute in the published container after the build completes, such as `.output/server/index.mjs` or `build/index.js`.
outputPathstringoptional= .The relative path containing the built runtime files to copy into the published container. Defaults to the application root.
JavaScriptAppResource
Configures the JavaScript application to publish as a server that runs a package manager script at runtime.
publishAsPackageScript(
scriptName?: string,
runScriptArguments?: string): JavaScriptAppResource
scriptNamestringoptional= startThe name of the script to run in the published container. For Node.js and Bun applications this is a `package.json` script; for Deno applications it is a task defined in `deno.json`. For example, `start` invokes the configured package manager's run command for the `start` script, such as `npm run start`, `pnpm run start`, `yarn run start`, `bun run start`, or `deno task start`.
runScriptArgumentsstringoptionalOptional arguments appended after the script name at runtime, such as `-- --port "$PORT"`.
JavaScriptAppResource
Publishes the JavaScript application as a standalone static website using YARP.
publishAsStaticWebsite(
apiPath?: string,
apiTarget?: IResourceWithServiceDiscovery,
outputPath?: string,
stripPrefix?: boolean,
targetEndpointName?: string): JavaScriptAppResource
apiPathstringoptional
apiTargetIResourceWithServiceDiscoveryoptional
outputPathstringoptional= dist
stripPrefixbooleanoptional= False
targetEndpointNamestringoptional
JavaScriptAppResource
methodwithBrowserDebuggerbuilder
Configures a browser debugger for the JavaScript application resource, enabling browser-based debugging through a child resource that launches when the parent application is ready.
withBrowserDebugger(browser?: string): JavaScriptAppResource
browserstringoptional= msedgeThe browser to use for debugging. Defaults to `"msedge"`. Supported values include `"msedge"` and `"chrome"`.
JavaScriptAppResource
methodwithBuildScriptbuilder
Adds a build script annotation to the resource builder using the specified command-line arguments.
withBuildScript(
scriptName: string,
args?: string[]): JavaScriptAppResource
scriptNamestringThe name of the script to be executed when the resource is built.
argsstring[]optionalAn array of command-line arguments to use for the build script.
JavaScriptAppResource
methodwithBunbuilder
Configures the JavaScript resource to use Bun as the package manager and optionally installs packages before the application starts.
withBun(
install?: boolean,
installArgs?: string[]): JavaScriptAppResource
installbooleanoptional= TrueWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installArgsstring[]optionalAdditional command-line arguments passed to "bun install". When null, defaults are applied based on publish mode and lockfile presence.
JavaScriptAppResource
methodwithDenobuilder
Configures the JavaScript resource to use Deno as the package manager.
withDeno(
install?: boolean,
installArgs?: string[]): JavaScriptAppResource
installbooleanoptional= FalseWhen `true`, creates an installer resource that runs `deno install` before the application starts. Defaults to `false`: unlike npm/Bun, Deno does not require a separate install step — `deno run` fetches and caches dependencies under `DENO_DIR` on first use — so no installer is wired by default. Set to `true` to pre-cache dependencies or to materialize a `node_modules` folder for Node compatibility.
installArgsstring[]optionalAdditional command-line arguments passed to `deno install`.
JavaScriptAppResource
methodwithNpmbuilder
Configures the Node.js resource to use npm as the package manager and optionally installs packages before the application starts.
withNpm(
install?: boolean,
installCommand?: string,
installArgs?: string[]): JavaScriptAppResource
installbooleanoptional= TrueWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installCommandstringoptionalThe install command itself passed to npm to install dependencies.
installArgsstring[]optionalThe command-line arguments passed to npm to install dependencies.
JavaScriptAppResource
methodwithPnpmbuilder
Configures the Node.js resource to use pnpm as the package manager and optionally installs packages before the application starts.
withPnpm(
install?: boolean,
installArgs?: string[]): JavaScriptAppResource
installbooleanoptional= TrueWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installArgsstring[]optionalThe command-line arguments passed to "pnpm install".
JavaScriptAppResource
methodwithRunScriptbuilder
Adds a run script annotation to the specified JavaScript application resource builder, specifying the script to execute and its arguments during run mode.
withRunScript(
scriptName: string,
args?: string[]): JavaScriptAppResource
scriptNamestringThe name of the script to be executed when the resource is run.
argsstring[]optionalAn array of arguments to pass to the script.
JavaScriptAppResource
methodwithYarnbuilder
Configures the Node.js resource to use yarn as the package manager and optionally installs packages before the application starts.
withYarn(
install?: boolean,
installArgs?: string[]): JavaScriptAppResource
installbooleanoptional= TrueWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installArgsstring[]optionalThe command-line arguments passed to "yarn install".
JavaScriptAppResource