live2d-widget.js
live2d-widget.js copied to clipboard
Cannot assign to read only property 'exports' of object
描述你的问题
-
使用
webpack 4
运行时报错Cannot assign to read only property 'exports' of object
追查原因是
src/dialog/index.js
中import
与module.exports
混用...mport { config } from '../config/configMgr'; mport { L2Dwidget } from '../index'; .. odule.exports = { createDialogElement, displayDialog, hiddenDialog, alertText, showHitokotoLoop
-
使用
webpack 4
运行时报错Identifier 'aE' has already been declared
Identifier 't' has already been declared
追查原因是
src/lib/live2d.core.js
中function aE()
和function t()
确实定义了2次... 第一次3133-3168
行 第二次4871-4906
行 考虑去除4871-4906
行?live2d.core.js-4871
环境信息(请务必填写下列信息)
-
设备: [PC]
-
操作系统: [MACOS]
-
浏览器 [Chrome 73]
-
live2d-widget: [3.1.3]
-
[x] 我已仔细阅读CONTRIBUTING中的相关内容。
-
[x] 我已仔细阅读README中的相关内容。
@EYHN
请使用webpack3编译此项目。
您可以使用webpack4调用此项目,下面是例子
main.js
const live2d = require('live2d-widget').L2Dwidget;
live2d.init();
webpack.config.js
module.exports = {
entry: {
'main': __dirname + '/main.js'
},
mode: 'development',
output: {
path: __dirname + '/dist',
filename: '[name].js'
}
}
@EYHN 没问题了 似乎主要是引入问题... 一直按照此处 API 引入
import {L2Dwidget} from 'live2d-widget/src/index.js'
改成
import { L2Dwidget } from 'live2d-widget'
即可(某版本之前不可...)
这里文档应该更新一下😊