vuepress / vuepress-community

:bulb: Community supported ecosystem for VuePress
https://vuepress-community.netlify.app
MIT License
81 stars 62 forks source link

[Question] why are we using `"module": "es2015"` #46

Closed Mister-Hope closed 4 years ago

Mister-Hope commented 4 years ago

If I am not misunderstanding, we should use "module": "commonjs" because that 's what Vuepress is requesting for it's plugins.

And that also means we should write export = xxx instead of module.exports = xxx in the entry files for vuepress plugins according to the typescript docs ( though module.exports = xxx is ok)

meteorlxy commented 4 years ago

It's tricky. Vuepress uses commonjs modules for entry files, etc, and uses esm files for enhanceAppFiles, etc.

meteorlxy commented 4 years ago

(对了,有时间的话可以研究研究 vitepress)

Mister-Hope commented 4 years ago

I am trying to solve the compile issue when user is not setting "allowSyntheticDefaultImports": true

If we are using "module": "es2015", most plugins is using commonjs, and will cause an issue when the plugin developer is tring to import vuepress-types if I change the types files with import * as xxx from 'xxx' . Also import xxx from 'xxx' will show an error

Mister-Hope commented 4 years ago

The only way not triggering error is to write import xxx = require('xxx'), but that requires we export vuepress-types using "module": "commonjs"

Mister-Hope commented 4 years ago

(对了,有时间的话可以研究研究 vitepress)

好的,这是要弃坑 vuepress 么?

meteorlxy commented 4 years ago

yyx 大佬要弃坑,我们也木有办法。

或者感兴趣的话一起来搞 vuepress-next (自从发现 vitepress 之后我失去动力了 orz)

Mister-Hope commented 4 years ago

哈哈哈哈,我自己搞了一个 hopepress , 可以一起搞搞,hopepress我就不弄了。我主要在hopepress 上的计划是drop node 8,然后全部ts化,并且优化一下vuepress 对ts 的支持,增强cache,还有一些issue提到的增强,比如支持prismjs自定义主题,渲染html添加进度条,优化内存之类的。大佬有什么针对 vuepress-next的其他计划么?能讲来听听么?

meteorlxy commented 4 years ago

你可以看看,已经全部重构了

Mister-Hope commented 4 years ago

好,我克隆下来看看。

Mister-Hope commented 4 years ago

基本上 ulivz 写的源码我都看了,vuepress的整体思路挺好的,就是主题和plugin模块的实现,内存消耗得太大了,而且性能也有一定问题。启动webpack前必须要读整个文档,要是尤大能做一个更快速的vite,我突然觉得也没啥动力了hhh

Mister-Hope commented 4 years ago

我自己写的 vuepress-theme-hope 真的是插件一多组件一多慢入牛,一次构建六分钟。

meteorlxy commented 4 years ago

原计划是尽可能保留 1.x 的兼容性。不过 vitepress 都出来了 emmm

前途未卜:

  1. 如果官方决定用 vitepress 代替 vuepress,由于两者的理念有挺大的差别,目前来看很难保持较好的兼容。所以有可能 vuepress 会交由社区单独维护(只是猜测,如果真到那时候我会争取下),那么 vuepress-next 其实可以考虑多做点 breaking changes,吸收一些 vitepress 的理念,甚至我考虑把 webpack 解耦出来,可以同时支持 vite / parcel 之类的。

  2. 如果 vitepress 不会代替 vuepress ,那么这两个可能会同时官方维护,vuepress-next 保持 1.x 兼容性可能会更优先一些。

meteorlxy commented 4 years ago

vitepress 目前看,非常依赖浏览器的 es module 机制,我觉得让 IE 去死的话的确是未来趋势。

meteorlxy commented 4 years ago

Close for housekeeping