Starcounter-Jack / JSON-Patch

Lean and mean Javascript implementation of the JSON-Patch standard (RFC 6902). Update JSON documents using delta patches.
MIT License
1.79k stars 215 forks source link

importing fast-json-patch fails in typescript / angular 6 #237

Open jeffreyabecker opened 5 years ago

jeffreyabecker commented 5 years ago

I'm getting an error when trying to import v 3.0.0: ERROR in ./node_modules/fast-json-patch/index.mjs Module parse failed: Unexpected token (25:4) You may need an appropriate loader to handle this file type.

as far as I can tell this is related to how typescript deals with .mjs files. However the package itself doesnt appear to have the source typescript files to use directly.

warpech commented 5 years ago

I just checked with a plain TS project and it seems to work as expected with fast-json-patch 3.0.0-1.

I think that TypeScript works well with MJS as long as you have a current version of TSC. Any idea what's different in your setup?

Source: https://github.com/warpech/fast-json-patch-typescript-demo

(it's actually pretty similar to https://github.com/Starcounter-Jack/JSON-Patch/blob/18a14f0b7d4e567ef605d21dd681718968d642e5/test/spec/typings/typingsSpec.ts)

image

jeffreyabecker commented 5 years ago

The biggest difference I notice from that repo is that my ts code contains a line import * as jsonpatch from "fast-json-patch" Is it possible that you've not pushed something?

warpech commented 5 years ago

Sorry, I forgot to push my final version of the files to https://github.com/warpech/fast-json-patch-typescript-demo

Now I have pushed it and the wildcard import works OK: https://github.com/warpech/fast-json-patch-typescript-demo/blob/b2a668291ba0701ec3bfaed97823f815c125bd45/index.ts#L2

rcollette commented 1 year ago

I have to believe this issue can be closed at this point?