tiddlyhost / tiddlyhost-com

Rails application for creating and hosting TiddlyWiki sites, plus resources for deploying it to https://tiddlyhost.com/
Other
184 stars 17 forks source link

tiddlywikicore-5.3.2.js contains wrong tiddlers #324

Closed buggyj closed 9 months ago

buggyj commented 9 months ago

I create a new external core wiki on tiddlyhost and dragged $:/core/ui/SideBar/Open from tiddlywiki.com on to https://testincludecore.tiddlyhost.com/ - imported it then compared - they are different -

simonbaird commented 9 months ago

My first thought is that might related to the use of the uglify plugin on the external core js file used by Tiddlyhost, but there are some substantial looking changes in that diff, so I'm not sure.

Will take a closer look soon.

@flibbles @pmario any suggestions?

simonbaird commented 9 months ago

I'm building the external core edition like this:

git checkout v5.3.2                                                                                             

node tiddlywiki.js editions/empty \                                          
    --output ./output/external-core \                             
    --rendertiddler '$:/core/save/offline-external-js' 'empty.html' 'text/plain'

node tiddlywiki.js  editions/empty \                                         
    --output ./output/external-core \                                                                                                            
    --render '$:/core/templates/tiddlywiki5.js' '[[tiddlywikicore-]addsuffix<version>addsuffix[.min.js]]' 'text/plain'

Or with uglify on the js file:

  export TIDDLYWIKI_PLUGIN_PATH=../tw5-uglify                                             
  node tiddlywiki.js +plugins/plugins/uglify editions/empty \                                  
    --output ./output/external-core \                                             
    --render '$:/core/templates/tiddlywiki5.js' '[[tiddlywikicore-]addsuffix<version>addsuffix[.min.js]]' 'text/plain'
simonbaird commented 9 months ago

Re the uglify theory, I got the same result with or without the uglify plugin, so I don't think that is the cause.

Perhaps the \whitespace trim causes some whitespace to be stripped out when the render happens...?

pmario commented 9 months ago

IMO they are not wrong. They are uglified. It looks OK to me.

flibbles commented 9 months ago

Bear in mind that there is a slight known issue using Uglify with 5.3.2. It should be resolved after the TiddlyWiki core PR https://github.com/Jermolene/TiddlyWiki5/pull/7895 is merged.

flibbles commented 9 months ago

To elaborate here, there were changes to the way whitespace after pragma is handled by the wikiparser. It's now preserved except in cases when \whitespace trim is present. So when Uglify removes whitespace trim and manually removes the whitespace instead, there's now a newline introduced preceding the body. This is causing some very subtle problems, and looking at the diff above, that tiddler would get that introduced newline.

buggyj commented 9 months ago

when I do the build I do not see this error:

git clone https://github.com/Jermolene/TiddlyWiki5 . git checkout v5.3.2
node tiddlywiki.js editions/empty --output ./output/external-core --rendertiddler '$:/core/save/offline-external-js' 'empty.html' 'text/plain' node tiddlywiki.js editions/empty --output ./output/external-core --render '$:/core/templates/tiddlywiki5.js' '[[tiddlywikicore-]addsuffixaddsuffix[.min.js]]' 'text/plain'

I had to rename 'tiddlywikicore-5.3.2.min.js' to 'tiddlywikicore-5.3.2.js'

pmario commented 9 months ago

Just to be sure you've seen this one: https://github.com/Jermolene/TiddlyWiki5/issues/7904

simonbaird commented 9 months ago

I got the same result with or without the uglify plugin

I think I was mistaken. Now it looks like the problem goes away if the uglify plugin is not used, as @buggyj found.

flibbles commented 9 months ago

The problem will go away with v5.3.3, but I'll also be pushing a new Uglify version soon which will make an exception for v5.3.2 anyway.

simonbaird commented 9 months ago

In case anyone is wondering what the plan is: I'm going to assume this is not causing any major problems on Tiddlyhost currently, and just wait for the upcoming fixes to land.

If you are seeing any problem with the external core TW 5.3.2 on Tiddlyhost let me know - I could build and push a non-uglified core js if needed.

flibbles commented 9 months ago

I've released Uglify v1.8.0 which has full support for Tiddlywiki 5.3.2, including support for the anomalous behavior that Tiddlywiki introduced.

I recommend migrating to Tiddlywiki 5.3.3 as soon as it releases because the workaround for the core bug means Uglify has to forgo some compression it'd ordinarily want to do.

simonbaird commented 9 months ago

Thanks - Pushing a release to Tiddlyhost now.

simonbaird commented 9 months ago

Ps, it is perhaps surprising for Tiddlyhost users to notice that tiddler content is different when using an external core TiddlyWiki on Tiddlyhost (due to the uglify). Is there an option for uglify so it compresses the javascript but leaves the content of the shadow tiddlers uncompressed?

buggyj commented 9 months ago

seems to be fixed in v5.3.3

flibbles commented 9 months ago

Is there an option for uglify so it compresses the javascript but leaves the content of the shadow tiddlers uncompressed?

Yes. The documentation on how to do that through a NodeJS compile is here. It's the last one described.

If you're using the wizard (which I don't think you are), it's just a matter of unchecking the text/vnd.tiddlywiki box.

flibbles commented 9 months ago

But actually, now that I think about it, you probably just want to use the "--uglify", "text/vnd.tiddlywiki", "no" build options.