How to know when to import a package or insert it into index.html
1 answer
In general, there are two types of modules. ES6 and non-ES6. If you want to use non-ES6 modules with ES6, you can try one of the following methods:
- Compile with CommonJS (e.g. using jQuery like CommonJS via npm)
- Download SystemJS so ES6 can work with CommonJS, AMD and globals
If you don't want to do this, you can try importing non-ES6 scripts into HTML. In this case, you won't be doing something like
import $ from 'jquery';
So, if you want to use a non-ES6 module without compiling with CommonJS, or if it is not available via npm, you can use HTML import instead of ES6 import
+1
source to share