Giter Club home page Giter Club logo

Comments (14)

jayair avatar jayair commented on May 28, 2024 1

@radelcom Oh that looks good. I'm going to try that out.

from serverless-nodejs-starter.

jayair avatar jayair commented on May 28, 2024 1

@radelcom Just updated the repo to use the babel source map plugin. Thanks for the feedback guys.

Closing this issue.

from serverless-nodejs-starter.

luke-unifymonitor avatar luke-unifymonitor commented on May 28, 2024

Compared against previous versions, it looks like the README.md should be updated to read

serverless webpack invoke --function hello

rather than

serverless invoke local --function hello -l

from serverless-nodejs-starter.

jayair avatar jayair commented on May 28, 2024

@luke-unifymonitor I'm not sure what is going on here but have you updated serverless-webpack to v3 (https://github.com/serverless-heaven/serverless-webpack/releases/tag/v3.0.0)?

This is also why we are now using serverless invoke local instead of serverless webpack invoke.

from serverless-nodejs-starter.

luke-unifymonitor avatar luke-unifymonitor commented on May 28, 2024

Thanks @jayair. I haven't got serverless-webpack installed globally.

I just do a serverless install --url https://github.com/AnomalyInnovations/serverless-es7 --name my-project

The package.json it creates is as below which has "serverless-webpack": "^3.0.0" in devDependencies.

{
  "name": "my-test",
  "version": "1.1.0",
  "description": "A starter project for the Serverless Framework with ES7 support",
  "main": "handler.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/AnomalyInnovations/serverless-es7.git"
  },
  "devDependencies": {
    "babel-core": "^6.25.0",
    "babel-loader": "^7.1.1",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-3": "^6.24.1",
    "serverless-webpack": "^3.0.0",
    "webpack": "^3.0.0",
    "webpack-node-externals": "^1.6.0"
  },
  "dependencies": {
    "babel-runtime": "^6.23.0",
    "source-map-support": "^0.4.14"
  }
}

from serverless-nodejs-starter.

jayair avatar jayair commented on May 28, 2024

@luke-unifymonitor Yup that should work. You should now be able to run serverless invoke local --function hello and it should run your function locally.

from serverless-nodejs-starter.

radelcom avatar radelcom commented on May 28, 2024

I am also getting similar error message with just sls deploy and not specific function. I was digging around and narrowed it down. It seems like dependent on which ever node version I am using. I am using nvm as my node version manager. If I use node v6.10.3, I get this issue and if I switched to node v8.4.0, all goes away and deploys successfully.

I guess question is, is it ok to use node v8.4.0 development and wont have impact to the actual AWS supported node v6.10 version when serverless is deployed?

Any input is greatly appreciated. tx in advance!

Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook before:deploy:createDeploymentArtifacts
Serverless: WARNING: Plugin ServerlessWebpack uses deprecated hook after:deploy:createDeploymentArtifacts
 
  Syntax Error -------------------------------------------
 
     Unexpected token ...
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:511:25)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Module.require (module.js:466:17)
    at require (internal/module.js:20:19)
    at ServerlessWebpack.validate

from serverless-nodejs-starter.

luke-unifymonitor avatar luke-unifymonitor commented on May 28, 2024

@jayair I'm afraid it doesn't work though - still getting the same error message.

Unexpected token ...

I'm on node 7.10.0

from serverless-nodejs-starter.

jackmusick avatar jackmusick commented on May 28, 2024

I'm also having this issue. I think it's this in webpack.config.js:

    ...acc,
    [key]: ["./_webpack/include.js", slsw.lib.entries[key]]
}), {});

Removing ...acc, fixes this, but I'm getting unrelated errors to this issue. Just thought I'd add my 2 cents in case it helps.

from serverless-nodejs-starter.

jayair avatar jayair commented on May 28, 2024

@radelcom @luke-unifymonitor @jackmusick Thanks for all the details. Yeah I should switch the code around and not assume folks are running a higher version of Node. I'll push an update soon.

from serverless-nodejs-starter.

jayair avatar jayair commented on May 28, 2024

@radelcom @luke-unifymonitor @jackmusick Just pushed an update. Can you guys try again?

from serverless-nodejs-starter.

luke-unifymonitor avatar luke-unifymonitor commented on May 28, 2024

@jayair - That's sorted it for me. Thanks very much.

from serverless-nodejs-starter.

jayair avatar jayair commented on May 28, 2024

Great!

@radelcom @jackmusick If you guys can confirm, then we'll close the issue.

from serverless-nodejs-starter.

radelcom avatar radelcom commented on May 28, 2024

@jayair - looks good here now too. although I switched my implementation to use babel-plugin-source-map-support. Now I dont need the _webpack folder with include.js anymore.

my .babelrc looks like this now

{
  "plugins": ["source-map-support", "transform-runtime"],
  "presets": ["es2015", "stage-3"]
}

and webpack.config.js

const slsw          = require('serverless-webpack');
const nodeExternals = require('webpack-node-externals');

module.exports = {
  entry: slsw.lib.entries,
  target: 'node',
  // Generate sourcemaps for proper error messages
  devtool: 'source-map',
  // Since 'aws-sdk' is not compatible with webpack,
  // we exclude all node dependencies
  externals: [nodeExternals()],
  // Run babel on all .js files and skip those in node_modules
  module: {
    rules: [{
      test: /\.js$/,
      loaders: ['babel-loader', 'eslint-loader'],
      include: __dirname,
      exclude: /node_modules/
    }]
  }
};

from serverless-nodejs-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.