Skip to content

Commit 7708f3b

Browse files
authored
Merge pull request #25 from adieuadieu/feat/support-serverless-exclude-node-dev-deps-feature
feat: add support for Serverless node devDeps exclusion feature
2 parents 72e3bd7 + e37c45f commit 7708f3b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

example/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"dependencies": {
3+
"lodash": "^4.17.4"
4+
},
5+
"devDependencies": {
36
"@types/lodash": "^4.14.63",
4-
"lodash": "^4.17.4",
57
"serverless-plugin-typescript": "^0.1.2"
68
}
79
}

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class ServerlessPlugin {
9191
fs.symlinkSync(path.resolve('node_modules'), path.resolve(path.join(buildFolder, 'node_modules')))
9292
}
9393

94+
// include package.json into build so Serverless can exlcude devDeps during packaging
95+
if (!fs.existsSync(path.resolve(path.join(buildFolder, 'package.json')))) {
96+
fs.symlinkSync(path.resolve('package.json'), path.resolve(path.join(buildFolder, 'package.json')))
97+
}
98+
9499
// include any "extras" from the "include" section
95100
if (this.serverless.service.package.include && this.serverless.service.package.include.length > 0) {
96101
const files = await globby(this.serverless.service.package.include)

0 commit comments

Comments
 (0)