jsonurl-js icon indicating copy to clipboard operation
jsonurl-js copied to clipboard

Cannot redefine property: toJsonURLText

Open SaalkT opened this issue 2 years ago • 12 comments

SaalkT avatar Mar 14 '23 13:03 SaalkT

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?

dmaccormack avatar Sep 14 '23 16:09 dmaccormack

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

AlonMiz avatar Dec 23 '23 11:12 AlonMiz

@AlonMiz were you able to find a workaround?

tonyxiao avatar Feb 20 '24 10:02 tonyxiao

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

tonyxiao avatar Feb 20 '24 10:02 tonyxiao

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
}

AlonMiz avatar Feb 23 '24 11:02 AlonMiz

but that doesn't work for javascript right?

tonyxiao avatar Feb 23 '24 17:02 tonyxiao

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');

AlonMiz avatar Feb 24 '24 18:02 AlonMiz

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

Speaking of which what does noproto mean anywyas?

tonyxiao avatar Feb 24 '24 19:02 tonyxiao

https://github.com/jsonurl/jsonurl-js/pull/660

joe223 avatar Mar 06 '24 09:03 joe223

This issue is till not fixed. This happens server side on my Gatsby website. Please fix asap.

ktheys avatar Oct 15 '24 09:10 ktheys

There's a discrepancy between the source: https://github.com/jsonurl/jsonurl-js/blob/v1.1.8/src/JsonURL.js#L1832 And the packaged code: https://www.runpkg.com/?@jsonurl/[email protected]/dist/jsonurl.noproto.js#2281

romulof avatar Nov 12 '24 10:11 romulof