Skip to content

Commit af5f931

Browse files
committed
Fix issue autoNumeric#4 Error when building with webpack 2 on linux
Fix the autonumeric external config 1. depend `autonumeric` as `autonumeric` in amd or commonjs environment. 2. depend `autonumeric` as `AutoNumeric` in global script environment.
1 parent 42efe4d commit af5f931

File tree

7 files changed

+20
-13
lines changed

7 files changed

+20
-13
lines changed

build/webpack.base.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ module.exports = {
7171
externals: {
7272
// This prevent bundling the AutoNumeric library inside the vue-autornumeric component
7373
// cf. https://webpack.js.org/configuration/externals/
74-
AutoNumeric: 'AutoNumeric',
74+
autonumeric : {
75+
commonjs2: 'autonumeric',
76+
commonjs: 'autonumeric',
77+
amd: 'autonumeric',
78+
root: 'AutoNumeric', // indicates global variable
79+
},
7580
},
7681
};

build/webpack.examples.js

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const webpack = require('webpack');
66
const options = require('./options');
77
const base = require('./webpack.base.js');
88

9+
// do not exclude the autonumeric in the bundle of the examples page
10+
delete base.externals;
11+
912
const config = merge(base, {
1013
entry: options.paths.resolve('examples-src/index.js'),
1114

dist/vue-autonumeric.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*/
66
(function webpackUniversalModuleDefinition(root, factory) {
77
if(typeof exports === 'object' && typeof module === 'object')
8-
module.exports = factory(require("AutoNumeric"));
8+
module.exports = factory(require("autonumeric"));
99
else if(typeof define === 'function' && define.amd)
10-
define("VueAutonumeric", ["AutoNumeric"], factory);
10+
define("VueAutonumeric", ["autonumeric"], factory);
1111
else if(typeof exports === 'object')
12-
exports["VueAutonumeric"] = factory(require("AutoNumeric"));
12+
exports["VueAutonumeric"] = factory(require("autonumeric"));
1313
else
1414
root["VueAutonumeric"] = factory(root["AutoNumeric"]);
1515
})(this, function(__WEBPACK_EXTERNAL_MODULE_43__) {
@@ -284,9 +284,9 @@ var _assign = __webpack_require__(15);
284284

285285
var _assign2 = _interopRequireDefault(_assign);
286286

287-
var _AutoNumeric = __webpack_require__(43);
287+
var _autonumeric = __webpack_require__(43);
288288

289-
var _AutoNumeric2 = _interopRequireDefault(_AutoNumeric);
289+
var _autonumeric2 = _interopRequireDefault(_autonumeric);
290290

291291
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
292292

@@ -338,7 +338,7 @@ exports.default = {
338338
options = this.manageOptionElement(this.options);
339339
}
340340

341-
this.anElement = new _AutoNumeric2.default(this.$refs.autoNumericInput, options);
341+
this.anElement = new _autonumeric2.default(this.$refs.autoNumericInput, options);
342342
if (this.value !== null && this.value !== '') {
343343
this.anElement.set(this.value);
344344

@@ -363,7 +363,7 @@ exports.default = {
363363
manageOptionElement: function manageOptionElement(optionElement) {
364364
var options = void 0;
365365
if (typeof optionElement === 'string' || optionElement instanceof String) {
366-
options = _AutoNumeric2.default.getPredefinedOptions()[optionElement];
366+
options = _autonumeric2.default.getPredefinedOptions()[optionElement];
367367
if (options === void 0 || options === null) {
368368
console.warn('The given pre-defined options [' + optionElement + '] is not recognized by autoNumeric.\nSwitching back to the default options.');
369369
options = defaultOptions;

dist/vue-autonumeric.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/examples.bundle.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
</head>
2222
<body>
2323
<div id="app"></div>
24-
<script src="https://unpkg.com/autonumeric"></script>
2524
<script src="examples.bundle.js"></script>
2625
</body>
2726
</html>

src/components/VueAutonumeric.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ OTHER DEALINGS IN THE SOFTWARE.
5454
</template>
5555

5656
<script type="text/babel">
57-
import AutoNumeric from 'AutoNumeric';
57+
import AutoNumeric from 'autonumeric';
5858

5959
// Custom default autoNumeric option can be set here to override the default autoNumeric ones
6060
const defaultOptions = {};

0 commit comments

Comments
 (0)