import-http Webpack/Rollup插件从URL导入模块

从 URL 直接导入模块的方式,真的蛮爽的,是用了 import-http 之后。它是个 Webpack / Rollup 插件,让你可以像前端 CDN 一样用 import 加个 URL,就能搞定依赖,比如:import template from 'https://unpkg.com/lodash-es/template'

远程模块会在第一次构建时拉下来,之后就缓存住了,除非你手动开了 reload 选项。嗯,省了装包、升级版本这些事儿,开发体验还不错。

适合试用新库、做 DEMO、搞原型那种场景,挺方便的。就是正式上线的项目,还是得考虑下缓存、稳定性这些问题。你懂的,CDN 挂了就都挂了。

ESLint Import 插件sass-bulk-import-loader 这些配合用,风格统一还挺丝滑的。反正我现在搞小项目,已经离不开它了。

如果你想让 node_modules 轻一点,或者只是懒得管依赖版本,不妨试试 import-http,说不定就用顺手了。

zip
import-http-master.zip 预估大小:24个文件
folder
import-http-master 文件夹
file
circle.yml 643B
file
.gitattributes 12B
file
yarn.lock 349KB
folder
lib 文件夹
file
constants.js 105B
file
utils.js 974B
file
http-cache.js 415B
file
fetch.js 275B
file
rollup.js 2KB
file
webpack.js 3KB
file
index.js 140B
folder
example 文件夹
file
rollup.config.js 202B
file
foo.js 44B
file
webpack.config.js 470B
file
index.js 122B
file
LICENSE 1KB
folder
test 文件夹
file
index.test.js 701B
folder
fixture 文件夹
file
entry.js 58B
file
.prettierrc 69B
file
README.md 3KB
file
rollup.js 41B
file
webpack.js 42B
file
.editorconfig 187B
file
.gitignore 26B
file
package.json 2KB
zip 文件大小:145.41KB