Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我可以提一个PR把esmodule模式改成cjs模式吗 #36

Closed
cesaryuan opened this issue Sep 25, 2023 · 5 comments · Fixed by #37
Closed

我可以提一个PR把esmodule模式改成cjs模式吗 #36

cesaryuan opened this issue Sep 25, 2023 · 5 comments · Fixed by #37

Comments

@cesaryuan
Copy link
Contributor

es module的问题在于用vscode或者webstorm调试时不支持在uncaught exception处断下来,不利于调试(在尝试为decode-js做贡献,但是发现不支持异常断点调试起来好麻烦哈哈)

而cjs则没有这个问题,所以想问下大佬我可以提一个pr改成cjs模式嘛

@echo094
Copy link
Owner

echo094 commented Sep 25, 2023

欢迎,但是工作量看起来有点大啊。

@cesaryuan
Copy link
Contributor Author

欢迎,但是工作量看起来有点大啊。

看了下还行,要改的不算多好像

@echo094
Copy link
Owner

echo094 commented Sep 25, 2023

确实管用,也就是改一下每个文件的import和export,还有package.json

你顺便把文件后缀改成cjs吧。

const { parse } = require('@babel/parser')
const traverse = require('@babel/traverse').default
const generator = require('@babel/generator').default
const t = require('@babel/types')
const vm = require('node:vm')
const { VM } = require('vm2')
example

@cesaryuan
Copy link
Contributor Author

你顺便把文件后缀改成cjs吧。

这个感觉不用改也行,改了之后pr会一片红🤣

echo094 added a commit that referenced this issue Sep 26, 2023
* refactor: convert esmodule to commonjs #36

Signed-off-by: cesaryuan <[email protected]>

* lint

Signed-off-by: echo094 <[email protected]>

---------

Signed-off-by: echo094 <[email protected]>
Co-authored-by: cesaryuan <[email protected]>
Co-authored-by: echo094 <[email protected]>
@echo094
Copy link
Owner

echo094 commented Jan 31, 2025

我找到一个新的方案 nodejs/node#50430 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants