webpacker-react 0.3.2 → 1.0.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.circleci/config.yml +32 -0
- data/.rubocop.yml +22 -22
- data/CHANGELOG.md +17 -1
- data/Gemfile +3 -2
- data/Gemfile.lock +122 -104
- data/LICENSE +21 -0
- data/README.md +27 -61
- data/Rakefile +1 -1
- data/javascript/webpacker_react-npm-module/.babelrc +7 -0
- data/javascript/webpacker_react-npm-module/dist/package.json +5 -3
- data/javascript/webpacker_react-npm-module/dist/yarn.lock +9 -0
- data/javascript/webpacker_react-npm-module/package.json +7 -7
- data/javascript/webpacker_react-npm-module/src/configure-hot-module-replacement.js +2 -17
- data/javascript/webpacker_react-npm-module/src/index.js +4 -28
- data/javascript/webpacker_react-npm-module/src/ujs.js +3 -3
- data/javascript/webpacker_react-npm-module/yarn.lock +1773 -1170
- data/lib/webpacker/react/version.rb +1 -1
- data/webpacker-react.gemspec +12 -11
- metadata +14 -14
- data/.travis.yml +0 -5
- data/circle.yml +0 -14
- data/javascript/webpacker_react-npm-module/src/hmr.js +0 -9
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpacker-react",
|
3
|
-
"version": "0.
|
3
|
+
"version": "1.0.0-beta.1",
|
4
4
|
"description": "Javascript",
|
5
5
|
"main": "index.js",
|
6
6
|
"homepage": "https://github.com/renchap/webpacker-react",
|
@@ -16,11 +16,13 @@
|
|
16
16
|
"files": [
|
17
17
|
"index.js",
|
18
18
|
"configure-hot-module-replacement.js",
|
19
|
-
"hmr.js",
|
20
19
|
"ujs.js"
|
21
20
|
],
|
22
21
|
"scripts": {
|
23
22
|
"prepublish": "cd .. ; yarn run build"
|
24
23
|
},
|
25
|
-
"license": "MIT"
|
24
|
+
"license": "MIT",
|
25
|
+
"dependencies": {
|
26
|
+
"webpack-merge": "^4.1.1"
|
27
|
+
}
|
26
28
|
}
|
@@ -2,3 +2,12 @@
|
|
2
2
|
# yarn lockfile v1
|
3
3
|
|
4
4
|
|
5
|
+
lodash@^4.17.4:
|
6
|
+
version "4.17.4"
|
7
|
+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
|
8
|
+
|
9
|
+
webpack-merge@^4.1.1:
|
10
|
+
version "4.1.1"
|
11
|
+
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.1.1.tgz#f1197a0a973e69c6fbeeb6d658219aa8c0c13555"
|
12
|
+
dependencies:
|
13
|
+
lodash "^4.17.4"
|
@@ -2,17 +2,17 @@
|
|
2
2
|
"name": "webpacker-react-build",
|
3
3
|
"private": true,
|
4
4
|
"scripts": {
|
5
|
-
"build": "babel src --
|
5
|
+
"build": "babel src --out-dir dist",
|
6
6
|
"lint": "eslint src/"
|
7
7
|
},
|
8
8
|
"devDependencies": {
|
9
9
|
"babel-cli": "^6.18.0",
|
10
|
-
"babel-preset-
|
11
|
-
"eslint": "^
|
12
|
-
"eslint-config-airbnb": "^
|
13
|
-
"eslint-plugin-import": "^2.
|
14
|
-
"eslint-plugin-jsx-a11y": "^
|
15
|
-
"eslint-plugin-react": "^7.
|
10
|
+
"babel-preset-env": "^1.6.1",
|
11
|
+
"eslint": "^5.3.0",
|
12
|
+
"eslint-config-airbnb": "^17.0.0",
|
13
|
+
"eslint-plugin-import": "^2.9.0",
|
14
|
+
"eslint-plugin-jsx-a11y": "^6.0.3",
|
15
|
+
"eslint-plugin-react": "^7.7.0"
|
16
16
|
},
|
17
17
|
"dependencies": {
|
18
18
|
"lodash": "^4.0.0"
|
@@ -1,16 +1,7 @@
|
|
1
|
-
import webpack from 'webpack'
|
2
1
|
import merge from 'webpack-merge'
|
3
2
|
|
4
|
-
function configureHotModuleReplacement(
|
5
|
-
const config =
|
6
|
-
originalConfig,
|
7
|
-
{
|
8
|
-
plugins: [
|
9
|
-
new webpack.NamedModulesPlugin()
|
10
|
-
]
|
11
|
-
}
|
12
|
-
)
|
13
|
-
|
3
|
+
function configureHotModuleReplacement(origConfig) {
|
4
|
+
const config = origConfig
|
14
5
|
config.module.rules = config.module.rules.map((rule) => {
|
15
6
|
if (rule.loader === 'babel-loader') {
|
16
7
|
return merge(rule, { options: { plugins: ['react-hot-loader/babel'] } })
|
@@ -18,12 +9,6 @@ function configureHotModuleReplacement(originalConfig) {
|
|
18
9
|
return rule
|
19
10
|
})
|
20
11
|
|
21
|
-
Object.keys(config.entry).forEach((key) => {
|
22
|
-
if (!(config.entry[key] instanceof Array)) {
|
23
|
-
config.entry[key] = [config.entry[key]]
|
24
|
-
}
|
25
|
-
config.entry[key].unshift('react-hot-loader/patch')
|
26
|
-
})
|
27
12
|
return config
|
28
13
|
}
|
29
14
|
|
@@ -11,38 +11,14 @@ const PROPS_ATTRIBUTE_NAME = 'data-react-props'
|
|
11
11
|
|
12
12
|
const WebpackerReact = {
|
13
13
|
registeredComponents: {},
|
14
|
-
wrapForHMR: null,
|
15
14
|
|
16
15
|
render(node, component) {
|
17
16
|
const propsJson = node.getAttribute(PROPS_ATTRIBUTE_NAME)
|
18
17
|
const props = propsJson && JSON.parse(propsJson)
|
19
18
|
|
20
|
-
|
21
|
-
if (this.wrapForHMR) {
|
22
|
-
reactElement = this.wrapForHMR(reactElement)
|
23
|
-
}
|
24
|
-
ReactDOM.render(reactElement, node)
|
25
|
-
},
|
26
|
-
|
27
|
-
renderOnHMR(component) {
|
28
|
-
const name = component.name
|
29
|
-
|
30
|
-
this.registeredComponents[name] = component
|
31
|
-
|
32
|
-
if (!this.wrapForHMR) {
|
33
|
-
console.warn('webpacker-react: renderOnHMR called but not elements not wrapped for HMR')
|
34
|
-
}
|
19
|
+
const reactElement = React.createElement(component, props)
|
35
20
|
|
36
|
-
|
37
|
-
for (let i = 0; i < toMount.length; i += 1) {
|
38
|
-
const node = toMount[i]
|
39
|
-
|
40
|
-
this.render(node, component)
|
41
|
-
}
|
42
|
-
},
|
43
|
-
|
44
|
-
registerWrapForHMR(wrapForHMR) {
|
45
|
-
this.wrapForHMR = wrapForHMR
|
21
|
+
ReactDOM.render(reactElement, node)
|
46
22
|
},
|
47
23
|
|
48
24
|
registerComponents(components) {
|
@@ -63,7 +39,7 @@ const WebpackerReact = {
|
|
63
39
|
},
|
64
40
|
|
65
41
|
mountComponents() {
|
66
|
-
const registeredComponents = this
|
42
|
+
const { registeredComponents } = this
|
67
43
|
const toMount = document.querySelectorAll(`[${CLASS_ATTRIBUTE_NAME}]`)
|
68
44
|
|
69
45
|
for (let i = 0; i < toMount.length; i += 1) {
|
@@ -74,7 +50,7 @@ const WebpackerReact = {
|
|
74
50
|
if (component) {
|
75
51
|
if (node.innerHTML.length === 0) this.render(node, component)
|
76
52
|
} else {
|
77
|
-
console.error(`webpacker-react:
|
53
|
+
console.error(`webpacker-react: can not render a component that has not been registered: ${className}`)
|
78
54
|
}
|
79
55
|
}
|
80
56
|
},
|
@@ -19,7 +19,7 @@ const ujs = {
|
|
19
19
|
|
20
20
|
setup(onMount, onUnmount) {
|
21
21
|
const $ = (typeof window.jQuery !== 'undefined') && window.jQuery
|
22
|
-
const Turbolinks = window
|
22
|
+
const { Turbolinks } = window
|
23
23
|
|
24
24
|
// Detect which kind of events to set up:
|
25
25
|
if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
|
@@ -46,7 +46,7 @@ const ujs = {
|
|
46
46
|
},
|
47
47
|
|
48
48
|
turbolinksClassic(onMount, onUnmount) {
|
49
|
-
const Turbolinks = window
|
49
|
+
const { Turbolinks } = window
|
50
50
|
|
51
51
|
this.handleEvent(Turbolinks.EVENTS.CHANGE, onMount)
|
52
52
|
this.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD, onUnmount)
|
@@ -57,7 +57,7 @@ const ujs = {
|
|
57
57
|
// have named events and didn't have a before-unload event.
|
58
58
|
// Also, it didn't work with the Turbolinks cache, see
|
59
59
|
// https://github.com/reactjs/react-rails/issues/87
|
60
|
-
const Turbolinks = window
|
60
|
+
const { Turbolinks } = window
|
61
61
|
Turbolinks.pagesCached(0)
|
62
62
|
this.handleEvent('page:change', onMount)
|
63
63
|
this.handleEvent('page:receive', onUnmount)
|