Reputation: 2107
I need to convert the following require
to ES6 import
.
var jsdom = require('jsdom');
var $ = require('jquery')(jsdom.jsdom().parentWindow);
I know that var jsdom = require('jsdom');
is simple equivalent to import jsdom from 'jsdom';
and var $ = require('jquery');
is import $ from 'jquery';
.
Now my question is where does (jsdom.jsdom().parentWindow)
go to?
Do I write it as import $ from 'jquery'(jsdom.jsdom().parentWindow);
?
Upvotes: 1
Views: 2193
Reputation: 1920
You can destruct it as follows;
import jsdom from 'jsdom';
import jQuery from 'jquery';
const $ = jQuery(jsdom.jsdom().parentWindow);
since it is just using the return of imported jquery
library inline.
Upvotes: 1