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

发现3个问题:vite报错不识别commonJS语法。泛型返回有问题。不生成pontCore.js #327

Open
dingshaohua-com opened this issue Jul 18, 2022 · 2 comments

Comments

@dingshaohua-com
Copy link

问题1:vite不能识别pontCore.js中的exports

因为vite只支持esm规范,exports属于commonjs规范。
解决办法是,使用patch-package 或者pnpm、yarn自带的补丁工具,给包打补丁。
比如pnpm,打补丁后自动生成的内容如下

diff --git a/pontCore/pontCore.js b/pontCore/pontCore.js
index 1e1bdfcaefedf5e37ac95014dbecd6953ad10dbb..9ebc94ff4b25a2ac83a54bf95806e50fde8bb1e1 100644
--- a/pontCore/pontCore.js
+++ b/pontCore/pontCore.js
@@ -13,7 +13,7 @@ var __assign = (this && this.__assign) || function () {
     };
     return __assign.apply(this, arguments);
 };
-Object.defineProperty(exports, "__esModule", { value: true });
+// Object.defineProperty(exports, "__esModule", { value: true });
 var PontCoreManager = /** @class */ (function () {
     function PontCoreManager() {
     }
@@ -72,4 +72,4 @@ var PontCoreManager = /** @class */ (function () {
     PontCoreManager.singleInstance = null;
     return PontCoreManager;
 }());
-exports.PontCore = PontCoreManager.getSignleInstance();
+export const PontCore = PontCoreManager.getSignleInstance();

问题2:若后端的返回泛型,且泛型的类型是复杂类型,则生成的返回类型有误

解决办法看我博客

问题3:不生成pontCore.js

pont-config.json中的surrounding改为javaScript即可。
哪怕用ts,也不要写成typeScript

@ayuan-gy
Copy link

patch-package怎么解决

@z979054461
Copy link
Collaborator

问题3已解决:#407

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

3 participants