terasum / js-mdict

*.mdx/*.mdd interpreter js implements, support mdict index file
MIT License
159 stars 18 forks source link

raise error when import v4.0.13 #55

Closed terasum closed 3 years ago

terasum commented 3 years ago
Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'
    at webpackMissingModule (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:118902:99)
    at Object../node_modules/js-mdict/lib/mdict.js (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:118902:218)
    at __webpack_require__ (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137773:42)
    at Object../src/service/mainsvc/main.service.ts (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137345:34)
    at __webpack_require__ (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137773:42)
    at Object../src/service/service.manifest.ts (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137503:22)
    at __webpack_require__ (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137773:42)
    at Object../src/service/service.main.register.ts (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137452:26)
    at __webpack_require__ (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137773:42)
    at Object../src/main/init.ts (/Users/chenquan/Workspace/nodejs/medict/.webpack/main/index.js:137134:1)
terasum commented 3 years ago

you have to install the "@babel/runtime" to resolve this:

yarn add --dev @babel/runtime
songxiaocheng commented 3 years ago

目前可用,不过这是一种”侵入式“的解决方法,侵入了该库使用者的代码。

把 @babel/runtime 依赖项放到 dependencies 而不是 devDependencies 应该可以解决?

官网的示例( https://babeljs.io/docs/en/babel-runtime )也是放到 dependencies 的

npm install --save @babel/runtime
terasum commented 3 years ago

@songxiaocheng 我理解是因为使用了 babel 7 导致有些代码需要运行时才可以使用,我们的库依赖 @babel/runtime 应该可以解决这个问题

songxiaocheng commented 3 years ago

在这里(https://github.com/terasum/js-mdict/commit/9cdc7e5dc77db90e3c7c7d009f7c667269dbefc5#r52574247 )引入了 @babel/plugin-transform-runtime 插件

其官网写到:

Install it as development dependency. and @babel/runtime as a production dependency (since it's for the "runtime"). The transformation plugin is typically used only in development, but the runtime itself will be depended on by your deployed code

terasum commented 3 years ago

PR #57 应该可以解决这个问题,close 了