Skip to content

Commit ea7a3b6

Browse files
committed
Updated of version webpack
1 parent 84978ce commit ea7a3b6

File tree

7 files changed

+10439
-945
lines changed

7 files changed

+10439
-945
lines changed

README.md

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,55 @@
11

22
# react-webpack-component
33

4-
[![NPM version](https://badge.fury.io/js/react-webpack-component.svg)](https://npmjs.org/package/react-webpack-component) [![Build Status](https://travis-ci.org/kevoj/react-webpack-component.svg?branch=master)](https://travis-ci.org/kevoj/react-webpack-component) [![dependencies Status](https://david-dm.org/kevoj/react-webpack-component/status.svg)](https://david-dm.org/kevoj/react-webpack-component) [![devDependencies Status](https://david-dm.org/kevoj/react-webpack-component/dev-status.svg)](https://david-dm.org/kevoj/react-webpack-component?type=dev)
5-
[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://raw.githubusercontent.com/kevoj/role-calc/master/LICENSE)
4+
[![NPM version](https://badge.fury.io/js/react-webpack-component.svg)](https://npmjs.org/package/react-webpack-component) [![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://raw.githubusercontent.com/kevoj/role-calc/master/LICENSE)
65

7-
> Base structure in Webpack for the creation of npm modules in React
6+
> Base structure in Webpack 4 for the creation of npm modules in React
87
98
### Installation
109

11-
* **Clone**
10+
**1. Clone**
1211

1312
```bash
14-
git clone https://github.com/kevoj/react-webpack-component.git
15-
cd react-webpack-component
13+
git clone https://github.com/kevoj/react-webpack-component.git your-react-component-name
14+
cd [your-react-component-name]
1615
npm install
1716
```
17+
**2. Set name of the library**
18+
Replace in **package.json**
1819

19-
* **Create Link**
20+
```json
21+
{
22+
"name": "your-react-component-name",
23+
...
24+
}
25+
```
26+
**3. Create Link**
2027

2128
```bash
2229
npm run build
2330
npm link
2431
```
32+
## Development
2533

2634
### Start
2735

36+
Watch changes in mode development
37+
2838
```bash
2939
npm start
3040
```
3141

3242
### Build
3343

44+
Compile in mode production
45+
3446
```bash
3547
npm run Build
3648
```
37-
3849
### Structure
3950

4051
<pre>
41-
|-- build (Compiled)
52+
|-- dist (Compiled)
4253
| `-- index.js
4354
|-- src (Your code here, view example in code source...)
4455
| |-- components
@@ -49,16 +60,15 @@ npm run Build
4960
### Test the component in a project
5061

5162
```bash
52-
mkdir new-project (React project)
53-
cd new-project
54-
npm link react-webpack-component
63+
cd Existing-React-Project
64+
npm link your-react-component-name
5565
```
5666

5767
### At this point you can already use your component, usage:
5868

5969
```javascript
6070
import React, { Component } from 'react';
61-
import { Example } from 'react-webpack-component'
71+
import { Example } from 'your-npm-name'
6272

6373
class HelloWorld extends Component {
6474
render() {
@@ -70,6 +80,38 @@ class HelloWorld extends Component {
7080
export default HelloWorld;
7181
```
7282

83+
## Production
84+
85+
### Publish in NPM
86+
87+
**1. Compile to production**
88+
89+
```bash
90+
npm run build
91+
```
92+
93+
**2. Login**
94+
95+
```bash
96+
npm login
97+
# login with your credentials in https://www.npmjs.com/
98+
```
99+
100+
**3. Upload package**
101+
102+
**Note:** Verify your version of the component in **package.json**, you can not upload the same version twice
103+
104+
```bash
105+
npm publish
106+
# Available in https://www.npmjs.com/package/your-react-component-name
107+
```
108+
Now, you can install your package with:
109+
110+
```bash
111+
npm install your-react-component-name--save
112+
# :)
113+
```
114+
73115
## License
74116

75117
MIT © [Leonardo Rico](https://github.com/kevoj/react-webpack-component/blob/master/LICENSE)

build/index.js

Lines changed: 0 additions & 150 deletions
This file was deleted.

dist/index.js

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
module.exports =
2+
/******/ (function(modules) { // webpackBootstrap
3+
/******/ // The module cache
4+
/******/ var installedModules = {};
5+
/******/
6+
/******/ // The require function
7+
/******/ function __webpack_require__(moduleId) {
8+
/******/
9+
/******/ // Check if module is in cache
10+
/******/ if(installedModules[moduleId]) {
11+
/******/ return installedModules[moduleId].exports;
12+
/******/ }
13+
/******/ // Create a new module (and put it into the cache)
14+
/******/ var module = installedModules[moduleId] = {
15+
/******/ i: moduleId,
16+
/******/ l: false,
17+
/******/ exports: {}
18+
/******/ };
19+
/******/
20+
/******/ // Execute the module function
21+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/
23+
/******/ // Flag the module as loaded
24+
/******/ module.l = true;
25+
/******/
26+
/******/ // Return the exports of the module
27+
/******/ return module.exports;
28+
/******/ }
29+
/******/
30+
/******/
31+
/******/ // expose the modules object (__webpack_modules__)
32+
/******/ __webpack_require__.m = modules;
33+
/******/
34+
/******/ // expose the module cache
35+
/******/ __webpack_require__.c = installedModules;
36+
/******/
37+
/******/ // define getter function for harmony exports
38+
/******/ __webpack_require__.d = function(exports, name, getter) {
39+
/******/ if(!__webpack_require__.o(exports, name)) {
40+
/******/ Object.defineProperty(exports, name, {
41+
/******/ configurable: false,
42+
/******/ enumerable: true,
43+
/******/ get: getter
44+
/******/ });
45+
/******/ }
46+
/******/ };
47+
/******/
48+
/******/ // define __esModule on exports
49+
/******/ __webpack_require__.r = function(exports) {
50+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
51+
/******/ };
52+
/******/
53+
/******/ // getDefaultExport function for compatibility with non-harmony modules
54+
/******/ __webpack_require__.n = function(module) {
55+
/******/ var getter = module && module.__esModule ?
56+
/******/ function getDefault() { return module['default']; } :
57+
/******/ function getModuleExports() { return module; };
58+
/******/ __webpack_require__.d(getter, 'a', getter);
59+
/******/ return getter;
60+
/******/ };
61+
/******/
62+
/******/ // Object.prototype.hasOwnProperty.call
63+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
64+
/******/
65+
/******/ // __webpack_public_path__
66+
/******/ __webpack_require__.p = "";
67+
/******/
68+
/******/
69+
/******/ // Load entry module and return exports
70+
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js");
71+
/******/ })
72+
/************************************************************************/
73+
/******/ ({
74+
75+
/***/ "./src/components/Example.js":
76+
/*!***********************************!*\
77+
!*** ./src/components/Example.js ***!
78+
\***********************************/
79+
/*! no static exports found */
80+
/***/ (function(module, exports, __webpack_require__) {
81+
82+
"use strict";
83+
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _react = __webpack_require__(/*! react */ \"react\");\n\nvar _react2 = _interopRequireDefault(_react);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar ExampleComponent = function (_Component) {\n _inherits(ExampleComponent, _Component);\n\n function ExampleComponent() {\n _classCallCheck(this, ExampleComponent);\n\n return _possibleConstructorReturn(this, (ExampleComponent.__proto__ || Object.getPrototypeOf(ExampleComponent)).apply(this, arguments));\n }\n\n _createClass(ExampleComponent, [{\n key: 'render',\n value: function render() {\n return _react2.default.createElement(\n 'div',\n null,\n 'This is so Example!'\n );\n }\n }]);\n\n return ExampleComponent;\n}(_react.Component);\n\nexports.default = ExampleComponent;\n\n//# sourceURL=webpack:///./src/components/Example.js?");
84+
85+
/***/ }),
86+
87+
/***/ "./src/index.js":
88+
/*!**********************!*\
89+
!*** ./src/index.js ***!
90+
\**********************/
91+
/*! no static exports found */
92+
/***/ (function(module, exports, __webpack_require__) {
93+
94+
"use strict";
95+
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.Example = undefined;\n\nvar _Example = __webpack_require__(/*! ./components/Example */ \"./src/components/Example.js\");\n\nvar _Example2 = _interopRequireDefault(_Example);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.Example = _Example2.default;\n\n/**\n * Usage:\n * import { Example } from 'react-webpack-component'\n * import * as ReactWebpackComponent from 'react-webpack-component'\n */\n\n//# sourceURL=webpack:///./src/index.js?");
96+
97+
/***/ }),
98+
99+
/***/ "react":
100+
/*!************************!*\
101+
!*** external "react" ***!
102+
\************************/
103+
/*! no static exports found */
104+
/***/ (function(module, exports) {
105+
106+
eval("module.exports = require(\"react\");\n\n//# sourceURL=webpack:///external_%22react%22?");
107+
108+
/***/ })
109+
110+
/******/ });

0 commit comments

Comments
 (0)