Upgraded to webpack 4 (#941)

* Upgrade to webpack 4 - partly working

* Upgraded to webpack 4

* Fixed error with webpack ProvidePlugin

* Fixed ESLint errors
This commit is contained in:
Martin Donath
2018-12-28 14:44:41 +01:00
committed by GitHub
parent 18221a7d1f
commit 4e72119d20
16 changed files with 3325 additions and 5324 deletions

View File

@@ -1,13 +1,8 @@
{
"presets": [
["env", {
["@babel/preset-env", {
"loose": true,
"target": {
"browsers": [
"> 1%",
"last 2 versions"
]
}
"targets": " > 1%, last 2 versions"
}]
],
"plugins": [

View File

@@ -25,52 +25,50 @@
* ------------------------------------------------------------------------- */
/* eslint-disable no-underscore-dangle */
export default /* JSX */ {
/**
* Create a native DOM node from JSX's intermediate representation
*
* @param {string} tag - Tag name
* @param {?Object} properties - Properties
* @param {Array<string | number | { __html: string } | Array<HTMLElement>>}
* children - Child nodes
* @return {HTMLElement} Native DOM node
*/
createElement(tag, properties, ...children) {
const el = document.createElement(tag)
/**
* Create a native DOM node from JSX's intermediate representation
*
* @param {string} tag - Tag name
* @param {?Object} properties - Properties
* @param {Array<string | number | { __html: string } | Array<HTMLElement>>}
* children - Child nodes
* @return {HTMLElement} Native DOM node
*/
export function createElement(tag, properties, ...children) {
const el = document.createElement(tag)
/* Set all properties */
if (properties)
Array.prototype.forEach.call(Object.keys(properties), attr => {
el.setAttribute(attr, properties[attr])
})
/* Set all properties */
if (properties)
Array.prototype.forEach.call(Object.keys(properties), attr => {
el.setAttribute(attr, properties[attr])
})
/* Iterate child nodes */
const iterateChildNodes = nodes => {
Array.prototype.forEach.call(nodes, node => {
/* Iterate child nodes */
const iterateChildNodes = nodes => {
Array.prototype.forEach.call(nodes, node => {
/* Directly append text content */
if (typeof node === "string" ||
typeof node === "number") {
el.textContent += node
/* Directly append text content */
if (typeof node === "string" ||
typeof node === "number") {
el.textContent += node
/* Recurse, if we got an array */
} else if (Array.isArray(node)) {
iterateChildNodes(node)
/* Recurse, if we got an array */
} else if (Array.isArray(node)) {
iterateChildNodes(node)
/* Append raw HTML */
} else if (typeof node.__html !== "undefined") {
el.innerHTML += node.__html
/* Append raw HTML */
} else if (typeof node.__html !== "undefined") {
el.innerHTML += node.__html
/* Append regular nodes */
} else if (node instanceof Node) {
el.appendChild(node)
}
})
}
/* Iterate child nodes and return element */
iterateChildNodes(children)
return el
/* Append regular nodes */
} else if (node instanceof Node) {
el.appendChild(node)
}
})
}
/* Iterate child nodes and return element */
iterateChildNodes(children)
return el
}