-
Notifications
You must be signed in to change notification settings - Fork 109
Add TypeScript runtime actions documentation #521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/pages/guides/app_builder_guides/configuration/typescript-actions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| --- | ||
| title: TypeScript Actions | ||
| description: >- | ||
| Use TypeScript to write Runtime actions in App Builder applications. | ||
| keywords: | ||
| - TypeScript | ||
| - Runtime Actions | ||
| - Webpack | ||
| - Configuration | ||
| --- | ||
|
|
||
| # TypeScript Actions | ||
|
|
||
| ## Overview | ||
|
|
||
| App Builder supports TypeScript for Runtime actions via Webpack's `ts-loader`. You can point your `app.config.yaml` directly to `.ts` files — no manual `tsc` compilation step or duplicated source directories required. This works with `aio app dev`, `aio app build`, and `aio app deploy`. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Install the required dev dependencies in your project: | ||
|
|
||
| ```bash | ||
| npm install --save-dev ts-loader typescript | ||
| ``` | ||
|
|
||
| ## Setup | ||
|
|
||
| ### 1. Add a Webpack configuration | ||
|
|
||
| Create a `webpack-config.js` file in the root of your project (or in an action directory for per-action configuration). See [Webpack Configuration](webpack-configuration.md) for details on file placement and supported export formats. | ||
|
|
||
| ```javascript | ||
| module.exports = { | ||
| devtool: 'inline-source-map', | ||
| module: { | ||
| rules: [ | ||
| { | ||
| test: /\.ts?$/, | ||
| exclude: /node_modules/, | ||
| use: 'ts-loader' | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| > If your project uses ES modules (`"type": "module"` in `package.json`), name this file `webpack-config.cjs` instead so that it is treated as CommonJS. See the [ES module syntax](webpack-configuration.md#es-module-syntax) section for more information. | ||
|
|
||
| ### 2. Add a TypeScript configuration | ||
|
|
||
| Create a `tsconfig.json` file in the root of your project: | ||
|
|
||
| ```json | ||
| { | ||
| "exclude": ["node_modules", "dist"], | ||
| "compilerOptions": { | ||
| "target": "ES6", | ||
| "module": "ES6", | ||
| "sourceMap": true | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### 3. Point your actions to `.ts` files | ||
|
|
||
| In `app.config.yaml`, set the `function` field of your action to the TypeScript entry file: | ||
|
|
||
| ```yaml | ||
| runtimeManifest: | ||
| packages: | ||
| my-package: | ||
| actions: | ||
| my-action: | ||
| function: actions/my-action/index.ts | ||
| web: 'yes' | ||
| runtime: nodejs:18 | ||
| ``` | ||
|
|
||
| That's it. App Builder will use Webpack with `ts-loader` to compile your TypeScript action during build and deployment. | ||
|
|
||
| ## Limitations | ||
|
|
||
| - **Debugging** — The VS Code debugger steps through the compiled JavaScript output by default. Adding `devtool: 'inline-source-map'` to your webpack configuration (as shown above) enables source map support, which improves the debugging experience but may not be a perfect 1:1 mapping with your original TypeScript source. | ||
|
|
||
| For general Webpack constraints (immutable options, supported config formats, etc.), see [Webpack Configuration](webpack-configuration.md). | ||
|
|
||
| ## Example project | ||
|
|
||
| The [typescript-app quickstart](https://github.com/adobe/appbuilder-quickstarts/tree/master/typescript-app) demonstrates TypeScript in an App Builder project. Note that it uses a manual `tsc` compilation approach; the `ts-loader` method described on this page is a simpler alternative that avoids the need for a separate build step or duplicated source directories. | ||
|
|
||
| ## Next steps | ||
|
|
||
| - [Webpack Configuration](webpack-configuration.md) — Customize your build process | ||
| - [App Builder Configuration Files](configuration.md) — Full `app.config.yaml` reference | ||
|
|
||
| Return to [Guides Index](../../index.md). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.