Cannot `pd publish` ESM typescript build if it imports from local files
See original GitHub issueWhen running pd publish
the follow error is encountered:
Detected local requires, creating zip archive...
- actions/myAction/index.js
- api.js
component create api call responded with status: 500, body: {"error":"unexpected error, please contact support@pipedream.com"}
This only happens when I attempt to publish a .js
file that imports from another relative local file. If all code is kept in the same file, the issue disappears.
I am compiling down from Typescript with this tsconfig.json
:
{
"compilerOptions": {
"outDir": "lib",
"module": "esnext",
"target": "esnext",
"lib": ["esnext", "dom"],
"sourceMap": true,
"allowJs": true,
"moduleResolution": "node",
"jsx": "react",
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"noUnusedLocals": false,
"strictNullChecks": true,
"noUnusedParameters": true,
"declaration": true,
"allowSyntheticDefaultImports": true
},
"include": ["src"],
"exclude": ["node_modules", "/lib"]
}
The result of running $ tsc
to build is a /lib
output folder in .js
files that continue to use relative imports. For example, if in the Typescript source code I have import { helper } from "../../api"
, the same will appear in the compiled Javascript code.
import { helper } from "../../api"; // this stays the same from TS -> JS
My naive suspect is that $ pd publish ./lib/actions/myAction.js
is being uploaded individually, however the logging does say that its “Detected local requires, creating zip archive…”. I would be helpful if the error message was more specific.
I really want to use Typescript in all my pipedream workflows, as static typing keeps me sane across so many cloud functions. Is there something I am missing?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Yeah, for CJS, we expect the whole component to be exported, not under the
default
key, which is more of a esm-ism.Unfortunately not, you are trailblazing, feel free to reach out at any time with questions. We are working on a way to make TS available natively, but we are taking a bit of a different approach.
On Fri, Feb 4, 2022 at 10:46 AM Kangze Huang @.***> wrote: