jsonurl/jsonurl-js

Cannot redefine property: toJsonURLText

Opened this issue · 9 comments

Cannot redefine property: toJsonURLText

Hi, @SaalkT. You're correct that the toJsonURL property can not be redefined, but it can be defined on a per-instance basis during object creation. See this test for an example: https://github.com/jsonurl/jsonurl-js/blob/main/test/stringify.test.js#L181

Would that be sufficient for your use case?

happens on next js, while rendering on the server side.
maybe there's some kind of protection from reinitialization can be implemented

@AlonMiz were you able to find a workaround?

@dmaccormack this is more of a bug rather than enhancement.

tonyxiao yes i've added an alias to my tsconfig

{
  "compilerOptions": {
    "paths": {
      // Creates 500s on our app when initializing
      // https://github.com/jsonurl/jsonurl-js/issues/614
      "@jsonurl/jsonurl": ["./node_modules/@jsonurl/jsonurl/dist/jsonurl.noproto"]
    },
    // ... more config
}

but that doesn't work for javascript right?

but that doesn't work for javascript right?

@tonyxiao
try this

import JsonURL from '@jsonurl/dist/jsonurl.noproto';

or with require

const JsonURL =  require('@jsonurl/dist/jsonurl.noproto');

Hmm that doesn't work in typescript anymore because there's no typedefinition for jsonurl.noproto

Speaking of which what does noproto mean anywyas?