flibbles / tw5-uglify Goto Github PK
View Code? Open in Web Editor NEWCompress TiddlyWiki5 javascript and plugins
License: Other
Compress TiddlyWiki5 javascript and plugins
License: Other
Producing an uglified version of tiddlywikicore.js
is buggy for the newly released TiddlyWiki 5.3.0.
Here's how I'm creating an external core empty and uglified tiddlywikicore.js. The commands are run in the TiddlyWiki5 git repo with tw5-uglify checked out in an adjacent directory:
export TIDDLYWIKI_PLUGIN_PATH=../tw5-uglify
node tiddlywiki.js editions/empty --output output/external-core \
--rendertiddler '$:/core/save/offline-external-js' 'empty.html' 'text/plain'
node tiddlywiki.js +plugins/plugins/uglify editions/empty --output output/external-core \
--render '$:/core/templates/tiddlywiki5.js' '[[tiddlywikicore-]addsuffix<version>addsuffix[.js]]' 'text/plain'
ls -l output/external-core
If you open the generated empty.html file you can see the problem. There is <<>>
showing up in many places instead of the expected content.
Looking at the core js file, there is text like Update <<>> plugins
inside the $:/core
plugin, instead of Update <<update-count>> plugins
which I think is causing the problem. If you search for <<>>
you can find many other examples. I guess somehow the uglify code is stripping out the text incorrectly.
Producing a non-uglified core js file like this is useful to compare the uglified and non-uglified output:
node tiddlywiki.js editions/empty --output output/external-core \
--render '$:/core/templates/tiddlywiki5.js' '[[tiddlywikicore-]addsuffix<version>addsuffix[.normal]addsuffix[.js]]' 'text/plain'
When click on a link in Open tab, or when click on a link in story river, TW does not scroll to the tiddler its title clicked.
I used uglify 1.7.0 on an empty.html. In the uglified.html pressing the transclude editortoolbarbutton gives a red screen with internal JavaScript Error:
Internal JavaScript Error
Well, this is embarrassing. It is recommended that you restart TiddlyWiki by refreshing your browser
TypeError: t.paramObject.suffix is undefined
Typing the brackets and transcluding works. Only the button seams to be broken. This happens in all my uglified Wikis.
Importing $:/core/ui/EditorToolbar/transcludify from empty.html to an uglified wiki fixes the button
Uglify convert the below macro
\define toc-list(here,exclude)
<$list filter="""[tag[$here$]] $exclude$ -[[$here$]]""">
<$text text="[["/><<currentTiddler>><$text text="]]"/>
<$macrocall $name="toc-list" here=<<currentTiddler>> exclude="""$exclude$ -[[$here$]]"""/>
</$list>
\end
To this one
\define toc-list(here exclude)
<$list filter="""[tag[$here$]]$exclude$ -$here$""">
<$text text=[[/><<currentTiddler>><$text text=]]/>
<$macrocall here={{!!title}}exclude="""$exclude$ -[[$here$]]"""$name=toc-list/>
\end
The uglified version does not work. Look at the filter of first line:
<$list filter="""[tag[$here$]] $exclude$ -[[$here$]]""">
<$list filter="""[tag[$here$]]$exclude$ -$here$""">
When
I use this in a TOC macro developed by @ericshulman. Of course, this is an old syntax and text substitution is not recommended anymore. From TW 5.2.x I can use format:titlelist[]
, so I resolved the issue.
This is just to inform you about the way uglifier works with such macro arguments.
Compressing TW-Vote using Uglify returns an error on one of tiddler.
This is the tiddler Uglify complains
/*\
keyvals.js
type: application/javascript
module-type: filteroperator
Filter operator for returning the key_°_values of a data tiddler
Note the _°_ is a separator used here for sorting purpose
\*/
(function(){
"use strict";
/*
Export our filter function
*/
exports.keyvals = function(source,operator,options) {
var results = [];
var sep="_°_";
source(function(tiddler,title) {
var data = options.wiki.getTiddlerDataCached(title);
if(data) {
for (var [key, value] of Object.entries(data)) {
results.push(key+sep+value);
}
}
});
return results;
};
})();
Uglify complains, it cannot compress the keyval.js for line for (var [key, value] of Object.entries(data)) {
as below
Would you please have a look and let me what is the issue?
The same procedure works with Uglify 1.5.1
Using the instruction is given here: https://github.com/flibbles/tw5-uglify#nodejs
when issue tiddlywiki --build test
everything works fine and index.html
is produced with compressed core and plugins, but I see an Empty Uglify plugin is remained in my index.html
.
NOTE: As it is empty, there is no overhead!
I use uglify 1.5.1 for compressing my TW, recently I noticed I get different results in a code uses now
macro. See
<$let note-time=<<now 0hh:0mm>>
note-time2=<<now "0hh:0mm">>
>
* <<note-time>>
* <<note-time2>>
</$let>
This results in:
The original code is <<now "0hh:0mm">>
after uglifying it is <<now 0hh:0mm>>
note to disappeared "
$:/boot/boot.css
to change the password entry dialogue.Confirm
Customize
text/css
$:/boot/boot.css
disappearse from the list of compressed Tidlers.Compress TiddlyWiki file
The uglified.html has a changed $:/boot/boot.css
and the password entry dialogue looks "normal". After a re-import it works, but it is unexpected.
Hi @flibbles
As discussed here https://groups.google.com/g/tiddlywiki/c/kF-OGmkyFfo/m/b272I2rtAwAJ Uglify does not work or work in reverse for Tiddlywiki 5.2
I would appreciate to have a look!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.