Skip to content

Commit 6cc541f

Browse files
committed
another attempts at module packaging
1 parent d343318 commit 6cc541f

11 files changed

Lines changed: 4059 additions & 1394 deletions

dist/idiomorph-ext.js

Lines changed: 741 additions & 675 deletions
Large diffs are not rendered by default.

dist/idiomorph-ext.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/idiomorph-htmx.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
htmx.defineExtension('morph', {
2-
isInlineSwap: function(swapStyle) {
3-
return swapStyle === 'morph';
4-
},
5-
handleSwap: function (swapStyle, target, fragment) {
1+
(function(){
2+
function createMorphConfig(swapStyle) {
63
if (swapStyle === 'morph' || swapStyle === 'morph:outerHTML') {
7-
return Idiomorph.morph(target, fragment.children);
4+
return {morphStyle: 'outerHTML'}
85
} else if (swapStyle === 'morph:innerHTML') {
9-
return Idiomorph.morph(target, fragment.children, {morphStyle:'innerHTML'});
6+
return {morphStyle: 'innerHTML'}
7+
} else if (swapStyle.startsWith("morph:")) {
8+
return Function("return (" + swapStyle.slice(6) + ")")();
109
}
1110
}
12-
});
11+
12+
htmx.defineExtension('morph', {
13+
isInlineSwap: function(swapStyle) {
14+
let config = createMorphConfig(swapStyle);
15+
return config.swapStyle === "outerHTML" || config.swapStyle == null;
16+
},
17+
handleSwap: function (swapStyle, target, fragment) {
18+
let config = createMorphConfig(swapStyle);
19+
if (config) {
20+
return Idiomorph.morph(target, fragment.children, config);
21+
}
22+
}
23+
});
24+
})()

dist/idiomorph.amd.js

Lines changed: 850 additions & 0 deletions
Large diffs are not rendered by default.

dist/idiomorph.cjs.js

Lines changed: 850 additions & 0 deletions
Large diffs are not rendered by default.

dist/idiomorph.esm.js

Lines changed: 850 additions & 0 deletions
Large diffs are not rendered by default.

dist/idiomorph.js

Lines changed: 738 additions & 684 deletions
Large diffs are not rendered by default.

dist/idiomorph.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/idiomorph.min.js.gz

89 Bytes
Binary file not shown.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
"unpkg": "dist/idiomorph.min.js",
2020
"scripts": {
2121
"test": "mocha-chrome test/index.html",
22-
"dist": "cp -r src/* dist/ && cat src/idiomorph.js src/idiomorph-htmx.js > dist/idiomorph-ext.js && npm run-script uglify && gzip -9 -k -f dist/idiomorph.min.js > dist/idiomorph.min.js.gz && exit",
22+
"amd" : "(cat src/idiomorph.js && echo \"\ndefine([], Idiomorph);\") > dist/idiomorph.amd.js",
23+
"cjs" : "(cat src/idiomorph.js && echo \"\nmodule.exports = Idiomorph;\") > dist/idiomorph.cjs.js",
24+
"esm" : "(cat src/idiomorph.js && echo \"\nexport default {Idiomorph};\") > dist/idiomorph.esm.js",
25+
"gen-modules" : "npm run-script amd && npm run-script cjs && npm run-script esm",
26+
"dist": "cp -r src/* dist/ && cat src/idiomorph.js src/idiomorph-htmx.js > dist/idiomorph-ext.js && npm run-script gen-modules && npm run-script uglify && gzip -9 -k -f dist/idiomorph.min.js > dist/idiomorph.min.js.gz && exit",
2327
"uglify": "uglifyjs -m eval -o dist/idiomorph.min.js dist/idiomorph.js && uglifyjs -m eval -o dist/idiomorph-ext.min.js dist/idiomorph-ext.js"
2428
},
2529
"repository": {

0 commit comments

Comments
 (0)