gijgo
gijgo copied to clipboard
Webpack - gj is not defined
I'm using gijgo from npm
importing this way, after jquery imports:
import 'modules/gijgo/js/gijgo.min';
import 'modules/gijgo/js/messages/messages.pt-br.min';
import 'modules/gijgo/css/gijgo.min.css';
then generating the bundle with webpack 4
but getting this error gj is not defined

Thanks for any help
I got it working using ver 1.9.6
in app.js:
import "gijgo";
and app.scss:
@import "~gijgo/css/gijgo";
also in webpack.config.js, I did following to make the fonts available:
plugins: [
new CopyWebpackPlugin([
{ from: 'node_modules/gijgo/fonts', to: '../fonts' }
]),
ver 1.9.7 is broken, yet to try ver 1.9.9
Hope this helps.
I had the same problem :(
Same here, gj is not being exported so it cannot be used
I don't have experience with Webpack. Could you give me replication steps about this. gj is the main object/variable that contains all methods and default configurations for the controls. How to configure export of this variable?
Just look at examples like moment.js and javascript export functionality added since ECMAscript 2015 (I think)
I have experience using Webpack only with Angular and everything looks good when I do that. You can see an example for that in 'src\app\datepicker.demo.component.ts' at https://github.com/atatanasov/gijgo-angular-wrappers. You can also remove the comment from line 30 to see that this works good with locales as well. You can see an instructions how to run that on a development server at the end of the https://github.com/atatanasov/gijgo-angular-wrappers read me section
This is specific to Angular, it won't work with other frameworks out there. The advantage of exporting is that it can work with anything.
Do you think that If I add export { gj }; line at the end of my js file, this is going to resolve the "gj is not defined" error.
Please, advise. Atanas
It's a little tricky with your code and I'm not pretty sure if I'm using the best practices:
-
Had to import jQuery on gijgo.js, otherwise is not recognized
import jQuery from 'jquery';I assume you have to import it from the node module in package.json -
Had to declare each variable the conventional way, meaning, anything that starts with:
variable = somethinghad to be changed to:var variable = something -
Then do
export default gj;at the end of the file
@cuartas15 - Thanks for the help. We can't change this in the next 1.9 version, but we are going to add support about this in version 2.0. I would ask the community to use your workaround for now and be patience for the next major release.
I ran into the same issue here. I solved it by using webpack's script-loader.
https://webpack.js.org/loaders/script-loader/
Once you have script loader, you can import Gijgo by
import 'script-loader!gijgo';
gj is now loaded. You can import the "message" files right after that line without a problem, if that was your issue.
import 'script-loader!gijgo';
import 'gijgo/js/messages/messages.es-es';
Note that this workaround pollutes the global namespace.
It's a little tricky with your code and I'm not pretty sure if I'm using the best practices:
* Had to import jQuery on gijgo.js, otherwise is not recognized `import jQuery from 'jquery';` I assume you have to import it from the node module in package.json * Had to declare each variable the conventional way, meaning, anything that starts with: `variable = something` had to be changed to: `var variable = something` * Then do `export default gj;` at the end of the file
This doesn't work for me.
@atatanasov is version 2.0 on the way?