diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..efb3367 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# http://editorconfig.org + +root = true + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 2 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..513c925 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,72 @@ +{ + "parser": "babel-eslint", + "extends": "airbnb", + "env": { + "browser": true, + "node": true, + "es6": true, + }, + "ecmaFeatures": { + "arrowFunctions": true, + "blockBindings": true, + "classes": true, + "defaultParams": true, + "destructuring": true, + "jsx": true, + "modules": true, + "objectLiteralComputedProperties": true, + "objectLiteralShorthandMethods": true, + "objectLiteralShorthandProperties": true, + "spread": true, + "templateStrings": true + }, + "globals": { + "__DEV__": true, + "describe": true, + "it": true, + "beforeEach": true, + "afterEach": true, + "expect": true, + "browser": true, + "by": true, + "element": true, + "jasmine": true + }, + "plugins": [ + "react" + ], + "rules": { + "no-unneeded-ternary" : "off", + "object-curly-spacing": ["error", "always", { + "objectsInObjects": false, + "arraysInObjects": false + }], + "comma-dangle": ["error", "never"], + "max-len": ["error", 100, 4, {"ignoreUrls": true}], + "space-before-function-paren": ["error", "never"], + "no-multiple-empty-lines": ["error", {max: 1}], + "no-use-before-define": 0, + "global-require": 0, + "no-else-return": "error", + "no-param-reassign": 0, + "prefer-const": 0, + "func-names": 0, + "arrow-body-style": 0, + "react/jsx-no-bind": [2, { + "ignoreRefs": false, + "allowArrowFunctions": true, + "allowBind": true + }], + "guard-for-in": 0, + "react/jsx-key": 2, + "react/jsx-no-undef": 0, + "react/prefer-stateless-function": 0, + "react/jsx-closing-bracket-location": 0, + "no-undef": "error", + "one-var": 0, + "no-extra-semi": "error", + "semi": "error", + "prefer-arrow-callback": "error", + "new-cap": "off" + } +} diff --git a/demo/package.json b/demo/package.json index e8b23e0..5213983 100644 --- a/demo/package.json +++ b/demo/package.json @@ -13,9 +13,7 @@ "devDependencies": { "html-minify-loader": "^1.1.0", "raw-loader": "^0.5.1", - "webpack": "^2.3.3" - }, - "dependencies": { - "webpack-auto-inject-version": "^0.5.5" + "webpack": "^2.3.3", + "webpack-auto-inject-version": "^0.5.10" } } diff --git a/demo/webpack.conf.js b/demo/webpack.conf.js index c87f689..5d76060 100644 --- a/demo/webpack.conf.js +++ b/demo/webpack.conf.js @@ -1,8 +1,8 @@ var path = require('path'); // Require WebpackAutoInject from npm installed modules ( preferred ) -// var WebpackAutoInject = require('webpack-auto-inject-version').default; +var WebpackAutoInject = require('webpack-auto-inject-version'); // Require WebpackAutoInject from dist - dev purpose only ( do not use the below line ) -var WebpackAutoInject = require('../dist/WebpackAutoInjectVersion').default; +// var WebpackAutoInject = require('../dist/WebpackAutoInjectVersion'); module.exports = { entry: { diff --git a/dist/WebpackAutoInjectVersion.js b/dist/WebpackAutoInjectVersion.js index ad6f95b..bd80ea0 100644 --- a/dist/WebpackAutoInjectVersion.js +++ b/dist/WebpackAutoInjectVersion.js @@ -4993,7 +4993,7 @@ module.exports = require("os"); /***/ (function(module, exports, __webpack_require__) { "use strict"; - +var __WEBPACK_AMD_DEFINE_RESULT__; Object.defineProperty(exports, "__esModule", { value: true @@ -5260,6 +5260,12 @@ WebpackAutoInject.protectedConfig = { }; exports.default = WebpackAutoInject; + +!(__WEBPACK_AMD_DEFINE_RESULT__ = function (Foo) { + return WebpackAutoInject; +}.call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + /***/ }), /* 158 */ /***/ (function(module, exports, __webpack_require__) { diff --git a/src/main.js b/src/main.js index 0153dcd..d8f8e96 100644 --- a/src/main.js +++ b/src/main.js @@ -103,4 +103,11 @@ export default class WebpackAutoInject{ // call next tick await this.executeComponent(components); } -} \ No newline at end of file +} + +// webpack hack to export class directly, +// - instead of using 'new WebpackAutoInject.default()', +// - with this you can just use WebpackAutoInject(); +define(() => { + return WebpackAutoInject; +});