Skip to content

Don't copy devDependencies #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kopertop opened this issue May 23, 2017 · 9 comments
Closed

Don't copy devDependencies #13

kopertop opened this issue May 23, 2017 · 9 comments

Comments

@kopertop
Copy link
Contributor

Currently, the code for this plugin copies the entire node_modules directory into the zip package. There are several packages (like this one) that don't need to be copied in there.

One solution would be to run npm install --production instead of copying in node_modules, but I don't think that's ideal as it takes time and doesn't necessarily copy the exact same modules that have been installed into node_modules. I'm not sure if just iterating over dependencies or devDependencies for specific inclusion or exclusion is good either.

@schickling
Copy link
Contributor

Hmm that's a very good point. I'm also not aware of the best solution here. Maybe @pmuens had an idea?

@pmuens
Copy link

pmuens commented May 24, 2017

@schickling thanks for mentioning! 👍

That's a pretty good point. We're already discussing a potential solution over here: serverless/serverless#2709

This will be baked into Serverless core soon. Feel free to chime in!

@ProbablePrime
Copy link

The issue on serverless is closed but this still remains an issue here.

@pmuens
Copy link

pmuens commented Jul 13, 2017

@ProbablePrime thanks for reaching out 👍

Unfortunately the solution we implemented included a bug where (in some circumstances) the packaging process skips some dev dependencies and doesn't exclude them properly. However we're currently working on a fix for that in the Framework code.

You can find the PR where we're working on the fix here: serverless/serverless#3889

@schickling
Copy link
Contributor

Thanks for the update @pmuens.

@kopertop @ProbablePrime I'll close this issue for now. In case serverless/serverless#3889 doesn't fix this, let's reopen this again.

@pmuens
Copy link

pmuens commented Jul 16, 2017

Thanks for the update @pmuens.@kopertop @ProbablePrime I'll close this issue for now. In case serverless/serverless#3889 doesn't fix this, let's reopen this again.

Thanks for closing @schickling 👍

Quick update: The fix should be ready soon and published in the upcoming version (which will be released next week).

@Alex0007
Copy link

Alex0007 commented Jul 24, 2017

@pmuens

serverless@1.18.0

    "dependencies": {
        "aws-sdk": "^2.88.0",
        "cuid": "^1.3.8",
        "humps": "^2.0.1",
        "moment": "^2.18.1",
        "request": "^2.81.0"
    },
    "devDependencies": {
        "@types/aws-lambda": "0.0.15",
        "@types/cuid": "^1.3.0",
        "@types/humps": "^1.1.2",
        "@types/request": "^2.0.0",
        "serverless": "^1.18.0",
        "serverless-plugin-typescript": "^0.5.0",
        "tslint": "^5.5.0"
    }

For some reasons i have typescript bundled

image

@pmuens
Copy link

pmuens commented Jul 25, 2017

Hey @Alex0007 thanks for the comment 👍!

Yes, unfortunately this is a bug introduced by the recent fix for the dev dependency exclusion.

More information can be found here: serverless/serverless#3972. Lucky enough there's already a PR with a fix in the pipeline: serverless/serverless#3975

For now you could opt-out of dev dependency exclusion with the help of this config:

package:
  excludeDevDependencies: false

https://serverless.com/framework/docs/providers/aws/guide/packaging/#development-dependencies

@keshavkaul
Copy link

keshavkaul commented Dec 29, 2017

@pmuens I'm still facing this issue. All my dev dependencies are included in the final package. This is my package.json

{
  "name": "demo",
  "version": "1.0.0",
  "description": "Created using the starter project template, built using Serverless and TypeScript.",
  "main": "handler.js",
  "scripts": {
    "dev": "serverless offline start",
    "deploy": "serverless deploy",
    "package": "serverless package",
    "test": "mocha -r ts-node/register src/**/*.spec.ts"
  },
  "devDependencies": {
    "@types/aws-lambda": "^0.0.24",
    "@types/bluebird": "^3.5.19",
    "@types/chai": "^4.0.10",
    "@types/chai-as-promised": "^7.1.0",
    "@types/mocha": "^2.2.45",
    "@types/node": "^8.5.2",
    "chai": "^4.1.2",
    "chai-as-promised": "^7.1.1",
    "mocha": "^4.1.0",
    "serverless": "^1.25.0",
    "serverless-offline": "^3.16.0",
    "serverless-plugin-typescript": "^1.1.3",
    "ts-node": "^4.1.0"
  },
  "dependencies": {
    "bluebird": "^3.5.1"    
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants