Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Edition #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .babelrc

This file was deleted.

30 changes: 0 additions & 30 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.idea/
yarn-error.log
15 changes: 15 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const presets = [
[
"@babel/preset-env",
{
"targets": {
"browsers": "last 2 versions, > 1%, ie >= 6, Chrome >= 29, Firefox >= 55, Safari >= 9, Android >= 4, iOS >= 9, and_uc > 11",
"node": "current"
},
},
],
];
const plugins = [
"@babel/plugin-transform-runtime",
]
module.exports = { presets, plugins };
2 changes: 1 addition & 1 deletion dist/webpack-numbers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<script type='text/javascript' src='./webpack-numbers.js'></script>
<script type='text/javascript'>
document.getElementById('root').innerHTML = " This is a browser example where and api is called to transalate 'One' to '1' \n Results: wordtonum('One') === " + webpackNumbers.wordtonum('One');
document.getElementById('root').innerHTML = " This is a browser example where and api is called to transalate 'One' to '1' \n Results: wordtonum('One') === " + webpackNumbers.createTranslator().wordtonum('One');
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/browser/webpack-numbers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/node/example.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('lodash');
var webpackNumbers = require('./webpack-numbers.js');
var out = function() {
process.stdout.write('This is the result for numtoword(1) === ' + webpackNumbers.numtoword(1));
process.stdout.write('This is the result for numtoword(1) === ' + webpackNumbers.createTranslator().numtoword(1));
};
out();
2 changes: 1 addition & 1 deletion examples/node/webpack-numbers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import numRef from './ref.json';

function createTransalator() {
function createTranslator() {
return {
numtoword: (num) => {
return num < 0 || num > 5 ? 'This is a failure' : converttoword(num);
Expand All @@ -25,4 +25,6 @@ const converttonum = (word) => {
}, -1);
};

export default createTransalator();
export {
createTranslator
}
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"description": "An example of how to author libraries using webpack",
"main": "dist/webpack-numbers.js",
"scripts": {
"build:browser": "webpack && cp dist/webpack-numbers.js examples/browser",
"build:node": "webpack && cp dist/webpack-numbers.js examples/node/ && node examples/node/example.js",
"build": "webpack",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
Expand All @@ -17,14 +16,15 @@
"author": "pksjce",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-env": "^1.6.1",
"eslint": "^3.9.1",
"eslint-loader": "^1.6.1",
"lodash": "^4.16.6",
"webpack": "^4.4.1",
"webpack-cli": "^2.0.12"
"@babel/core": "^7.4.0",
"@babel/plugin-transform-runtime": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"babel-loader": "^8.0.5",
"lodash": "^4.17.11",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0"
},
"dependencies": {
"@babel/runtime": "^7.4.2"
}
}
33 changes: 0 additions & 33 deletions webpack.config.babel.js

This file was deleted.

32 changes: 32 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const path = require('path')

module.exports = {
mode: "production",
entry: {
main: "./index.js"
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "webpack-numbers.js",
libraryTarget: "umd",
library: "webpackNumbers",
globalObject: "this"
},
externals: {
"lodash": {
commonjs: 'lodash',
commonjs2: 'lodash',
amd: 'lodash',
root: '_',
}
},
module: {
rules: [
{
test: /\.(js)$/,
exclude: /(node_modules)/,
use: "babel-loader"
}
]
}
}
Loading