引入 Lib 中的 class 无效
- Dominant language
- JavaScript
- Stars
- 41.6k
- Forks
- 3.7k
- Avg merge
- 7h 6m
- Merged PRs (30d)
- 6
Description
**问题描述**
import { LibClass } from 'lib';
let aa = new LibClass();
以上代码打包成微信小程序后报错,编译后的代码:
const e=require("../../common/vendor.js")
执行时,报 e 为 undefined 错误
**复现步骤**
let aa = new LibClass(); 代码位置为小程序分包中,不知道是否有影响
**预期结果**
不报错,并完成对象 new 操作
**实际结果**
报错,不是 undefined 就是报 LibClass is not constructor
**系统信息:**
- 发行平台: [微信小程序]
- uni-app版本 ["@dcloudio/uni-app": "3.0.0-5020420260813003",]
**补充信息**
vendor.js 似乎已经通过 exports.xxx 导出了的,但是不知道为啥不生效
Contributor guide
Research direction
Reproduce the import in a WeChat mini-program subpackage using the reported uni-app version. Start by inspecting the compiled common/vendor.js and the subpackage output around the generated require call and exports. Done means importing LibClass no longer produces undefined or “LibClass is not constructor” and the object can be created successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100