Does using es6 import use package size import when using webpack

I need to understand when I use named imports like this

import { render } from 'react-dom'

Does webpack in the package contain only the visualization method or the entire module , especially when using tree shake , setting the module to false in the babel settings and letting webpack take care of them?

Also in case of import reaction

import React from 'react'

& &

import React, { Component, PropTypes } from 'react'

What is the right way?

+4
source share
1 answer

Tree-Shaking is applicable for modules that can be statically analyzed (to get a complete dependency tree without running code) - and this is ONLY for ES2015 modules and NOT CommonJS (node).

react, react-dom, (react@15.4.x), ES2015. -

import { render } from "react-dom";

import ReactDOM from "react-dom";

react-dom . react , CommonJS UMD.

+4

Source: https://habr.com/ru/post/1673732/


All Articles