Incorrect source map for function identifier change
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 363
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 3
Description
Hi everyone,
I'm attempting to transform this:
``` javascript
f(2)
```
to this:
``` javascript
Runtime.call({
name: 'f',
func: f,
args: [2],
thisArg: this
}).then(() => {});
```
The generated source map is not mapping the call expression correctly. It seems to want to treat the callback function to `then(callback)` as the original `f(2)` call. Here are visuals of the expected and unexpected behaviors:
1. [expected](http://sokra.github.io/source-map-visualization/#base64,UnVudGltZS5jYWxsKHsKICBuYW1lOiAiZiIsCiAgZnVuYzogZiwKICBhcmdzOiBbMl0sCiAgdGhpc0FyZzogdGhpcwp9KTsK,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImVtOi8vYXBwL2FwcC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiWUFBQzs7O1NBQUM7O0NBQUMsQ0FBQyIsImZpbGUiOiJhcHAuanMiLCJzb3VyY2VzQ29udGVudCI6WyJmKDIpO1xuIl19,ZigyKTsK) - no `then(...)` call.
2. [unexpected](http://sokra.github.io/source-map-visualization/#base64,UnVudGltZS5jYWxsKHsKICBuYW1lOiAiZiIsCiAgZnVuYzogZiwKICBhcmdzOiBbMl0sCiAgdGhpc0FyZzogdGhpcwp9KS50aGVuKCgpID0+IHt9KTsK,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImVtOi8vYXBwL2FwcC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7U0FBRTs7T0FBRCxTQUFFLENBQUMiLCJmaWxlIjoiYXBwLmpzIiwic291cmNlc0NvbnRlbnQiOlsiZigyKTtcbiJdfQ==,ZigyKTsK) - with a `then(...)` call. Notice when you mouse over the first `(` in the source, the callback function of the `then` call is highlighted.
I'm still attempting to learn how the printing with source maps work. But it would be super helpful if someone knows if I'm supposed to be manually mapping new node locations somehow. I can include the source code for building the nodes if it would be helpful.
PS - I'm really amazed with this project @benjamn; it's making life much simpler. Thanks for making it!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the JavaScript transformation in the issue and compare the expected and unexpected source-map visualizations. Read the source-map printing and node-building code mentioned in the report; done means the generated map associates the transformed call with the original f(2), rather than highlighting the then callback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100