Synchro
Synchro

Reputation: 1269

React - Webpack module.exports require

Watching the Webpack course for React.js on YouTube, the author of the video showed the content.jsx file where require and module.exports are used

enter image description here

saying that "using require we link to the react folder and also for react-dom, then export the Content class", my question is why, instead of require, it does not use import React from 'react' for react-dom import React from 'react- dom' and export export Content or export default Content

Upvotes: 0

Views: 586

Answers (1)

shadowtime2000
shadowtime2000

Reputation: 128

Most likely the tutorial you are watching is using Webpack 1 which uses the older CommonJS module format. require was how people imported stuff, and module.exports was how they exported stuff. Now a days CommonJS isn't used as much for frontend development because ES modules are being used more often and support tree shaking (that is a link to an article I wrote on the topic).

Upvotes: 1

Related Questions