Closed imaegoo closed 4 months ago
test passed
奇怪,我在运行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"
You can mark the path "tencentcloud-sdk-nodejs" as external to exclude it from the bundle, 我觉得应该试试这句话
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合并进去再进行部署就会出错:-(现在无法完成一个成功的部署。
能分享一下怎么从一个clean的状态部署上去的步骤吗?
和README中的步骤基本一样,不同之处是我把第二步执行的命令换成了
echo "" > node_modules/tencentcloud-sdk-nodejs/tencentcloud/index.js
能分享一下怎么从一个clean的状态部署上去的步骤吗?
和README中的步骤基本一样,不同之处是我把第二步执行的命令换成了
echo "" > node_modules/tencentcloud-sdk-nodejs/tencentcloud/index.js
啊,这个很聪明!我把同样的技巧也用在了jsdom上面。这个降低尺寸的效果比较之前的rm -rf ...
还要好很多,因为顺便也把所有依赖的包也一并移除了。目前我部署的脚本只有不到400kB,和1MiB的上限还有很大的距离!
links https://github.com/twikoojs/twikoo/pull/695