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

fix: modify the importing method of 3rd-party dependencies #1

Merged
merged 2 commits into from
May 14, 2024
Merged

fix: modify the importing method of 3rd-party dependencies #1

merged 2 commits into from
May 14, 2024

Conversation

imaegoo
Copy link
Member

@imaegoo imaegoo commented May 14, 2024

@imaegoo
Copy link
Member Author

imaegoo commented May 14, 2024

test passed

image

@Tao-VanJS Tao-VanJS merged commit dfefc4c into twikoojs:main May 14, 2024
@Tao-VanJS
Copy link
Collaborator

奇怪,我在运行npx wrangler deploy --minify还是会遇到这样的错误:

✘ [ERROR] Could not resolve "tencentcloud-sdk-nodejs"

    node_modules/twikoo-func/utils/lib.js:55:33:
      55 │ ...entcloud = require('tencentcloud-sdk-nodejs') // 腾讯云 API ...
         ╵                       ~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "tencentcloud-sdk-nodejs" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.


✘ [ERROR] Build failed with 1 error:

  node_modules/twikoo-func/utils/lib.js:55:33: ERROR: Could not resolve "tencentcloud-sdk-nodejs"

@imaegoo
Copy link
Member Author

imaegoo commented May 14, 2024 via email

@Tao-VanJS
Copy link
Collaborator

You can mark the path "tencentcloud-sdk-nodejs" as external to exclude it from the bundle, 我觉得应该试试这句话

这句话让我很困惑。我没有找到怎么可以把一个path mark成"external"的方法。所以我只知道用try {...} catch {...}包起来的办法。另外我看到您已经可以把这个repo成功部署到Cloudflare worker上去了。能分享一下怎么从一个clean的状态部署上去的步骤吗?目前我把这个PR合并进去再进行部署就会出错:-(现在无法完成一个成功的部署。

@imaegoo
Copy link
Member Author

imaegoo commented May 15, 2024

能分享一下怎么从一个clean的状态部署上去的步骤吗?

和README中的步骤基本一样,不同之处是我把第二步执行的命令换成了

echo "" > node_modules/tencentcloud-sdk-nodejs/tencentcloud/index.js

@Tao-VanJS
Copy link
Collaborator

能分享一下怎么从一个clean的状态部署上去的步骤吗?

和README中的步骤基本一样,不同之处是我把第二步执行的命令换成了

echo "" > node_modules/tencentcloud-sdk-nodejs/tencentcloud/index.js

啊,这个很聪明!我把同样的技巧也用在了jsdom上面。这个降低尺寸的效果比较之前的rm -rf ...还要好很多,因为顺便也把所有依赖的包也一并移除了。目前我部署的脚本只有不到400kB,和1MiB的上限还有很大的距离!

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

Successfully merging this pull request may close these issues.

2 participants