Do I have to use a packaging tool to use ES6 and import?

is it necessary to use packaging tools when using ES6 and import?-sharp-sharp-sharp problem description

the environmental background of the problems and what methods you have tried

I searched and said to use webpack or browerify, but it seems not suitable for small projects

small and medium-sized project leaders need to use modular processing to feel that they have packaged more code

Jun.19,2022

is not required

in browsers, import statements can only be used in tags of script that declare type= "module".

import


browsers are available but browsers are compatible
pc all browsers support

except ie .

recommend a wave of my articles: goes deep into CommonJs and ES6 Module


what should I do? I still like to use


syntax


must be packaged, and the ES6 code needs to be converted to ES5 to run on terminals such as browsers.
can't there be more code packaged? some of the writing methods of ES6 are just syntactic sugar, which are translated into ES5 and just unfolded their original implementation.


you can use script's type= "module" and type= "nomodule" to determine whether the browser supports ES6 directly. If you do, you can introduce ES6 files. If not, babel transcoding is required. Modern import browsers also support it. Depending on your compatibility requirements


generally use the webpack tool to generate a single JS file supported by all browsers by using the webpack tool to generate a single JS file with import and export syntax.
take a look at this article how to make browsers support import and export syntax in ES6

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c003dc-3a889.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c003dc-3a889.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?