CodeYellowBV / tarantino

a tiny and isomorphic URL router for JavaScript.
MIT License
11 stars 3 forks source link

Migration guide #4

Open mhulse opened 7 years ago

mhulse commented 7 years ago

Coming from Director, I was not able to make a quick switch to tarantino.

Setting aside the discussions of the future/direction of this repo, I think it would be of help Director users to have a director -> tarantino migration guide.

I have only been using the browser implementation, so I would be of no help for writing a TL;DR for the server-side/node bits … Though, I would not mind making notes for the browser part.

Thoughts?

SpaceK33z commented 7 years ago

I'm only using the browser part too. I didn't change anything to the other implementations. There were only a few changes to the browser part, but it shouldn't break too much stuff. The biggest change was that I switched the module bundler from CodeSurgeon (which is deprecated), to Rollup. Also I enabled html5history API by default.

mhulse commented 7 years ago

Ah, the html5history API may have been breaking my non-html5history setup when doing the switch. I'll try again and make notes; I will update this issue once I have something. At a bare minimum, maybe having this issue will suffice in terms of a guide. 👍

Thanks!

mhulse commented 7 years ago

Ah, the html5history API may have been breaking my non-html5history setup when doing the switch.

I think the real reason why html5 history did not work is because my app was not deployed at the root of my local dev. I could be wrong, but it seems like html5 option requires a site deployed at the root of the url.

http://stackoverflow.com/questions/10045540/history-pushstatedata-title-url-concatenates-instead-of-replacing-url-to-add

Still learning about html5 pushstate and replacestate, so bare with me.

SpaceK33z commented 7 years ago

It doesn't really require the app to be at your root, but if it's not at the root you need some additional config. In that case, you should append the path to the route url:

{
  '/mypath/dog': function() {},
  '/mypath/cat': function() {},
}

You're probably thinking now, that's fucked up, and it is. However, you could "automate" this by setting this path in a variable and use that each time. Or, but I haven't tested this, you could do something like this:

{
  '/mypath': {
     '/dog': function() {},
     '/cat': function() {},
  }
}
mhulse commented 7 years ago

t doesn't really require the app to be at your root, but if it's not at the root you need some additional config.

Ahh, I see! Thanks for the tips!

I will be officially making the switch today and will update this issue if I run into any issues. :octocat:

mhulse commented 7 years ago

One thing I noticed was that I needed to call the router like so:

tarantino.Router(......)

The docs just specify "Router".

I can do a PR to correct this, unless I am overlooking something. 👍

SpaceK33z commented 7 years ago

@mhulse ah yes that seems to be wrong in the first example. Btw, we could update the Node.js examples to be const { Router } = require('tarantino');, that's a bit more fancy.

mhulse commented 7 years ago

ah yes that seems to be wrong in the first example. Btw, we could update the Node.js examples to be const { Router } = require('tarantino');, that's a bit more fancy.

Awesome, I'll update the docs. 👍