appvision-gmbh / json2typescript

Map JSON to a TypeScript class with secure type checking!
https://www.npmjs.com/package/json2typescript
MIT License
278 stars 55 forks source link

Fix to resolve CommonJS issue with angular 10 #148

Closed rayita closed 4 years ago

rayita commented 4 years ago

Fix to resolve Angular 10 warning;

WARNING in \src\webapp\src\app\services\app-globals.service.ts depends on json2typescript. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

I made modifications needed to pack simultaneously both versions, the new one using esm module format (compatible angular 10) and the old commonjs module format fo those who need compatibility with old js versions.

I also update TS to last version.

andreas-aeschlimann commented 4 years ago

Nice work @rayita. Your implementation works fine, but before I am going to publish the new version, we should somehow fix the path issue:

When json2typescript is imported in my IDE (WebStorm), it suggests two paths:

I would like developers to continue just importing the main directory json2typescript in case that we make changes again. While it still works, it is bad that the IDE tries to push the user to import the direct path to the esm or cjs directory. Do you know if we can prevent this?