noppoMan / npdynamodb

A Node.js Simple Query Builder and ORM for AWS DynamoDB
112 stars 19 forks source link

Webpack Bundling #48

Open TaichiHo opened 7 years ago

TaichiHo commented 7 years ago

Hi, I love this library a lot and want to use it in my production environment.

Right now I have this library as dependency and I am trying to packaging my application with webpack. Webpack complains about the dynamic require issues.

The default behavior of webpack is create a context object pointing to the current directory which in this case will not resolve the dependency.

Any ideas on improving this?

Thanks.

WARNING in ./~/npdynamodb/lib/migrate/migrator.js
Critical dependencies:
139:27-59 the request of a dependency is an expression
175:15-33 the request of a dependency is an expression
 @ ./~/npdynamodb/lib/migrate/migrator.js 139:27-59 175:15-33

WARNING in ./~/npdynamodb/lib/dialects/2012-08-10/api.js
Critical dependencies:
16:11-37 the request of a dependency is an expression
22:13-40 the request of a dependency is an expression
 @ ./~/npdynamodb/lib/dialects/2012-08-10/api.js 16:11-37 22:13-40
noppoMan commented 7 years ago

@TaichiHo Hi, thanks for using npdynamodb and really awesome thing to use it in production!

I see, I'll investigate it. give me a second. (Actually it's mainly designed for server side so its browser support is little bit lazy haha..)

TaichiHo commented 7 years ago

@noppoMan Thanks for the reply.

I am actually using it on server side as well. I want to use webpack to bundle it and deploy to aws lambda.

For the migrator.js, it might be necessary to use the dynamic require. But for the api.js, it seems normal static require should be enough.

According to webpack, dynamic require is considered an anti-pattern.

Should be a easy fix.

Thanks you!

wookieb commented 7 years ago

I'm sorry. @TaichiHo Why do you need webpack in order to deploy it on AWS Lambda?