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

使用build --target lib --name libname [entry] 编译后文件不可用 #2643

Closed
fengpeng opened this issue Sep 28, 2018 · 4 comments
Closed

Comments

@fengpeng
Copy link

Version

3.0.4

Reproduction link

https://github.com/ElemeFE/element

Node and OS info

Node 8.x / yarn v1.10.1/ Mac

Steps to reproduce

  1. 随意新建( vue create )项目
  2. 添加 --target lib --name 等等信息到package.json buidl命令, 添加main字段, 指定到 [libname].common.js
  3. 编译之后link到某本地项目( 比如用 vue create 新建一个 ), 并添加
  4. 运行项目

What is expected?

正常运行

What is actually happening?

pptest.common.js?c837:1 Uncaught TypeError: Cannot assign to read only property 'exports' of object '#'


应该是下面这段代码引起的错误, 切换到webpack 3版本似乎没有复现此问题.
// webpack_require.r = function(exports) {
/
/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
// Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/
/ }
// Object.defineProperty(exports, '__esModule', { value: true });
/
/ };

PS: 开始以为是commonjs的文件不被接受, 后来发现element-ui是这个格式且完全无压力, 遂追踪.

@fengpeng
Copy link
Author

先关掉, 提个有例子的上来.

@mrodal
Copy link

mrodal commented Oct 3, 2018

Im having the same problem, but if I downgrade to webpack 3, I get more errors, so I think its not compatible with the latest vue-cli.

Please respond in english :E

@fengpeng
Copy link
Author

fengpeng commented Oct 26, 2018

@mrodal
I fixed the problem with webpack 4

resolve: { symlinks: false }

@mrodal
Copy link

mrodal commented Oct 26, 2018

Yeah, I opened another issue and got to the same solution: #2675
But thanks anyway!

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

No branches or pull requests

2 participants