Open cre8 opened 2 years ago
Could you share how you're downloading & using mustache.js? Any building involved or downloading directly from a CDN?
E.g. I would not expect the same to happen if you used the simplest alternative from the README:
I used it via npm without any more configuration like in the angular.json file.
A dif between the two versions should give more insights, will do it the next days and report the findings.
I have the same problem with a Angular 12 nx monorepo.
I've installed via npm install mustache@latest --save-exact
and npm install @types/mustache@latest --save-exact
.
I'am upgrading from Version 3.1.0
to 4.2.0
and now i'am getting lots of
Error: export 'render' (imported as 'render') was not found in 'mustache' (possible exports: default)
Our imports looks like:
import * as mustache from 'mustache';
A downgrade to 4.1.0
works fine. So i have to stay there for now.
Push: Error is still relevant. Can't upgrade mustache to Version 4.2.0 in the Angular 14 and NX Upgrade process.
Probably same root cause as #786 ?
Push: Error is still relevant.
Import it like import mustache from 'mustache'
. And use as mustache.render
Import it like
import mustache from 'mustache'
. And use asmustache.render
import mustache from 'mustache';
leads to TS1192: Module '".../node_modules/@types/mustache/index"' has no default export.
And enabling esModuleInterop
with over 200 libraries in our monorepo is no option. That leads to other problems. So actually it's impossible to update.
Apply following patch
diff --git a/node_modules/@types/mustache/index.d.ts b/node_modules/@types/mustache/index.d.ts
index 709da20..34d5407 100644
--- a/node_modules/@types/mustache/index.d.ts
+++ b/node_modules/@types/mustache/index.d.ts
@@ -419,4 +419,5 @@ export interface TemplateCache {
clear(): void;
}
-export as namespace Mustache;
+declare const mustache:{render:typeof render, escape:typeof escape, clearCache:typeof clearCache, parse:typeof parse};
+export default mustache;
Import as
import whatever from 'mustache';
// use like
whatever.render()
Push, still relevant... unable to update. Dependabot PR is still blocked.
Downgrade to 4.1.0 works for now :-1:
Still broken, staying at 4.1.0
I make a new TypeScript rewrite fork for it. However, it still lacks test cases and is incompatible with some APIs. If anyone is interested in it, please feel free to contribute it.
Try this,
I was facing the same same issue today, resolved using these steps.
I got the error when using it in a library in my angular application.
Error appeared in version
4.2.0
, but not after downgrading to4.1.0
OS: Linux