Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

JavaScriptAppResource

Handle
📦 Aspire.Hosting.JavaScript v17.0.0

A resource that represents a JavaScript application.

type JavaScriptAppResource interface {
IComputeResource
Resource
ResourceWithArgs
ResourceWithContainerFiles
ResourceWithEndpoints
ResourceWithEnvironment
ResourceWithServiceDiscovery
ResourceWithWaitSupport
}

Properties

propertyResourceTypeDisplayNamestringget
Gets the ResourceTypeDisplayName property
ResourceTypeDisplayName() (string, error)

Methods

methodPublishAsNodeServerbuilder
Configures the JavaScript application to publish as a standalone Node.js server that runs a built artifact directly.
PublishAsNodeServer(
entryPoint string,
options ...*PublishAsNodeServerOptions,
) 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.
options...*PublishAsNodeServerOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*PublishAsNodeServerOptions argument.

OutputPath*stringThe relative path containing the built runtime files to copy into the published container. Defaults to the application root.
JavaScriptAppResource

The updated resource builder.

Returns a handle; failures surface later via Err().

Configures the JavaScript application to publish as a server that runs a package manager script at runtime.
PublishAsPackageScript(options ...*PublishAsPackageScriptOptions) JavaScriptAppResource
options...*PublishAsPackageScriptOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*PublishAsPackageScriptOptions argument.

ScriptName*stringThe 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.
RunScriptArguments*stringOptional arguments appended after the script name at runtime, such as -- --port "$PORT".
JavaScriptAppResource

The updated resource builder.

Returns a handle; failures surface later via Err().

Publishes the JavaScript application as a standalone static website using YARP.
PublishAsStaticWebsite(options ...*PublishAsStaticWebsiteOptions) JavaScriptAppResource
options...*PublishAsStaticWebsiteOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*PublishAsStaticWebsiteOptions argument.

ApiPath*string
ApiTarget*ResourceWithServiceDiscovery
OutputPath*string
StripPrefix*bool
TargetEndpointName*string
JavaScriptAppResource

Returns a handle; failures surface later via Err().

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(options ...*WithBrowserDebuggerOptions) JavaScriptAppResource
options...*WithBrowserDebuggerOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithBrowserDebuggerOptions argument.

Browser*stringThe browser to use for debugging. Defaults to "msedge". Supported values include "msedge" and "chrome".
JavaScriptAppResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithBuildScriptbuilder
Adds a build script annotation to the resource builder using the specified command-line arguments.
WithBuildScript(
scriptName string,
options ...*WithBuildScriptOptions,
) JavaScriptAppResource
scriptNamestringThe name of the script to be executed when the resource is built.
options...*WithBuildScriptOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithBuildScriptOptions argument.

Args[]stringAn array of command-line arguments to use for the build script.
JavaScriptAppResource

The same resource builder instance with the build script annotation applied.

Returns a handle; failures surface later via Err().

methodWithBunbuilder
Configures the JavaScript resource to use Bun as the package manager and optionally installs packages before the application starts.
WithBun(options ...*WithBunOptions) JavaScriptAppResource
options...*WithBunOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithBunOptions argument.

Install*boolWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
InstallArgs[]stringAdditional command-line arguments passed to "bun install". When null, defaults are applied based on publish mode and lockfile presence.
JavaScriptAppResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithDenobuilder
Configures the JavaScript resource to use Deno as the package manager.
WithDeno(options ...*WithDenoOptions) JavaScriptAppResource
options...*WithDenoOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithDenoOptions argument.

Install*boolWhen 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.
InstallArgs[]stringAdditional command-line arguments passed to deno install.
JavaScriptAppResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithNpmbuilder
Configures the Node.js resource to use npm as the package manager and optionally installs packages before the application starts.
WithNpm(options ...*WithNpmOptions) JavaScriptAppResource
options...*WithNpmOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithNpmOptions argument.

Install*boolWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
InstallCommand*stringThe install command itself passed to npm to install dependencies.
InstallArgs[]stringThe command-line arguments passed to npm to install dependencies.
JavaScriptAppResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithPnpmbuilder
Configures the Node.js resource to use pnpm as the package manager and optionally installs packages before the application starts.
WithPnpm(options ...*WithPnpmOptions) JavaScriptAppResource
options...*WithPnpmOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithPnpmOptions argument.

Install*boolWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
InstallArgs[]stringThe command-line arguments passed to "pnpm install".
JavaScriptAppResource

The resource builder.

Returns a handle; failures surface later via Err().

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,
options ...*WithRunScriptOptions,
) JavaScriptAppResource
scriptNamestringThe name of the script to be executed when the resource is run.
options...*WithRunScriptOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithRunScriptOptions argument.

Args[]stringAn array of arguments to pass to the script.
JavaScriptAppResource

The same resource builder instance with the run script annotation applied, enabling further configuration.

Returns a handle; failures surface later via Err().

methodWithYarnbuilder
Configures the Node.js resource to use yarn as the package manager and optionally installs packages before the application starts.
WithYarn(options ...*WithYarnOptions) JavaScriptAppResource
options...*WithYarnOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithYarnOptions argument.

Install*boolWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
InstallArgs[]stringThe command-line arguments passed to "yarn install".
JavaScriptAppResource

The resource builder.

Returns a handle; failures surface later via Err().