Skip to content

Commit

Permalink
fix(nx-serverless): fixed overlapping service and function paths (#96)
Browse files Browse the repository at this point in the history
* fix(nx-serverless): Create deploy package.json with proper external modules/dependencies (#89)

* Create deploy package.json with proper external modules/dependencies

* Modify Stats Config to Always have chunks and modules in chunks to get external modules

* fix(nx-serverless): fixed overlapping service and function paths cased by some plugins

I have been having compatabilty issues with serverless-import-config-plugin

Co-authored-by: Brain Weasner <84519320+brian-weasner@users.noreply.github.com>
Co-authored-by: Wick <voravit@flowaccount.com>
  • Loading branch information
3 people authored Nov 3, 2021
1 parent c66d8ab commit fb98840
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libs/nx-serverless/src/utils/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,21 @@ export const getEntryForFunction = (
) => {
const handler = serverlessFunction.handler;

const handlerFile = getHandlerFile(handler);
let handlerFile = getHandlerFile(handler);
if (!handlerFile) {
_.get(serverless, 'service.provider.name') !== 'google' &&
serverless.cli.log(
`\nWARNING: Entry for ${name}@${handler} could not be retrieved.\nPlease check your service config if you want to use lib.entries.`
);
return {};
}

// Sometimes the service path and handlerFile path overlap, unusually caused by plugins. This regex removes the overlap
const regex = new RegExp(
`^${serverless.config.servicePath.replace(/\/([^/]*)/g, `($1\\/)?`)}`
);
handlerFile = handlerFile.replace(regex, ``);

const ext = getEntryExtension(handlerFile, serverless);

// Create a valid entry key
Expand Down

0 comments on commit fb98840

Please sign in to comment.