PLEASE provide proper support for CommonJS. Normal npm packages always provide both .mjs and .cjs files, and configure "exports" to switch on the import type in their package.json, e.g.:
{
// ...
"exports": {
"import": "main.mjs",
"require": "main.cjs"
},
// ...
}
Our esmodule-based code is transpiled to common-js to support other CommonJS-only libraries and work around several other issues.
Because of the lack of proper CommonJS for this package, we're forced to use an extremely ugly and hard-to-use import routine:
// @laserfiche modules are esmodule-only. Because `import` statements are transpiled to `require`,
// which cannot load esmodules, this import MUST be explicitly written as a dynamic import call, which
// is allowed in commonjs modules, but still works for esmodules. Otherwise, deployment WILL FAIL.
// WARNING: When using anything within LaserficheModule, the code MUST await LaserficheModuleLoading beforehand.
let LaserficheModule!: typeof import("@laserfiche/lf-repository-api-client");
let LaserficheModuleLoading!: Promise<void>;
// MUST use eval to prevent transpiler from converting it to require
eval(`
LaserficheModuleLoading = import(
"@laserfiche/lf-repository-api-client"
).then((mod) => {
LaserficheModule = mod;
});
`);
It is yet to be determined if even this works. If it doesn't, we'll literally be forced to disregard this library and rewrite it on our own.
PLEASE provide proper support for CommonJS. Normal npm packages always provide both .mjs and .cjs files, and configure "exports" to switch on the import type in their package.json, e.g.:
Our esmodule-based code is transpiled to common-js to support other CommonJS-only libraries and work around several other issues.
Because of the lack of proper CommonJS for this package, we're forced to use an extremely ugly and hard-to-use import routine:
It is yet to be determined if even this works. If it doesn't, we'll literally be forced to disregard this library and rewrite it on our own.