thoughtbot / superglue

A productive library for Classic Rails, React and Redux
https://thoughtbot.github.io/superglue/
MIT License
327 stars 8 forks source link

feat: initialize typescript #60

Closed johncardiologs closed 2 weeks ago

johncardiologs commented 1 month ago

A first jab at introducing ts/tsx to this repo! cc @jhash

johncardiologs commented 3 weeks ago

Hi! Sorry, my mind's been completely elsewhere lately and I left this.

Agreed with the approach of keeping babel -- I made the changes you suggested. I'll look into the failing tests & trying to get this to compile properly when I next have a chance!

jho406 commented 3 weeks ago

A rebase onto main would fix those errors.

johncardiologs commented 3 weeks ago

To compare the build outputs, I ran the builds and diffd the files. Primarily, I saw one added line in the typescript babel build outputs that was appended to the end of every file:

//# sourceMappingURL=data:application/json;charset=utf-8;base64

followed by a string of characters. It seems this corresponds to babel's source map option.

The only other 'true diff' I saw apart from this was the following, where dist/ contains files built via this PR and maindist/ holds files built using the npm run build:index command from branch main:

❯ diff dist/index.js maindist/index.js
4c4
< exports.superglueReducer = exports.pageReducer = exports.mapDispatchToPropsIncludingVisitAndRemote = exports.getIn = exports.fragmentMiddleware = exports.UPDATE_FRAGMENTS = exports.SAVE_RESPONSE = exports.REMOVE_PAGE = exports.GRAFTING_SUCCESS = exports.GRAFTING_ERROR = exports.COPY_PAGE = exports.BEFORE_VISIT = exports.BEFORE_REMOTE = exports.BEFORE_FETCH = exports.ApplicationBase = void 0;
---
> exports.updateFragments = exports.superglueReducer = exports.pageReducer = exports.mapDispatchToPropsIncludingVisitAndRemote = exports.getIn = exports.fragmentMiddleware = exports.UPDATE_FRAGMENTS = exports.SAVE_RESPONSE = exports.REMOVE_PAGE = exports.GRAFTING_SUCCESS = exports.GRAFTING_ERROR = exports.COPY_PAGE = exports.BEFORE_VISIT = exports.BEFORE_REMOTE = exports.BEFORE_FETCH = exports.ApplicationBase = void 0;
10a11
> exports.updateFragments = _reducers.updateFragments;

I'm not entirely sure what could be causing this difference, but it doesn't seem super harmful to me -- though I'm not entirely familiar yet with superglue!

Let me know if there's anything else to fix up, otherwise I think this may be a decent starting point!