Repository navigation
Feature/esm jest - #35
Conversation
This is now supported by node (out of the box)
| @@ -0,0 +1,5 @@ | |||
| { | |||
| "presets": [ | |||
| "@babel/preset-env" | |||
There was a problem hiding this comment.
This is currently required for jest but I expect soon we can drop babel for tests.
| (function testBasic() { | ||
| var trace = get(); | ||
|
|
||
| //expect(trace[0].getFunction()).toBe(testBasic); |
There was a problem hiding this comment.
@felixge I'm not sure why but getFunction always returns undefined/null here
| (function testWrapper() { | ||
| (function testBelowFn() { | ||
| var trace = get(testBelowFn); | ||
| //expect(trace[0].getFunction()).toBe(testWrapper); |
There was a problem hiding this comment.
@felixge I'm not sure why but getFunction always returns undefined/null here
| 2: 'Object.asyncJestTest', | ||
| 4: 'new Promise' |
There was a problem hiding this comment.
This feels weird, but we are parsing what is passed to us. It probably could be better
| compare('getTypeName', { | ||
| 7: null | ||
| }); | ||
| compare('getMethodName', { | ||
| 2: 'asyncJestTest' | ||
| }); | ||
| compare('getLineNumber', { | ||
| 0: 88, | ||
| 1: 92 | ||
| }); | ||
| compare('getColumnNumber', { | ||
| 0: 13 | ||
| }); | ||
| compare('isNative'); |
There was a problem hiding this comment.
These overrides seem brittle depending on node version?
| return lines | ||
| .map(function(line) { | ||
| if (line.match(/^\s*[-]{4,}$/)) { | ||
| return self._createParsedCallSite({ |
There was a problem hiding this comment.
This is the whole reason I migrated to esm. When this script is used in esm (you can import cjs) this self reference was globalThis and caused runtime issues.
| @@ -0,0 +1,51 @@ | |||
| import { get } from "../index.js"; | |||
There was a problem hiding this comment.
I moved and renamed these tests, not sure why it thinks it was a delete and new instead of a git mv
|
@felixge I'd like your thoughts before merging this unless you are fine with these changes since they are breaking (dropping cjs). I'm currently blocked on my esm project. |
|
@niemyjski this LGTM. I don't have time for an in-depth review. My only thought is that perhaps it's time to give this a major (v1) version number to make it clear it's a breaking changing and then keep doing the semver thing going forward. |
|
Sounds good! I will push this as |
Upgraded tests to jest and dropped cjs for esm. Everyone is converting their libraries to esm which supports importing cjs but not the other way around. I was running into issues importing and consuming parse from esm due to a
selfreference.