Skip to content
This repository has been archived by the owner on Feb 24, 2018. It is now read-only.

Commit

Permalink
Add ES Modules build
Browse files Browse the repository at this point in the history
  • Loading branch information
jogold committed Feb 27, 2017
1 parent 9075925 commit 61c390d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
18 changes: 15 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{
"presets": [
"es2015"
]
}
[
"es2015", {
"loose": true,
"modules": false
}
]
],
"env": {
"commonjs": {
"plugins": [
["transform-es2015-modules-commonjs", { "loose": true }]
]
}
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
npm-debug.log

/docs/

es
lib
Empty file added .npmignore
Empty file.
17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,35 @@
"identity"
],
"scripts": {
"build": "webpack -p",
"clean": "rimraf lib es",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack dist/amazon-cognito-identity.js",
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack dist/amazon-cognito-identity.min.js",
"build": "npm run clean && npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min",
"doc": "jsdoc src -d docs",
"lint": "eslint src"
},
"main": "dist/amazon-cognito-identity.min.js",
"main": "lib/index.js",
"module": "es/index.js",
"jsnext:main": "es/index.js",
"types": "./index.d.ts",
"dependencies": {
"aws-sdk": "^2.6.0"
},
"devDependencies": {
"babel-cli": "^6.23.0",
"babel-core": "^6.13.2",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.13.2",
"babel-plugin-transform-es2015-modules-commonjs": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"cross-env": "^3.1.4",
"eslint": "^3.3.1",
"eslint-config-airbnb-base": "^5.0.2",
"eslint-import-resolver-webpack": "^0.5.1",
"eslint-plugin-import": "^1.13.0",
"jsdoc": "^3.4.0",
"rimraf": "^2.5.4",
"webpack": "^1.13.1"
}
}
23 changes: 14 additions & 9 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ var banner = '/*!\n' +
' * limitations under the License. \n' +
' */\n\n';

module.exports = {
var config = {
entry: './enhance',
output: {
path: 'dist',
filename: 'amazon-cognito-identity.min.js',
libraryTarget: 'umd',
library: 'AmazonCognitoIdentity'
},
devtool: 'source-map',
externals: {
// This umd context config isn't in configuration documentation, but see example:
// https://github.com/webpack/webpack/tree/master/examples/externals
Expand All @@ -45,11 +42,6 @@ module.exports = {
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.BannerPlugin(banner, { raw: true })
],
module: {
Expand All @@ -65,3 +57,16 @@ module.exports = {
]
}
};

if (process.env.NODE_ENV === 'production') {
config.devtool = 'source-map';
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
);
}

module.exports = config;

0 comments on commit 61c390d

Please sign in to comment.