question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`imports?window.jQuery=jquery` doesn't capture window

See original GitHub issue

The expression imports?window.jQuery=jquery!angular generates the following

/*** IMPORTS FROM imports-loader ***/
var window = (window || {});
window.jQuery = require("jquery");

require('./angular');

When webpack wraps this in a function expression, the window referenced in the initialization of the localwindow is the local window rather than the global window. This is fine for contained modules, but in this case the module is just a stub that loads another module where the private window isn’t visible.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
amitayrcommented, May 8, 2017

@cdauth this happens because of javascript hoisting. this line: var window = (window || {}); is interpreted as var window; window = (window || {}); so you don’t get the global window varaible.

you can solve it with some hacking: imports-loader?window=>global&window.jQuery=>jquery!angular or imports-loader?windowTemp=>window&windowTemp.jQuery=>jquery!angular

0reactions
Tchillercommented, Jun 17, 2022

@cap-Bernardito thanks for your last comment. There is a little typo in it which you might want to correct. “additionalCode”

Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - JQuery - $ is not defined - Stack Overflow
First you need to make sure that jQuery script is loaded. This could be from a CDN or local on your ...
Read more >
Prism
Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It's used in millions of websites, including some of...
Read more >
Using Web Workers - Web APIs - MDN Web Docs
A worker is an object created using a constructor (e.g. Worker() ) that runs a named JavaScript file — this file contains the...
Read more >
Using Cypress - Cypress Documentation
Cypress commands yield jQuery objects, so you can call methods on them. ... How do I prevent the application from opening a new...
Read more >
How can I load jQuery in LWC? - Salesforce Stack Exchange
So if you try to use it inside the component, you'll be able to write something like $('input') , but window.jQuery in developer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found