Modifying the typescript example to use imports results in error.
blah.ts
export const name = 'steve';
handler.ts
import {name} from './blah';
export const hello = (event, context, cb) => cb(null,
{ message: name + 'Go Serverless Webpack (Typescript) v1.0! Your function executed successfully!', event }
);
running serverless webpack serve results in error:
Error: Cannot find module "./blah"
at webpackMissingModule (/home/myuser/Documents/git/serverless-webpack/examples/typescript/.webpack/handler.js:48:79)
at Object.(/home/myuser/Documents/git/serverless-webpack/examples/typescript/.webpack/handler.js:48:162)
at webpack_require (/home/myuser/Documents/git/serverless-webpack/examples/typescript/.webpack/handler.js:20:30)
at /home/myuser/Documents/git/serverless-webpack/examples/typescript/.webpack/handler.js:40:18
at Object.(/home/myuser/Documents/git/serverless-webpack/examples/typescript/.webpack/handler.js:43:10)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at ServerlessWebpack.loadHandler (/home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/serverless-webpack/lib/run.js:19:20)
at Watching.handler (/home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/serverless-webpack/lib/serve.js:24:39)
at Watching._done (/home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/webpack/lib/Compiler.js:81:7)
at Watching.(/home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/webpack/lib/Compiler.js:61:18)
at Compiler.emitRecords (/home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/webpack/lib/Compiler.js:282:37)
at Watching.(/home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/webpack/lib/Compiler.js:58:19)
at /home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/webpack/lib/Compiler.js:275:11
at Compiler.applyPluginsAsync (/home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/tapable/lib/Tapable.js:60:69)
at Compiler.afterEmit (/home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/webpack/lib/Compiler.js:272:8)
at Compiler.(/home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/webpack/lib/Compiler.js:267:14)
at /home/myuser/Documents/git/serverless-webpack/examples/typescript/node_modules/async/lib/async.js:52:1
your webpack.config.js would be of help to troubleshot the issue
From the typescript example, I'm running serverless webpack serve.
var path = require('path');
module.exports = {
entry: './handler.ts',
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: 'handler.js'
},
target: 'node',
module: {
loaders: [
{ test: /\.ts(x?)$/, loader: 'ts-loader' }
]
}
};
gosh with node6 the whole ts example isn't working for me anymore xD
I have no idea why this is not working, I believe it is a webpack configuration related issue but I'm not experienced with TS.
Lets see if someone can work this out. Or if you do please report back.
I have a fair bit of experience with webpack and the config is fine when you use webpack standalone. Ultimately I ended up using gulp to run webpack, then later run serverless via child_process.spawn. Make for a more reliable and customizable build.
I had similar problem. Issue is in extensions array. For some reason it should contains empty extension, but then plain webpack command fails.
Example:
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['.ts', '.tsx', '.js', '']
},
With the recently released version 2.0.0 of the plugin, any Webpack version can be used (it's a peer dependency now). Can you check if the issue still persists, when using a newer Webpack version? Additionally, we plan to remove the serve command completely in favor of the serverless-offline plugin (#135) which is the better option. The webpack plugin will then concentrate on the core features (packaging).
serve will be removed in the next v3.0.0 release in favor of serverless-offline (see #152 ). No efforts will be spent on the function anymore. Reverify the issue with the latest plugin version.
I'll close this for now - please reopen if the issue still persists.
Most helpful comment
I had similar problem. Issue is in extensions array. For some reason it should contains empty extension, but then plain webpack command fails.
Example: