Closed
Description
Hi there,
I'm trying to build a Webpack bundle for an AWS Lambda project and I'm running into a few errors. I have a common package and a project package. The common package sets up a connection and returns a client from pg
. The project package uses the client to actually execute queries. Currently I'm trying to bundle pg
in the common package, but I've also tried setting it as an external with not much difference 😢 I've included the error I get when I try and build my project:
ERROR in ./~/server-libs/dist/bundle.js
Module not found: Error: Cannot resolve 'file' or 'directory' ../type-overrides in /project/node_modules/server-libs/dist
@ ./~/server-libs/dist/bundle.js 5:11534-11562
ERROR in ./~/server-libs/dist/bundle.js
Module not found: Error: Cannot resolve 'file' or 'directory' ../../package.json in /project/node_modules/server-libs/dist
@ ./~/server-libs/dist/bundle.js 5:11585-11614
ERROR in ./~/server-libs/dist/bundle.js
Module not found: Error: Cannot resolve 'file' or 'directory' ../connection-parameters in /project/node_modules/server-libs/dist
@ ./~/server-libs/dist/bundle.js 5:11688-11723
ERROR in ./~/server-libs/dist/bundle.js
Module not found: Error: Cannot resolve 'file' or 'directory' ./query in /project/node_modules/server-libs/dist
@ ./~/server-libs/dist/bundle.js 5:11832-11850
ERROR in ./~/server-libs/dist/bundle.js
Module not found: Error: Cannot resolve module 'pg-native' in /project/node_modules/server-libs/dist
@ ./~/server-libs/dist/bundle.js 5:11511-11531
Webpack configuration for common package:
const path = require('path');
const PATHS = {
dist : path.resolve(__dirname, 'dist'),
src : path.resolve(__dirname, 'src'),
};
module.exports = {
entry : './index.js',
target : 'node',
output : {
path : PATHS.dist,
filename : 'bundle.js',
library : 'ServerLib',
libraryTarget : 'umd',
},
resolve : {
extensions : ['', '.js'],
root : [ PATHS.src ],
},
module : {
loaders : [{
test : /\.js$/,
loaders : ['babel'],
exclude : /node_modules/,
}, {
test : /\.json$/,
loaders : ['json'],
}],
noParse : [/pg\/lib\/native/]
},
externals : {
'lodash' : true,
'moment' : true,
},
};
Webpack configuration for project package:
module.exports = {
entry : './handler.js',
target : 'node',
module : {
loaders : [{
test : /\.js$/,
loaders : ['babel'],
exclude : /node_modules/,
}, {
test : /\.json$/,
loaders : ['json'],
}],
},
};
Metadata
Metadata
Assignees
Labels
No labels