ngx-kjua
ngx-kjua copied to clipboard
bug: ERROR ReferenceError: require is not defined
Description
After the update to 1.14.0
the NgxKjuaComponent
throws the following error when it is been initialized / first called in our application (see Stacktrace for more details):
ERROR ReferenceError: require is not defined
The compilation on the other hand runs without any errors.
Moreover version 1.13.2
works fine in the exact same setting.
Do I need a special configuration (e.g special compiler options) to make version 1.14.0
work?
Stacktrace
main.js ERROR ReferenceError: require is not defined
at new NgxKjuaComponent
at NodeInjectorFactory.NgxKjuaComponent_Factory [as factory]
at getNodeInjectable
at instantiateAllDirectives
at createDirectivesInstances
at ɵɵelementStart
at Module.ɵɵelement
at MyComponent_Template
at executeTemplate
at renderView
The references in the stacktrace point to the following code in the transpiled main.js
which is part of the class cunstructor of NgxKjuaComponent
:
if ((0,_angular_common__WEBPACK_IMPORTED_MODULE_1__.isPlatformServer)(this.platformId)) {
return;
} else if (!kjua) {
kjua = require("kjua-svg");
}
Used versions
"dependencies": {
...
"@angular/common": "13.2.2",
"@angular/compiler": "13.2.2",
"@angular/core": "13.2.2",
...
"kjua-svg": "1.13.1", (as defined in the peerDependencies)
"ngx-kjua": "1.14.0",
...
},
"devDependencies": {
...
"@angular-devkit/build-angular": "13.2.3",
"@angular/cli": "13.2.3",
"@angular/compiler-cli": "13.2.2",
"@types/node": "17.0.18",
"typescript": "4.4.4",
...
}
I guess I broke SSR now but please try 1.14.1
Thanks for the quick response. The original ReferenceError
does not exist anymore in version 1.14.1
.
Unfortunately now I get a TypeError
with the following stacktrace:
ERROR TypeError: (kjua_svg__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (intermediate value)(intermediate value)) is not a function
at NgxKjuaComponent.get template [as template]
at NgxKjuaComponent.renderCode
at NgxKjuaComponent.updateView
at NgxKjuaComponent.ngAfterViewInit
at callHook
at callHooks
at executeInitAndCheckHooks
at refreshView
at refreshComponent
at refreshChildComponents
The return value of getTemplate()
within the NgxKjuaComponent
seems to still cause an issue.
dang it... I guess the fix has to be implemented in "kjua-svg"..
Is another issue required for kjua-svg
(i.e. in https://github.com/werthdavid/kjua)?
I guess. I'm the maintainer of that as well so in the end it doesn't make a difference.. I don't have time until next week though, PRs are highly appreciated if you have any idea how to fix this
No problem at all since version 1.13.2
works fine for me. So the fix is not that urgent to me :-).
Unfortunately I have no idea what could be the cause of the error. I'll take a look at it, but I'm not the most experienced in the JS libraries area.
@werthdavid I had the same error and saw that you weren't exporting the project as Angular recommends it. I decided to refactor it a little bit.
I've updated the version to be v2.0.0 since it's kind of a big changes in your code.
Hope this will help
https://github.com/werthdavid/ngx-kjua/pull/51
@werthdavid could you release a new version, now that the cod should be fixed?
I'm on it. Currently testing it in one of my projects. I'll remove some unnecessary stuff and then make a release by the end of the day
The end of the day came sooner than expected 😅 2.0.0 is out, let me know if you experience any problems
@werthdavid I confirm that this does solve the issue, you may close this issue
Unfortuately I still get the same TypeError with version 2.0.0
. Do I need to do more just updating ngx-kjua
?
Unfortuately I still get the same TypeError with version
2.0.0
. Do I need to do more just updatingngx-kjua
?
Indeed, I don't know what I did test, sorry for my mistake.
Then I do not understand the error...
Hello, I'm also having the same TypeError
ERROR TypeError: (kjua_svg__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (intermediate value)(intermediate value)) is not a function at NgxKjuaComponent.get template [as template] at NgxKjuaComponent.renderCode at NgxKjuaComponent.updateView at NgxKjuaComponent.ngAfterViewInit at callHook at callHooks at executeInitAndCheckHooks at refreshView at refreshComponent at refreshChildComponents
and I'm using angular 13.2.2, "kjua-svg": "^1.13.1" and "ngx-kjua": "^2.0.0"
hi ,Is it possible for me to run a compatible older version, ?
hi ,Is it possible for me to run a compatible older version, ?
You can run 1.13.2
Is this still the case with 2.0.1?
This one is still appearing @werthdavid. I had to downgrade to 1.13.2
core.mjs:6485 ERROR TypeError: (kjua_svg__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (intermediate value)(intermediate value)) is not a function
at NgxKjuaComponent.get template [as template] (ngx-kjua.mjs:114:20)
at NgxKjuaComponent.renderCode (ngx-kjua.mjs:118:27)
at NgxKjuaComponent.updateView (ngx-kjua.mjs:143:22)
at NgxKjuaComponent.ngAfterViewInit (ngx-kjua.mjs:82:14)
at callHook (core.mjs:2542:1)
at callHooks (core.mjs:2511:1)
at executeInitAndCheckHooks (core.mjs:2462:1)
at refreshView (core.mjs:9555:1)
at refreshComponent (core.mjs:10655:1)
at refreshChildComponents (core.mjs:9280:1)
With 2.0.1
Uncaught TypeError: qn is not a function
at n.get template [as template] (1639.7cb16e9dc89963d1.js:formatted:2136:28)
at n.renderCode (1639.7cb16e9dc89963d1.js:formatted:2163:36)
at n.updateView (1639.7cb16e9dc89963d1.js:formatted:2179:96)
at ngOnChanges (1639.7cb16e9dc89963d1.js:formatted:2133:50)
at n.er (main.a26327982be8bec6.js:1:2211432)
at ll (main.a26327982be8bec6.js:1:2216084)
at al (main.a26327982be8bec6.js:1:2215880)
at ca (main.a26327982be8bec6.js:1:2215550)
at Of (main.a26327982be8bec6.js:1:2240666)
at Object.Mf (main.a26327982be8bec6.js:1:2240560)
I also get the same error as @Sergiobop with version 2.0.1
.
I can reproduce it... on it!
I did play around with tsconfig but after a little research it seems to be a problem with ng-packagr... https://github.com/ng-packagr/ng-packagr/issues/2215 I will for now unpublish >=2.0.0 as 1.x works and create a new version when ng-packagr fixed the issue
just had exactly the same error: core.mjs:6485 ERROR TypeError: (kjua_svg__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (intermediate value)(intermediate value)) is not a function
despite my package.json showed me 1.13.2 as ngx-kju (kju-svg: 1.13.1) - moved to a new workstation so maybe somehow it upgraded it upon installing all packages newly (and still showing old version). Upgraded it to 1.14.x to check but same error, downgraded back to 1.13.2 fixed it, all problems gone.
BTW: the upper error is only showed in "dev mode" if I build my application it shows the "other" similar one:
Uncaught TypeError: Yge is not a function
Is the bug fixed with this one @werthdavid @delyethan ? https://github.com/werthdavid/ngx-kjua/pull/60
If that's the case we can close this one and https://github.com/werthdavid/ngx-kjua/issues/53 (Also do a release?)
BIG THANKS for your work!
I fear as stated above the problem comes from ng-packagr... still waiting for a fix
@hramberger Should be fixed, can you try it?
I checked version 2.0.2 and it seems to work as expected again. Thanks for the fix!
@werthdavid feel free to close that issue :)