Sam Sussman

Results 112 comments of Sam Sussman

Looks like adding an export also causes the file to get compiled. ```ts export const x = () => { console.log("hi"); }; ``` ```ts ({"Object.":function(module,exports,require,__dirname,__filename,jest){"use strict"; var __createBinding = (this...

Confirmed that it happens to client libraries too (I turned off the optimization that doesn't add the import to files without resources). In `test-app`: ```ts () => {}; ``` ```ts...

looks like you can re-create the __importStar by using `require("tslib")` https://www.typescriptlang.org/tsconfig#esModuleInterop

Also, I think this is the root cause: https://github.com/microsoft/TypeScript/issues/40507#issuecomment-737628756

This is the logic that determines if the transform is done. https://cs.github.com/microsoft/TypeScript/blob/28dc248e5c500c7be9a8c3a7341d303e026b023f/src/compiler/transformers/module/module.ts#L58-L64 https://cs.github.com/microsoft/TypeScript/blob/28dc248e5c500c7be9a8c3a7341d303e026b023f/src/compiler/utilities.ts#L815-L817

Leaning towards a variation of option1. All closures (arrow functions, functions, and methods) that contain integrations will be transformed into some variation of NativeFunctionDecl that provides a native integration interface...

> By "compile" do you mean statically and not with the closure serializer? So far the options are all static compile time, fed into the closure serializer.

> Also, doing it statically can only work if we own the source. What if a developer calls an imported function and passes it a reference to a table? If...

They have their own "parser" https://github.com/pulumi/pulumi/blob/bf78eabb2934bf3364233ab4325be5743268853a/sdk/nodejs/runtime/closure/parseFunction.ts#L103 Looks like they do eventually use the ts AST/api to walk the immediate tree: https://github.com/pulumi/pulumi/blob/bf78eabb2934bf3364233ab4325be5743268853a/sdk/nodejs/runtime/closure/parseFunction.ts#L426

Hmm, lets start with a list of what we do given the current assumption of a single closure that may contain integrations. 1. Compile: Discover **integrations** inside of the closure...