Skip to content

Instantly share code, notes, and snippets.

@joscha
Created May 9, 2024 15:09
Show Gist options
  • Save joscha/bd630f90adaa0cb1ce2f9c4714ba3d7a to your computer and use it in GitHub Desktop.
Save joscha/bd630f90adaa0cb1ce2f9c4714ba3d7a to your computer and use it in GitHub Desktop.
Pipedream Typescript Action with parcel

Sample action with Typescript and parcel.

Run yarn install && yarn build && pd publish dist/main.js to try it out.

import { defineAction } from "@pipedream/types";
import assert from "assert";
export default defineAction({
name: "My Action",
version: "0.0.1",
key: "my-key",
description: "Example",
props: {},
type: "action",
methods: {},
async run(options) {
assert(options);
const { $ } = options;
$.export("$summary", ":tada:");
$.export("hello", "world");
},
});
{
"name": "@your/package",
"version": "1.0.0",
"source": "index.ts",
"main": "dist/main.js",
"types": "dist/main.d.ts",
"private": true,
"type": "module",
"scripts": {
"watch": "parcel watch",
"build": "parcel build"
},
"dependencies": {
"@pipedream/types": "^0.3.0"
},
"devDependencies": {
"@parcel/packager-ts": "2.12.0",
"@parcel/transformer-typescript-types": "2.12.0",
"parcel": "^2.12.0",
"typescript": "^5.4.5"
}
}
{
"compilerOptions": {
"composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
"target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["ES2020"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"module": "ES2020", /* Specify what module code is generated. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "dist", /* Specify an output folder for all emitted files. */
"isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment