Skip to content

fix: TypeError: SuperJSON is not a constructor#250

Merged
Skn0tt merged 1 commit into
flightcontrolhq:mainfrom
juliusmarminge:fix-export
Jul 17, 2023
Merged

fix: TypeError: SuperJSON is not a constructor#250
Skn0tt merged 1 commit into
flightcontrolhq:mainfrom
juliusmarminge:fix-export

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jul 17, 2023

Copy link
Copy Markdown
Contributor

"Fixes" #247 (comment)

import { SuperJSON } from "superjson"
const superjson = new SuperJSON();

now works. default import still broken though

@juliusmarminge juliusmarminge requested a review from Skn0tt as a code owner July 17, 2023 09:18
@juliusmarminge juliusmarminge changed the title fix: constructor fix: TypeError: SuperJSONis not a constructor Jul 17, 2023
@juliusmarminge juliusmarminge changed the title fix: TypeError: SuperJSONis not a constructor fix: TypeError: SuperJSON is not a constructor Jul 17, 2023
@juliusmarminge

Copy link
Copy Markdown
Contributor Author

Not optimal since it doesn't fix the default import, but works as a workaround 🤷🏼‍♂️

Tested using yalc locally and linking to a separate package outside the superjson repo

@Skn0tt

Skn0tt commented Jul 17, 2023

Copy link
Copy Markdown
Collaborator

That's a good workaround, I guess. The problem with the default export boils down to the fact that apparently, SuperJSON in this context is of type Module, not the class that we expect it to be. So this should also work:

import SuperJSON from "superjson"

new SuperJSON.default()

@Skn0tt

Skn0tt commented Jul 17, 2023

Copy link
Copy Markdown
Collaborator

Let's get this merged 🤷

@juliusmarminge

Copy link
Copy Markdown
Contributor Author

So this should also work:

import SuperJSON from "superjson"

new SuperJSON.default()

While that might work in runtime, you get typeerrors. Somewhere the type is wrong I guess? Bundlers are weird...

CleanShot 2023-07-17 at 11 24 35@2x

@Skn0tt Skn0tt merged commit 631f21c into flightcontrolhq:main Jul 17, 2023
@Skn0tt

Skn0tt commented Jul 17, 2023

Copy link
Copy Markdown
Collaborator

Published as part of https://github.com/blitz-js/superjson/releases/tag/v1.13.1.

@juliusmarminge

Copy link
Copy Markdown
Contributor Author

And this errors with the same error:

import * as SuperJSON from 'superjson'

export const superjson = new SuperJSON.default({
	dedupe: true,
})
CleanShot 2023-07-17 at 11 27 45@2x

@juliusmarminge

Copy link
Copy Markdown
Contributor Author

Published as part of https://github.com/blitz-js/superjson/releases/tag/v1.13.1.

Can confirm it works straight from node_modules (no local linked package) 👍🏼

