Alexa-skills-kit-sdk-for-nodejs: Webpack compatibility

Created on 1 May 2018  路  6Comments  路  Source: alexa/alexa-skills-kit-sdk-for-nodejs

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:
Webpack gives a warning while bundling a Typescript file importing from the Alexa SDK ## Expected Behavior Webpack runs without warning ## Current Behavior Webpack gives a warning:
WARNING in ./node_modules/ask-sdk-core/dist/util/AskSdkUtils.js
34:22-67 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/ask-sdk-core/dist/util/AskSdkUtils.js
 @ ./node_modules/ask-sdk-core/dist/attributes/AttributesManagerFactory.js
 @ ./node_modules/ask-sdk-core/dist/index.js
 @ ./node_modules/ask-sdk/dist/index.js
 @ ./impfkompass.ts

Running the output results in:

Error --------------------------------------------------

聽聽Cannot find module "."

聽聽聽聽聽For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

聽聽Stack Trace --------------------------------------------

Error: Cannot find module "."
聽聽聽聽at webpackMissingModule (/Users/johanneskees/Repositories/a7/impfkompass-alexa-node/.webpack/service/impfkompass.js:1768:67)
聽聽聽聽at Object.createAskSdkUserAgent (/Users/johanneskees/Repositories/a7/impfkompass-alexa-node/.webpack/service/impfkompass.js:1768:145)
聽聽聽聽at Skill. (/Users/johanneskees/Repositories/a7/impfkompass-alexa-node/.webpack/service/impfkompass.js:6632:58)
聽聽聽聽at step (/Users/johanneskees/Repositories/a7/impfkompass-alexa-node/.webpack/service/impfkompass.js:6568:23)
聽聽聽聽at Object.next (/Users/johanneskees/Repositories/a7/impfkompass-alexa-node/.webpack/service/impfkompass.js:6549:53)
聽聽聽聽at fulfilled (/Users/johanneskees/Repositories/a7/impfkompass-alexa-node/.webpack/service/impfkompass.js:6540:58)
聽聽聽聽at 
...

Possible Solution

Remove usage of path.* in require calls

Context



Webpack Conf:

const path = require('path');
const slsw = require('serverless-webpack');

module.exports = {
    entry: slsw.lib.entries,
    devtool: 'source-map',
    resolve: {
        extensions: [
            '.js',
            '.jsx',
            '.json',
            '.ts',
            '.tsx'
        ]
    },
    output: {
        libraryTarget: 'commonjs',
        path: path.join(__dirname, '.webpack'),
        filename: '[name].js',
    },
    target: 'node',
    module: {
        loaders: [
            { test: /\.ts(x?)$/, loader: 'ts-loader' },
        ],
    },
};

TS Config:

{
  "compilerOptions": {
    "sourceMap": true,
    "lib": [
      "es5",
      "es2015.promise",
      "es6"
    ]
  }
}

Your Environment

  • ASK SDK for Node.js used: 2.0.1
  • Node 10.0
  • Webpack 3.11.0 + ts-loader 2.8.3
  • Operating System and version: Mac OS 10.3.5

Most helpful comment

Is there a chance that you release this as a new version?

All 6 comments

Do you have an idea when this might be resolved? This blocks building skills with webpack using the new SDK. Is it really needed to add the version to the user-agent and therefore parse the package.json?

Hey folks just wondering when this may be resolved as I'm hitting serious issues with this, cannot ship a skill.

Is there a chance that you release this as a new version?

+1 I'm running into the same issue. Please fix.

My webpack build zip file is 518kb. Without webpack it's 5.8MB. In a situation where I'm constantly uploading and re-uploading a zip file to test changes this makes a significant impact on my workflow.

I haven't benchmarked this and could certainly be wrong, but I would also expect a small built file to execute more efficiently on lambda as well since it's not touching the filesystem.

@eileennoonan83 This issue was fixed in v2.0.4, just update and you can continue using webpack!

@captnCC Thank you! Seems to be working now :D

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mehtanilay10 picture mehtanilay10  路  6Comments

dkl3in picture dkl3in  路  3Comments

kevinwu picture kevinwu  路  3Comments

developer170883 picture developer170883  路  4Comments

slesem picture slesem  路  4Comments