Skip to content

Commit

Permalink
Fixes #612 Dist files contain eval
Browse files Browse the repository at this point in the history
The webpack `devtool` option for the `development` configuration has been changed from `cheap-module-eval-source-map` to `cheap-source-map`;
This removes any `eval()` from the generated `dist/autoNumeric.js` file, and makes the source maps works in all cases in the browsers

Merge the changes from `4.4.1` while making sure there is no regression with #609; this adds the `browser` field alongside the `main` one in `package.json`
Note: The `browser` option points to the minified library `dist/autoNumeric.min.js`

Update the `index.html` test file to use the un-minified `development` library `dist/autoNumeric.js`
This allows to *temporarily* use forbidden functions like `console` or wrong formatting while debugging, using `yarn build:dev`

Fixes a call to `_reformatAltHovered()` even when the `unformatOnHover` option was set to `false`

Signed-off-by: Alexandre Bonneau <alexandre.bonneau@linuxfr.eu>
  • Loading branch information
AlexandreBonneau committed Oct 13, 2018
1 parent c3911bb commit 403cf92
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,14 @@
+ Introduces the *formula mode* which allows a user to enter a math expression in the element using the `=` key, then evaluate it with the `Enter` one
+ Adds the `formulaMode` option, set to `false` by default, that controls if the *formula mode* is enabled
+ Adds the `Lexer`, `Parser`, `Evaluator`, `ASTNode` and `Token` classes for managing math expressions
+ Fixes #612 Dist files contain eval
+ The webpack `devtool` option for the `development` configuration has been changed from `cheap-module-eval-source-map` to `cheap-source-map`;
This removes any `eval()` from the generated `dist/autoNumeric.js` file, and makes the source maps works in all cases in the browsers
+ Merge the changes from `4.4.1` while making sure there is no regression with #609; this adds the `browser` field alongside the `main` one in `package.json`
+ Note: The `browser` option points to the minified library `dist/autoNumeric.min.js`
+ Update the `index.html` test file to use the un-minified `development` library `dist/autoNumeric.js`
This allows to *temporarily* use forbidden functions like `console` or wrong formatting while debugging, using `yarn build:dev`
+ Fixes a call to `_reformatAltHovered()` even when the `unformatOnHover` option was set to `false`

### 4.4.3
+ Fixes #598 The `unformatOnHover` config value isn't used when set to `false`
Expand Down
4 changes: 2 additions & 2 deletions config/webpack.config.dev.js
Expand Up @@ -7,8 +7,8 @@ const baseWebpackConfig = require('./webpack.config.base.js');

module.exports = merge(baseWebpackConfig, {
mode : 'development',
// cheap-module-eval-source-map is faster for development
devtool: '#cheap-module-eval-source-map',
// cf. https://webpack.js.org/configuration/devtool/
devtool: 'cheap-source-map',
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
// new FriendlyErrorsPlugin(),
Expand Down
32 changes: 31 additions & 1 deletion config/webpack.config.prd.js
Expand Up @@ -45,6 +45,36 @@ const webpackConfig = merge(baseWebpackConfig, {
output : { // See https://github.com/mishoo/UglifyJS2#output-options
beautify: false,
comments: false,
preamble: `/**
* AutoNumeric.js - http://autonumeric.org
*
* @authors Bob Knothe, Alexandre Bonneau
* @copyright 2009 Robert J. Knothe
*
* @license Released under the MIT License
* http://www.opensource.org/licenses/mit-license.php
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sub license, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/`
},
mangle : { // see https://github.com/mishoo/UglifyJS2#mangle-options
keep_fnames: false,
Expand All @@ -54,7 +84,7 @@ const webpackConfig = merge(baseWebpackConfig, {
}),
],
},
devtool: '#source-map',
devtool: 'source-map',
output : {
libraryTarget: 'umd',
library : 'AutoNumeric',
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -3,6 +3,7 @@
"version": "4.5.0",
"description": "autoNumeric is a standalone Javascript library that provides live *as-you-type* formatting for international numbers and currencies. It supports most international numeric formats and currencies including those used in Europe, Asia, and North and South America.",
"main": "dist/autoNumeric.js",
"browser": "dist/autoNumeric.min.js",
"module": "src/main.js",
"readmeFilename": "README.md",
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions src/AutoNumeric.js
Expand Up @@ -2,7 +2,7 @@
* AutoNumeric.js
*
* @version 4.5.0
* @date 2018-10-13 UTC 01:00
* @date 2018-10-13 UTC 01:16
*
* @authors Bob Knothe, Alexandre Bonneau
* @contributors Sokolov Yura and others, cf. AUTHORS
Expand Down Expand Up @@ -6619,7 +6619,7 @@ To solve that, you'd need to either set \`decimalPlacesRawValue\` to \`null\`, o
}

// Manage the reformat when hovered with the Alt key pressed
if (this.eventKey === AutoNumericEnum.keyName.Alt && this.hoveredWithAlt) {
if (this.eventKey === AutoNumericEnum.keyName.Alt && this.settings.unformatOnHover && this.hoveredWithAlt) {
this.constructor._reformatAltHovered(this);

return;
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/index.html
Expand Up @@ -179,7 +179,8 @@
</style>
<!-- Used by the end-to-end server spin up for the tests : -->
<script src="/autonumeric"></script>
<script src="../../dist/autoNumeric.min.js"></script>
<!--<script src="../../dist/autoNumeric.min.js"></script>-->
<script src="../../dist/autoNumeric.js"></script>
<!-- ^ Used by the page when calling it manually directly in the browser -->
</head>
<body>
Expand Down

0 comments on commit 403cf92

Please sign in to comment.