Skip to content

Commit

Permalink
fix: include files that include []
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Jun 5, 2023
1 parent 75cda48 commit d19f422
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/runtime/src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ export const hasManuallyAddedModule = ({
)
/* eslint-enable camelcase */

/**
* Transforms `/api/shows/[id].js` into `/api/shows/*id*.js`,
* so that the file `[id].js` is matched correctly.
*/
const escapeGlob = (path: string) => path.replace(/\[/g, '*').replace(/]/g, '*')

export const configureHandlerFunctions = async ({
netlifyConfig,
publish,
Expand Down Expand Up @@ -173,7 +179,7 @@ export const configureHandlerFunctions = async ({
netlifyConfig.functions[functionName] ||= { included_files: [] }
netlifyConfig.functions[functionName].node_bundler = 'none'
netlifyConfig.functions[functionName].included_files ||= []
netlifyConfig.functions[functionName].included_files.push(...includedFiles)
netlifyConfig.functions[functionName].included_files.push(...includedFiles.map(escapeGlob))
}
} else {
configureFunction('_api_*')
Expand Down

0 comments on commit d19f422

Please sign in to comment.