Remove buildOptions access before initialization#341
Remove buildOptions access before initialization#341Edweis wants to merge 1 commit intofloydspace:masterfrom
Conversation
|
Should be resolved by #337 |
|
I'm having the same issue, but with 1.32.5 which should include #337 At the time Then these two lines https://github.com/floydspace/serverless-esbuild/blob/master/src/index.ts#L137-L138 are looking for I'm not sure if Possibly this line https://github.com/floydspace/serverless-esbuild/blob/master/src/index.ts#L245 should look more like to make use of the constants? |
ah yep you are right. Pre-#337 they were initialised in the constructor. Let me think about this and I'll put something up to fix it |
Issue:
With the following settings in
serverless.yml:When running
serverless offline, the offline server starts but when a file is changed,serverless-esbuildruns into an infinite loop and keeps compiling until the process is killed.Investigation
After some investigation, I found that chikidar is initialized with
{ "options": { "ignored": [ null, // (1) "dist", "node_modules", null, // (2) "node_modules/serverless-esbuild" ], "awaitWriteFinish": true, "ignoreInitial": true }, "defaultPatterns": [ "./**/*.(js|ts)" ] }Reading the code,
(1)and(2)should actually be respectively.esbuildand.buildsince they are the default value fromserverless-esbuild(link).The issue is that
getCachedOptionsran for the first time beforethis.outputWorkFolderandthis.outputBuildFolderare defined. Hence the cache is populated withnullinstead.Fix
This fix, makes
this.outputWorkFolderandthis.outputBuildFolderinitialized with the context value instead of the one fromgetCachedOptions.