ugh, running into another issue where the config i...
# sst
t
ugh, running into another issue where the config is being mutated for custom configs, this time with `sst start`…
I’ve already traced it, but here’s the first indication of failure in the output:
Copy code
Error Transpiling Lambda code... TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
    at validateString (internal/validators.js:124:11)
    at Object.join (path.js:1148:7)
    at loadEsbuildConfigOverrides (/Users/tylerflint/Code/tylerflint/serverless-app-template/node_modules/@serverless-stack/cli/scripts/util/cdkHelpers.js:212:33)
    at runTranspileNode (/Users/tylerflint/Code/tylerflint/serverless-app-template/node_modules/@serverless-stack/cli/scripts/start.js:575:30)
    at handleTranspileNode (/Users/tylerflint/Code/tylerflint/serverless-app-template/node_modules/@serverless-stack/cli/scripts/start.js:530:15) {
  code: 'ERR_INVALID_ARG_TYPE'
}
so I dug into
@serverless-stack/cli/scripts/util/cdkHelpers.js
and found the following:
on line 188 there is a copy by reference:
Copy code
customConfig = customConfig || {};
then on line 210 the update:
Copy code
customConfig.plugins = path.join(paths.appPath, customConfig.plugins);
but then it gets really weird.
on line 217 the esbuild config is required (makes sense):
Copy code
const ret = require(customConfig.plugins);
but then on line 224 the
customConfig.plugins
is re-assed to the result of requiring the esbuild config:
Copy code
customConfig.plugins = ret.plugins;
it’s probably not all that weird tbh, I just wasn’t expecting to see it used that way. The real problem though, is that since the original reference is copied instead of the value being cloned it gets re-used in that form again, which is what causes the breakage.
let me try a quick hotfix to see if the problem goes away when I deep clone the original reference
yep that did the trick
ok let me get a quick PR
t
Bleh I wonder in how many places we do this
thanks for the PR