Dan Van Brunt
09/21/2021, 5:17 PMthdxr
09/21/2021, 5:19 PMthdxr
09/21/2021, 5:20 PMthdxr
09/21/2021, 5:20 PMDan Van Brunt
09/21/2021, 5:20 PMDan Van Brunt
09/21/2021, 5:21 PMthdxr
09/21/2021, 5:23 PMthdxr
09/21/2021, 5:24 PMconst Config = require(process.env.ENV_CONFIG)
thdxr
09/21/2021, 5:24 PMthdxr
09/21/2021, 5:24 PM{ OPT1: "Hello"}
thdxr
09/21/2021, 5:25 PMConfig[my_env].OPT1
Dan Van Brunt
09/21/2021, 5:25 PMDan Van Brunt
09/21/2021, 5:25 PMCamilo Bravo
09/21/2021, 5:41 PMconst Config = require(process.env.ENV_CONFIG)
This line is throwing a few typescript issues @thdxrCamilo Bravo
09/21/2021, 5:42 PMDan Van Brunt
09/21/2021, 5:44 PM// eslint-disable-line no-eval
Dan Van Brunt
09/21/2021, 5:44 PM/* eslint-disable no-eval */
before any code in a .js
file, that will disable the no-eval
rule for the entire file.thdxr
09/21/2021, 5:45 PMrequire
like that with esbuild so it might not workDan Van Brunt
09/21/2021, 6:18 PMprocess.env
in the bundle output.Dan Van Brunt
09/21/2021, 6:20 PMdefine
property to the build props? https://github.com/evanw/esbuild/issues/438#issuecomment-705120203thdxr
09/21/2021, 6:21 PMDan Van Brunt
09/21/2021, 6:36 PMthdxr
09/21/2021, 6:38 PMDan Van Brunt
09/21/2021, 6:38 PMthdxr
09/21/2021, 6:38 PMCamilo Bravo
09/21/2021, 6:52 PMError: Cannot configure the "define" option in "/esbuild.js". Only the "plugins" option is currently supported.
Looks like there is a check to prevent any customization of the esbuild config beyond pluginsFrank
Dan Van Brunt
09/21/2021, 8:20 PMFrank
TABLE_NAME: table.tableName
Dan Van Brunt
09/21/2021, 8:20 PMDan Van Brunt
09/21/2021, 8:20 PMthis.stackName
no?Frank
Frank
Dan Van Brunt
09/21/2021, 8:22 PMFrank
table.tableName
should work in this caseDan Van Brunt
09/21/2021, 8:23 PMFrank
Frank
The maximum length of a request, including the path, the query string (if any), and headers, is 20,480 bytes
Frank
Dan Van Brunt
09/21/2021, 8:25 PMDan Van Brunt
09/21/2021, 8:26 PMFrank
Dan Van Brunt
09/21/2021, 8:32 PMDan Van Brunt
09/21/2021, 8:33 PMFunction
here to allow for inline config? Similar to what you did on line 283.Dan Van Brunt
09/21/2021, 8:34 PMesbuildConfig
to be an object OR a string.Frank
define
config here? https://github.com/iDVB/serverless-stack/blob/fcc44adcdae3459bf70d84084cbca640e642d879/packages/resources/assets/nodejs/esbuild.js#L27-L29Frank
Frank
metafile
etcDan Van Brunt
09/21/2021, 9:03 PMFrank
Frank
plugins
and define
, would it work for you guys?Dan Van Brunt
09/21/2021, 9:42 PMDan Van Brunt
09/21/2021, 9:42 PMFrank
Camilo Bravo
09/21/2021, 9:47 PMplugins
)Camilo Bravo
09/21/2021, 9:47 PMdefines
is okay that would probably be good to have tooDan Van Brunt
09/21/2021, 9:50 PMnodeBuilder.ts
esbuild.js
….. we’re allowing esbuildConfig to be a string or a type that allows for plugins: [Plugin]
which is fine for nodeBuilder but we are base64 encoding it to be sent to esbuild.js
which you guys are already decoding for defaultConfigValue
.
We’d do the same thing for customConfig but at that point its either a Base64encoded string or a string path. So all I could think of is to again test for !fs.existsSync(customConfig)
and if YES then its a string path and if NO then Buffer.from
Dan Van Brunt
09/21/2021, 9:53 PM--inline-config
flag to esbuild.js
and assume its a base64 string of flag existsFrank
plugins
isn’t serializable right? ie. plugin
is an import right?
esbuildConfig: {
plugins: [plugin]
}
Frank
Dan Van Brunt
09/21/2021, 9:58 PMDan Van Brunt
09/21/2021, 9:59 PMDan Van Brunt
09/21/2021, 10:00 PMFrank
sst start
also needs to run esbuild to build the functions, if defined inline, sst start
won’t be able to figure out what to import.Dan Van Brunt
09/21/2021, 10:04 PMdefine
?Dan Van Brunt
09/21/2021, 10:05 PMFrank
define
and plugins
. Does that work?thdxr
09/21/2021, 11:45 PMDan Van Brunt
09/22/2021, 12:49 AMthis.stackName
which I think should be avail to be passed into define
?thdxr
09/22/2021, 1:03 AMthdxr
09/22/2021, 1:03 AMfs.write("src/handler/config.js", JSON.stringify({ stack: this.stackname }))
Dan Van Brunt
09/22/2021, 1:05 AMDan Van Brunt
09/22/2021, 12:52 PMthis.stackName
. Unless we extend FunctionBundleNodejsProps to allow for define
?Frank
keepNames
esbuild config. I was thinking we can add define
to the allowed config similarly https://github.com/serverless-stack/serverless-stack/pull/807/filesDan Van Brunt
09/22/2021, 2:35 PMesbuildConfig
?Dan Van Brunt
09/22/2021, 2:40 PMthis.stackName
Frank
esbuild-envfile-plugin
, and plugins had to be defined in external file.Dan Van Brunt
09/22/2021, 2:42 PMDan Van Brunt
09/22/2021, 2:43 PMthis.stack
which is why we went down the path to try and allow for inline config.Frank
define
and plugins
esbuild config. And we are stuck right now b/c
• define
has to be configured inline to access `this.stackName`;
• but plugins
has to be configured externally
That sounds right?Frank
Camilo Bravo
09/22/2021, 6:31 PMDan Van Brunt
09/22/2021, 7:01 PMFrank
bundling: {
esbuildConfig: {
define: ...,
keepNames: ...,
plugins: "path/to/esbuild.js"
}
}
You can pass in define
inline, and plugins
through an external file.Frank
Camilo Bravo
09/23/2021, 1:04 PMCamilo Bravo
09/23/2021, 1:05 PMFrank
define
inline like this:
bundle: {
esbuildConfig: {
define: { … },
},
},
Camilo Bravo
09/27/2021, 1:18 PM