Support packaging functions individually#136
Conversation
|
Looks like a few people are trying to resolve this issue now (#107 is another one). The relevant code looks like it's on I'll try to repro and confirm this fix sometime this week, thanks for helping out! |
5af7c6e to
c702a57
Compare
|
@JackCuthbert , i have reapplied the changes, please review |
|
Nice @zjye ! Can you drop the merge commit as well and modify the commit with the fix to be a message like:
This will cause semantic-release to do it's magic and publish a minor version update (as this is adding support for something it didn't do before) and GitHub to automatically close out any related issues/PRs once this is merged. @divyenduz I'll be attempting to repro this within the next few days, I'll ping again once this is ready for merge! |
814f391 to
111a410
Compare
|
Hey @zjye I've tested your fix and it looks like it resolves part of the problem defined in the #42 use case where one function is defined as being packaged individually. What it is not doing is copying anything defined in the diff --git a/src/index.ts b/src/index.ts
index 27e1769..9442508 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -149,7 +149,7 @@ export class TypeScriptPlugin {
await this.linkOrCopy(path.resolve('package.json'), outPkgPath, 'file')
}
- // include any "extras" from the "include" section
+ // include any "extras" from the "include" section of the main service
if (this.serverless.service.package.include && this.serverless.service.package.include.length > 0) {
const files = await globby(this.serverless.service.package.include)
@@ -166,6 +166,25 @@ export class TypeScriptPlugin {
}
}
}
+
+ // include any "extras" from the "include" section of each function
+ for (const fnName in this.functions) {
+ const fn = this.functions[fnName]
+ if (fn.package.include !== undefined) {
+ for (const filename of fn.package.include) {
+ const destFileName = path.resolve(path.join(buildFolder, filename))
+ const dirname = path.dirname(destFileName)
+
+ if (!fs.existsSync(dirname)) {
+ fs.mkdirpSync(dirname)
+ }
+
+ if (!fs.existsSync(destFileName)) {
+ fs.copySync(path.resolve(filename), path.resolve(path.join(buildFolder, filename)))
+ }
+ }
+ }
+ }Additionally, it seems that packaging individually (both at a single function or service-wide level) only duplicates the resulting .zip file with a new name. All code and includes are packaged into each archive, so if you need more control over what goes into each package make sure to use |
|
Hey @divyenduz, how do you feel about this one? |
|
Do we have an update on this PR? It's such a needed feature. |
to fix issue #42