ui: replace pretty-data library
SuperITMan opened this issue · comments
Alexis Georges commented
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/NationalBankBelgium/stark/blob/master/CONTRIBUTING.md#got-a-question-or-problem
Current behavior
After upgrading Stark to Angular 8, we get the following error when running the showcase:
Uncaught ReferenceError: assignment to undeclared variable maxdeep
pp pretty-data.js:54
js pretty-data.js:334
Webpack 14
pretty-data.js:54:2
pp pretty-data.js:54
js pretty-data.js:334
Webpack 16
An issue about this has been opened on vkiryukhin/pretty-data#26 and didn't receive any answer for a year. Since this library does not seem to be maintained anymore, we should investigate to replace it by another library.
Minimal reproduction of the problem with instructions
- Checkout master branch
- Edit "packages/stark-ui/src/modules/pretty-print/components/pretty-print.component.ts" file as following:
// Line 53 uncomment following line:
const prettyData: any = require("pretty-data").pd;
// +- Line 160 adapt as follows:
this.prettyString = prettyData.xml(this.data);
// this.prettyString = this.data;
// +- Line 188 adapt as follows:
this.prettyString = prettyData.sql(this.data);
// this.prettyString = this.data;
- Run
npm run build
&& npm run update:showcase && npm run showcase
What is the motivation / use case for changing the behavior?
Fix support for all extensions in pretty-print component.
To do so, we could use different formatters to replace ones supported by pretty-data in stark-ui:
- SQL: sql-formatter
- XML: @prettier/plugin-xml
- HTML: already present prettier/parser-angular
Environment
Angular version: 8x