https://pulumi.com logo
#typescript
Title
# typescript
p

prehistoric-kite-30979

08/24/2021, 12:07 PM
Hi all, I’m trying to create a workaround for https://github.com/pulumi/pulumi/issues/2661 (yarn 2/3 workspaces). What are the exact requirements for
aws.lambda.CallbackFunction
?
I can get non-local workspaces to work (e.g.
@pulumi/aws
) by symlinking.
But local workspaces complain with
Copy code
failed to compute asset hash: asset path 'node_modules/@tetrateio-components/aws-lambda' is a directory; try using an archive
the only difference I can see is that my local workspaces/packages have no generated javascript?
the other difference looks like
@pulumi/pulumi
is a directory but
@tetrateio-components/aws-lambda
is a symlink
l

little-cartoon-10569

08/24/2021, 10:39 PM
I think they're the same as described in https://github.com/pulumi/pulumi/issues/4780 and https://github.com/pulumi/pulumi/issues/2619#issuecomment-592543664: you can't use inline lambdas (that is, CallbackFunction and similar mixins) unless you also have an already-generated node_modules in the same directory that Pulumi is bundling into the zip.
My workaround is to link the project's node_modules into any directory that has a CallbackFunction. So long as the CallbackFunction only uses code that is also used in the main project (so that the node_modules directory has all required dependencies), then it works.
(Aside: this has the downside that I can't run my mocha tests from those directories, because I can't get mocha to find packages.json in a parent directory if it has already found node_modules...)
p

prehistoric-kite-30979

08/24/2021, 10:46 PM
interesting so even when I symlink node_modules I see that error ^^
(but only for local workspaces, external packages work fine)
we used to use node_modules symlink and it worked before we migrated to yarn workspaces
so its something specific to how yarn handles local workspaces
l

little-cartoon-10569

08/25/2021, 1:34 AM
🤔
Local workspaces are links from /node_modules to the workspace, right? If your workspace contains .ts files, then the imports won't work. If you're compiling to /lib/ (based on your tsconfig's outdir), then you need /lib to be your workspace...
The link would need to be /node_modules/myproj -> /lib/myproj, not -> /myproj.
But I think you can do that in yarn workspaces using the name property?
That is, /myproj/package.json needs
"name": "/lib/myproj"
. (Completely untested.. that's derived only from reading https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it)
p

prehistoric-kite-30979

08/25/2021, 11:48 AM
yes, local modules are symlinks in the node_modules. We don’t compile to JS anywhere so let me try that.
compiling js didnt seem to help, going to have to give up for now and come back to this 😅
2 Views