Chia1104 referenced this pull request in Chia1104/chia1104.dev Jul 21, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [superjson](https://togithub.com/blitz-js/superjson) | [`1.12.4` ->
`1.13.1`](https://renovatebot.com/diffs/npm/superjson/1.12.4/1.13.1) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/superjson/1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/superjson/1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/superjson/1.12.4/1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/superjson/1.12.4/1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>blitz-js/superjson (superjson)</summary>

###
[`v1.13.1`](https://togithub.com/blitz-js/superjson/releases/tag/v1.13.1)

[Compare
Source](https://togithub.com/blitz-js/superjson/compare/v1.13.0...v1.13.1)

#### What's Changed

- Bump json5 from 1.0.1 to 1.0.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/blitz-js/superjson/pull/218](https://togithub.com/blitz-js/superjson/pull/218)
- Bump minimatch from 3.0.4 to 3.1.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/blitz-js/superjson/pull/213](https://togithub.com/blitz-js/superjson/pull/213)
- Bump decode-uri-component from 0.2.0 to 0.2.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/blitz-js/superjson/pull/212](https://togithub.com/blitz-js/superjson/pull/212)
- Bump tough-cookie from 4.1.2 to 4.1.3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/blitz-js/superjson/pull/248](https://togithub.com/blitz-js/superjson/pull/248)
- fix: TypeError: SuperJSON is not a constructor by
[@&#8203;juliusmarminge](https://togithub.com/juliusmarminge) in
[https://github.com/blitz-js/superjson/pull/250](https://togithub.com/blitz-js/superjson/pull/250)

#### New Contributors

- [@&#8203;juliusmarminge](https://togithub.com/juliusmarminge) made
their first contribution in
[https://github.com/blitz-js/superjson/pull/250](https://togithub.com/blitz-js/superjson/pull/250)

**Full Changelog**:
flightcontrolhq/superjson@v1.13.0...v1.13.1

###
[`v1.13.0`](https://togithub.com/blitz-js/superjson/releases/tag/v1.13.0)

[Compare
Source](https://togithub.com/blitz-js/superjson/compare/v1.12.4...v1.13.0)

#### What's Changed

- fix: referential equalities should ignore child nodes by
[@&#8203;KATT](https://togithub.com/KATT) in
[https://github.com/blitz-js/superjson/pull/244](https://togithub.com/blitz-js/superjson/pull/244)
- feat: add `dedupe` flag by [@&#8203;KATT](https://togithub.com/KATT)
in
[https://github.com/blitz-js/superjson/pull/247](https://togithub.com/blitz-js/superjson/pull/247)

**Full Changelog**:
flightcontrolhq/superjson@v1.12.4...v1.13.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/Chia1104/chia1104.dev).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi44LjExIiwidXBkYXRlZEluVmVyIjoiMzYuOC4xMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
Chia1104 referenced this pull request in ChiaStack/chiastack.dev Jul 25, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [superjson](https://togithub.com/blitz-js/superjson) | [`1.12.4` ->
`1.13.1`](https://renovatebot.com/diffs/npm/superjson/1.12.4/1.13.1) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/superjson/1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/superjson/1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/superjson/1.12.4/1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/superjson/1.12.4/1.13.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>blitz-js/superjson (superjson)</summary>

###
[`v1.13.1`](https://togithub.com/blitz-js/superjson/releases/tag/v1.13.1)

[Compare
Source](https://togithub.com/blitz-js/superjson/compare/v1.13.0...v1.13.1)

#### What's Changed

- Bump json5 from 1.0.1 to 1.0.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/blitz-js/superjson/pull/218](https://togithub.com/blitz-js/superjson/pull/218)
- Bump minimatch from 3.0.4 to 3.1.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/blitz-js/superjson/pull/213](https://togithub.com/blitz-js/superjson/pull/213)
- Bump decode-uri-component from 0.2.0 to 0.2.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/blitz-js/superjson/pull/212](https://togithub.com/blitz-js/superjson/pull/212)
- Bump tough-cookie from 4.1.2 to 4.1.3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/blitz-js/superjson/pull/248](https://togithub.com/blitz-js/superjson/pull/248)
- fix: TypeError: SuperJSON is not a constructor by
[@&#8203;juliusmarminge](https://togithub.com/juliusmarminge) in
[https://github.com/blitz-js/superjson/pull/250](https://togithub.com/blitz-js/superjson/pull/250)

#### New Contributors

- [@&#8203;juliusmarminge](https://togithub.com/juliusmarminge) made
their first contribution in
[https://github.com/blitz-js/superjson/pull/250](https://togithub.com/blitz-js/superjson/pull/250)

**Full Changelog**:
flightcontrolhq/superjson@v1.13.0...v1.13.1

###
[`v1.13.0`](https://togithub.com/blitz-js/superjson/releases/tag/v1.13.0)

[Compare
Source](https://togithub.com/blitz-js/superjson/compare/v1.12.4...v1.13.0)

#### What's Changed

- fix: referential equalities should ignore child nodes by
[@&#8203;KATT](https://togithub.com/KATT) in
[https://github.com/blitz-js/superjson/pull/244](https://togithub.com/blitz-js/superjson/pull/244)
- feat: add `dedupe` flag by [@&#8203;KATT](https://togithub.com/KATT)
in
[https://github.com/blitz-js/superjson/pull/247](https://togithub.com/blitz-js/superjson/pull/247)

**Full Changelog**:
flightcontrolhq/superjson@v1.12.4...v1.13.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/Chia1104/chia-stack).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMTEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants