From b0bd8d5cf09ea6fb210543cd9c228a057d51f00b Mon Sep 17 00:00:00 2001 From: Kristof Vandenbroucke Date: Mon, 5 Feb 2024 17:27:41 +0100 Subject: [PATCH] Add some context to the dirty fix of the wrapper --- packages/oslo-extractor-uml-ea/lib/DataRegistry.ts | 2 +- .../oslo-extractor-uml-ea/lib/MdbReaderWrapper.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 packages/oslo-extractor-uml-ea/lib/MdbReaderWrapper.ts diff --git a/packages/oslo-extractor-uml-ea/lib/DataRegistry.ts b/packages/oslo-extractor-uml-ea/lib/DataRegistry.ts index 032ef2e..5291227 100644 --- a/packages/oslo-extractor-uml-ea/lib/DataRegistry.ts +++ b/packages/oslo-extractor-uml-ea/lib/DataRegistry.ts @@ -1,6 +1,6 @@ import type { Logger } from '@oslo-flanders/core'; import { fetchFileOrUrl } from '@oslo-flanders/core'; -import MDBReader from 'mdb-reader'; +import MDBReader from './MdbReaderWrapper'; import type { EaAttribute } from '@oslo-extractor-uml-ea/types/EaAttribute'; import type { EaConnector } from '@oslo-extractor-uml-ea/types/EaConnector'; import type { EaDiagram } from '@oslo-extractor-uml-ea/types/EaDiagram'; diff --git a/packages/oslo-extractor-uml-ea/lib/MdbReaderWrapper.ts b/packages/oslo-extractor-uml-ea/lib/MdbReaderWrapper.ts new file mode 100644 index 0000000..aea2032 --- /dev/null +++ b/packages/oslo-extractor-uml-ea/lib/MdbReaderWrapper.ts @@ -0,0 +1,14 @@ +import * as MDBReaderOriginal from 'mdb-reader'; + +// This is a very dirty fix to a problem with one of the external libraries we use being mdb-reader. +// As of version 2.x the library is written in ESM and does not +// support CommonJS: https://github.com/andipaetzold/mdb-reader/releases/tag/v2.0.0-next.7 +// This means that we cannot use it in our project as it is and we either need to fork it +// and fix it ourselves or use a dirty workaround +// The workaround is to use the default import of the library and then access the default property +// of the default import, which will throw some errors in the editor, but will work as expected. + + +const MDBReader = MDBReaderOriginal.default.default; + +export default MDBReader; \ No newline at end of file