Hi all, I’m trying to create a workaround for <ht...
# typescript
p
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
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
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
🤔
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
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 😅