Skip to content

Commit cb493e2

Browse files
committed
build preactUJS
1 parent 101b51e commit cb493e2

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

preact_ujs/dist/preact_ujs.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
(function webpackUniversalModuleDefinition(root, factory) {
22
if(typeof exports === 'object' && typeof module === 'object')
3-
module.exports = factory();
3+
module.exports = factory(require("preact"));
44
else if(typeof define === 'function' && define.amd)
5-
define([], factory);
5+
define(["preact"], factory);
66
else if(typeof exports === 'object')
7-
exports["PreactRailsUJS"] = factory();
7+
exports["PreactRailsUJS"] = factory(require("preact"));
88
else
9-
root["PreactRailsUJS"] = factory();
10-
})(window, function() {
9+
root["PreactRailsUJS"] = factory(root["Preact"]);
10+
})(window, function(__WEBPACK_EXTERNAL_MODULE_preact__) {
1111
return /******/ (function(modules) { // webpackBootstrap
1212
/******/ // The module cache
1313
/******/ var installedModules = {};
@@ -103,7 +103,7 @@ return /******/ (function(modules) { // webpackBootstrap
103103
/*! no static exports found */
104104
/***/ (function(module, exports, __webpack_require__) {
105105

106-
eval("//var preact = require(\"preact\")\nvar constructorFromGlobal = __webpack_require__(/*! ./src/getConstructor/fromGlobal */ \"./src/getConstructor/fromGlobal.js\")\nvar constructorFromRequireContextWithGlobalFallback = __webpack_require__(/*! ./src/getConstructor/fromRequireContextWithGlobalFallback */ \"./src/getConstructor/fromRequireContextWithGlobalFallback.js\")\n\nvar PreactRailsUJS = {\n CLASS_NAME_ATTR: 'data-preact-class',\n PROPS_ATTR: 'data-preact-props',\n\n findDOMNodes: function() {\n return document.querySelectorAll('['+PreactRailsUJS.CLASS_NAME_ATTR+']')\n },\n\n getConstructor: constructorFromGlobal,\n\n useContext: function(requireContext) {\n this.getConstructor = constructorFromRequireContextWithGlobalFallback(requireContext)\n },\n\n mountComponents: function() {\n console.log('mountcomponent loaded')\n var nodes = PreactRailsUJS.findDOMNodes()\n for (var i = 0; i < nodes.length; ++i) {\n var node = nodes[i]\n //PreactRailsUJS.clearChildNodes(node)\n var className = node.getAttribute(PreactRailsUJS.CLASS_NAME_ATTR)\n var constructor = PreactRailsUJS.getConstructor(className)\n var propsJson = node.getAttribute(PreactRailsUJS.PROPS_ATTR)\n var props = propsJson && JSON.parse(propsJson)\n preact.render(preact.h(constructor, props), node)\n }\n },\n\n clearChildNodes: function(node) {\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n },\n\n handleEvent: function(eventName, callback) {\n document.addEventListener(eventName, callback);\n },\n\n removeEvent: function(eventName, callback) {\n document.removeEventListener(eventName, callback);\n }\n\n}\n\nPreactRailsUJS.handleEvent('DOMContentLoaded', PreactRailsUJS.mountComponents)\n\nmodule.exports = PreactRailsUJS\n\n\n//# sourceURL=webpack://PreactRailsUJS/./index.js?");
106+
eval("var preact = __webpack_require__(/*! preact */ \"preact\")\nvar constructorFromGlobal = __webpack_require__(/*! ./src/getConstructor/fromGlobal */ \"./src/getConstructor/fromGlobal.js\")\nvar constructorFromRequireContextWithGlobalFallback = __webpack_require__(/*! ./src/getConstructor/fromRequireContextWithGlobalFallback */ \"./src/getConstructor/fromRequireContextWithGlobalFallback.js\")\n\nvar PreactRailsUJS = {\n CLASS_NAME_ATTR: 'data-preact-class',\n PROPS_ATTR: 'data-preact-props',\n\n findDOMNodes: function() {\n return document.querySelectorAll('['+PreactRailsUJS.CLASS_NAME_ATTR+']')\n },\n\n getConstructor: constructorFromGlobal,\n\n useContext: function(requireContext) {\n this.getConstructor = constructorFromRequireContextWithGlobalFallback(requireContext)\n },\n\n mountComponents: function() {\n var nodes = PreactRailsUJS.findDOMNodes()\n for (var i = 0; i < nodes.length; ++i) {\n var node = nodes[i]\n PreactRailsUJS.clearChildNodes(node)\n var className = node.getAttribute(PreactRailsUJS.CLASS_NAME_ATTR)\n var constructor = PreactRailsUJS.getConstructor(className)\n var propsJson = node.getAttribute(PreactRailsUJS.PROPS_ATTR)\n var props = propsJson && JSON.parse(propsJson)\n preact.render(preact.h(constructor, props), node)\n }\n },\n\n clearChildNodes: function(node) {\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n },\n\n handleEvent: function(eventName, callback) {\n document.addEventListener(eventName, callback);\n },\n\n removeEvent: function(eventName, callback) {\n document.removeEventListener(eventName, callback);\n }\n\n}\n\nPreactRailsUJS.handleEvent('DOMContentLoaded', PreactRailsUJS.mountComponents)\n\nmodule.exports = PreactRailsUJS\n\n\n//# sourceURL=webpack://PreactRailsUJS/./index.js?");
107107

108108
/***/ }),
109109

@@ -138,6 +138,17 @@ eval("// Load React components by requiring them from \"components/\", for examp
138138

139139
eval("// Make a function which:\n// - First tries to require the name\n// - Then falls back to global lookup\nvar fromGlobal = __webpack_require__(/*! ./fromGlobal */ \"./src/getConstructor/fromGlobal.js\")\nvar fromRequireContext = __webpack_require__(/*! ./fromRequireContext */ \"./src/getConstructor/fromRequireContext.js\")\n\nmodule.exports = function(reqctx) {\n var fromCtx = fromRequireContext(reqctx)\n return function(className) {\n var component;\n try {\n // `require` will raise an error if this className isn't found:\n component = fromCtx(className)\n } catch (firstErr) {\n // fallback to global:\n try {\n component = fromGlobal(className)\n } catch (secondErr) {\n console.error(firstErr)\n console.error(secondErr)\n }\n }\n return component\n }\n}\n\n\n//# sourceURL=webpack://PreactRailsUJS/./src/getConstructor/fromRequireContextWithGlobalFallback.js?");
140140

141+
/***/ }),
142+
143+
/***/ "preact":
144+
/*!******************************************************************************************!*\
145+
!*** external {"root":"Preact","commonjs2":"preact","commonjs":"preact","amd":"preact"} ***!
146+
\******************************************************************************************/
147+
/*! no static exports found */
148+
/***/ (function(module, exports) {
149+
150+
eval("module.exports = __WEBPACK_EXTERNAL_MODULE_preact__;\n\n//# sourceURL=webpack://PreactRailsUJS/external_%7B%22root%22:%22Preact%22,%22commonjs2%22:%22preact%22,%22commonjs%22:%22preact%22,%22amd%22:%22preact%22%7D?");
151+
141152
/***/ })
142153

143154
/******/ });

0 commit comments

Comments
 (0)