Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack externals not requiring

In my environment (aws-lambda) I have the aws-sdk set up, so in the webpack.config i've added:

externals: {
    'aws-sdk': 'aws-sdk'
  },

When building it seems to set it as module.exports = aws-sdk; instead of module.exports = require('aws-sdk'); weird thing was it was working fine before, just randomly stopped, any ideas?

(using serverless-webpack and webpack)

like image 687
csilk Avatar asked Apr 28 '26 07:04

csilk


1 Answers

Finally figured out by finding these docs: https://webpack.github.io/docs/configuration.html#externals

Had to have output: { libraryTarget: "commonjs" }, set

like image 121
csilk Avatar answered Apr 30 '26 20:04

csilk