tangxiangmin / vite-plugin-remote-module

Load HTTP remote module in the Vite project
16 stars 4 forks source link

嵌套导入 #3

Open CHOYSEN opened 1 year ago

CHOYSEN commented 1 year ago

比如远程有两个模块:

// http://example.com/a.ts
import count from './b.ts'
console.log(count)
// http://example.com/b.ts
const count = 1
export default count
// index.ts
import '@remote/http://example.com/a.ts'

目前只下载了 a.ts,没下载 b.ts

tangxiangmin commented 1 year ago

这个插件本身不会解析目标模块的依赖,也就是说如果远程模块依赖了其他本地模块,需要将其模块的依赖也写成远程路径才行,比如

// http://example.com/a.ts
import count from '@remote/http://example.com/b.ts'
console.log(count)

这样插件应该就会自动去下载相关的依赖

另外一种解决办法是 将模块a打包,将所有的依赖模块合并到一个文件之类的。