amazon web services - How to use webpack import aws-sdk -


i found issues in official, looks refused answer. can ask questions on so. here error&warning log:

warning in ./~/aws-sdk/lib/util.js critical dependencies: 40:30-45 request of dependency expression 43:11-53 request of dependency expression  @ ./~/aws-sdk/lib/util.js 40:30-45 43:11-53  warning in ./~/aws-sdk/lib ^\.\/.*$ module not found: error: cannot resolve directory '.' in /users/me/documents/sources/my-project/client/node_modules/aws-sdk/lib  @ ./~/aws-sdk/lib ^\.\/.*$  warning in ./~/aws-sdk/lib/api_loader.js critical dependencies: 13:15-59 request of dependency expression 104:12-46 request of dependency expression 108:21-58 request of dependency expression 114:18-52 request of dependency expression  @ ./~/aws-sdk/lib/api_loader.js 13:15-59 104:12-46 108:21-58 114:18-52  warning in ./~/aws-sdk/lib/region_config.json module parse failed: /users/me/documents/sources/my-project/client/node_modules/aws-sdk/lib/region_config.json line 2: unexpected token : may need appropriate loader handle file type. | { |   "rules": { |     "*/*": { |       "endpoint": "{service}.{region}.amazonaws.com"  @ ./~/aws-sdk/lib ^\.\/.*$  error in ./~/aws-sdk/lib/api_loader.js module not found: error: cannot resolve module 'fs' in /users/me/documents/sources/my-project/client/node_modules/aws-sdk/lib  @ ./~/aws-sdk/lib/api_loader.js 1:9-22  error in ./~/aws-sdk/lib/services.js module not found: error: cannot resolve module 'fs' in /users/me/documents/sources/my-project/client/node_modules/aws-sdk/lib  @ ./~/aws-sdk/lib/services.js 1:9-22 

there 3 types:

  1. cannot resolve module 'fs'

i need install fs can solve this.

  1. need appropriate loader

well, need install json-loader, , set in webpack.config.js, can solve.

  1. critical dependencies
  2. module not found: error: cannot resolve directory '.'

i webpack newbie.so, don't know how solve this. me? thanks.

update:

  1. module not found: error: cannot resolve directory '.'

that fault, config file's extensions missing .

using noparse method should work if creating node package, setting webpack not apply parsing/loaders. did not work me when creating umd formatted output file/library.

to create umd formatted library had use loaders browserify aws-sdk , handle json files.

install loaders:

npm install json-loader --save-dev

npm install transform-loader brfs --save-dev

webpack config:

module: {   loaders: [     { test: /aws-sdk/, loaders: ["transform?brfs"]},     { test: /\.json$/, loaders: ['json']},   ] }, output: {   library: 'libraryname',   librarytarget: 'umd' }, resolve: {   extensions: ['', '.js'] } 

replace libraryname own namespacing. library used through constructor follows:

var libobj = new libraryname(); 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -