!Pause migration to ESM | 暂缓ESM计划 #8548
NeverBehave
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Most of the of NodeJS developer might have already knew that Node 10 is no longer under maintained, and Node 12 by default ES Module. However, RSSHub is still using CommonJS (CJS)
Although in current Node LTS 16, CJS is still in stable state, more and more deps have completely dropped back-compatibility with CJS and going toward MJS: https://nodejs.org/dist/latest-v16.x/docs/api/modules.html#modules_modules_commonjs_modules
At the same time, NodeJS member has clearly mentioned that CJS would still be main stream for a pretty long time: nodejs/help#2267
With all these being said, along with the consideration that RSSHub is mainly a Server App, which won't enjoy much of the benefits of ESM, we will pause all works toward making RSSHub an ESM. This decision means that RSSHub will:
Problems we have encountered during migration:
(await (import 'some-route.js')).default
. We use lots of it when optimizing for cloud function, plugins, etc.jest
does not work well with ESMPlease Note, this transition is not init by Node official, but a bunch of deps maintainers who tried to push the ESM and brings all these chaos, some of them stated that the cost of transition is minimum, but unfortunately this isn't true for RSSHub. You may check our efforts here: #8292
Unless we have a clear, mature solution toward all these problems mentioned, we will NOT consider switching to ESM, and here from the stand as an contributor, I strongly disagree people making these breaking changes without leaving a clear path how to migrate. I see there are some ideas but that's totally not enough. It's okay to change, but it is not okay to just do the changes.
可能相当一部分NodeJS开发者已经知道,NodeJS 10已经不再维护。版本12默认支持ES Module。然而RSSHub目前仍在使用CommonJS (CJS)
尽管CJS在目前的LTS 16版本里面依然是稳定版本的核心功能之一,越来越多的基础库却开始完全放弃CJS的兼容,彻底转向了MJS:https://nodejs.org/dist/latest-v16.x/docs/api/modules.html#modules_modules_commonjs_modules
NodeJS开发者也明确表明CJS可能长期以来一直是主流:nodejs/help#2267
在这样的基础下,尤其是对于一个面向服务端的应用(转入ESM几乎没有任何优势,不需要转译),我们决定暂缓所有ESM的计划。这个决定的后果有:
目前ESM尝试遇到的问题有:
(await (import 'some-route.js')).default
jest
尚未有成熟的ESM测试方法请注意,本次的转变并不是由官方推荐的,而是工具类维护者为了推动ESM的发展而造成目前生态的混乱。他们部分人声明“转换到ESM的成本很低”。很不幸的是,这对RSSHub并不成立
主要发起的讨论在此,可移步参考:sindresorhus/meta#15
在上述问题有稳定解决方案前我们不再考虑转换到ESM,已有进度在此冻结:#8292
Beta Was this translation helpful? Give feedback.
All reactions