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

安装第三方包打包成功,生成代码却存在问题 #65

Closed
zhaoqinghai opened this issue May 3, 2018 · 16 comments
Closed

安装第三方包打包成功,生成代码却存在问题 #65

zhaoqinghai opened this issue May 3, 2018 · 16 comments
Labels
bug Something isn't working

Comments

@zhaoqinghai
Copy link

default

@qiu8310
Copy link
Owner

qiu8310 commented May 4, 2018

怎么复现,简单描述下

@zhaoqinghai
Copy link
Author

先通过cnpm安装rxjs6.0的包,然后引用rxjs到项目中,再输入minapp dev 生成成功,没有异常。再打开微信小程序开发工具将生成的dist引入其中 运行就会出现这个问题

@qiu8310
Copy link
Owner

qiu8310 commented May 4, 2018

怎么引用的 rxjs,我直接 require('rxjs') 没什么问题,是不是调用了什么函数或者什么的触发了?

@zhaoqinghai
Copy link
Author

我是这样引用的import * as Rx from 'rxjs'; 没调用其他函数

@qiu8310
Copy link
Owner

qiu8310 commented May 4, 2018

我没办法复现

image

image

你用的 minapp/cli 是什么版本

@zhaoqinghai
Copy link
Author

zhaoqinghai commented May 4, 2018

那为什么显示的是本地服务的js无法加载,是不是还要设置防火墙。能不能直接相对路径引入呢?
版本号是1.1.1

@qiu8310
Copy link
Owner

qiu8310 commented May 4, 2018

image

这个文件是不是不存在,我电脑里只有 Observable.js, 没有 observable.js(O 变小写了)

@zhaoqinghai
Copy link
Author

这个文件是不存在的,是有哪个地方需要这个文件吗

@qiu8310
Copy link
Owner

qiu8310 commented May 5, 2018

那我不太清楚,你重装下 rxjs 试试,我这边是正常运行的

@zhaoqinghai
Copy link
Author

我装了好几次了,也装了好几个版本了,今天minapp又升级到2.0了,可还是编译成功了,在微信小程序开发工具就报错

@qiu8310
Copy link
Owner

qiu8310 commented May 5, 2018

你是 window 系统吗?

@zhaoqinghai
Copy link
Author

对啊 win10

@qiu8310
Copy link
Owner

qiu8310 commented May 5, 2018

好,我去 window 下试试看

@zhaoqinghai
Copy link
Author

好的,谢谢啦

@qiu8310 qiu8310 closed this as completed in 3ec115f May 5, 2018
@qiu8310
Copy link
Owner

qiu8310 commented May 5, 2018

问题解决了,发了 2.0.1 版本

主要原因是 window 路径不区分大小写

internal/Observable/xxx.js 中使用了

require('../observable')

而我的程序会先计算出 require 文件的绝对路径并去除后缀 internal/observable,然后用 internal/Observableinternal/observable 计算出相对引用位置,由于不区分大小写,导致相对引用位置为空字符串 "",从而导致微信报错

解决方法就是在计算出相对引用位置之后再去除文件后缀。

非常感谢你的反馈!!!

@zhaoqinghai
Copy link
Author

谢谢 成功了

@qiu8310 qiu8310 added bug Something isn't working and removed reproduce-needed labels May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants