[bug]: can't `require` some dependencies on server component
Maintainer thường phản hồi trong vòng 6 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, node.js
Hướng nghiên cứu
Start with the generated server component and the example service.js from the reproduction, then inspect the output at dist/server/index.js after adding uuid with require. Reproduce the failure using the listed sdk-plugin init and Strapi develop steps. Done means the generated plugin starts successfully and the server service can import and use the dependency without a dynamic try wrapper.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What version of @strapi/sdk-plugin are you using?
- npm version: 10.8.2
- node version: 20.17.0
@strapi/sdk-pluginversion: 5.2.6
What's Wrong?
Using the template created by sdk-plugin for Strapi v5 some imports inside the server component don't work. Building the plugin itself seems to work without problem, however once I try to start Strapi 5.0.0 I get the following error:
Error: Could not load js config file ~/test-plugin/dist/server/index.js: Cannot destructure property 'v4' of 'require$$0__default.default' as it is undefined.
at loadJsFile (~/cms/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@codemirror+language_s62dddslq2bxwrlfinmqz5vbcm/node_modules/@strapi/core/dist/utils/load-config-file.js:18:13)
at Module.loadConfigFile (~/cms/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@codemirror+language_s62dddslq2bxwrlfinmqz5vbcm/node_modules/@strapi/core/dist/utils/load-config-file.js:37:14)
at loadPlugins (~/cms/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@codemirror+language_s62dddslq2bxwrlfinmqz5vbcm/node_modules/@strapi/core/dist/loaders/plugins/index.js:118:41)
at async Promise.all (index 3)
at async Module.loadApplicationContext (~/cms/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@codemirror+language_s62dddslq2bxwrlfinmqz5vbcm/node_modules/@strapi/core/dist/loaders/index.js:12:3)
at async Object.register (~/cms/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@codemirror+language_s62dddslq2bxwrlfinmqz5vbcm/node_modules/@strapi/core/dist/providers/registries.js:26:5)
at async Strapi.register (~/cms/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@codemirror+language_s62dddslq2bxwrlfinmqz5vbcm/node_modules/@strapi/core/dist/Strapi.js:322:7)
at async Strapi.load (~/cms/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@codemirror+language_s62dddslq2bxwrlfinmqz5vbcm/node_modules/@strapi/core/dist/Strapi.js:314:5)
at async Module.develop (~/cms/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@codemirror+langua_zxfweiqacyjrhnmmqug74nt5xi/node_modules/@strapi/strapi/dist/node/develop.js:177:28)
at async action (~/cms/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@codemirror+langua_zxfweiqacyjrhnmmqug74nt5xi/node_modules/@strapi/strapi/dist/cli/commands/develop.js:18:5)
This started happening only from RC.18 to the stable version, instead since the first RC up to RC.17 it was working without problems.
To Reproduce
- Create plugin with
npx @strapi/sdk-plugin@latest init test-plugin, with TypeScript disabled. - Import a dependency
npm install uuid - Use dependency on server. For example, I changed
service.jslike this:
'use strict';
const {v4} = require("uuid")
const service = ({ strapi }) => ({
getWelcomeMessage() {
return 'Welcome to Strapi 🚀, uuid: ' + v4();
},
});
module.exports = service;
- Include plugin and start Strapi
npm strapi develop - Strapi crashes while trying to start, with the error above.
The issue can be circumvented by requiring uuid dynamically wrapping in a try, but that shouldn't be necessary.
Expected Behaviour
Strapi should start successfully, correctly importing the dependency.
- Ngôn ngữ chính
- TypeScript
- Star
- 24
- Fork
- 13
- Merge trung bình
- 5 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của strapi/sdk-plugin
-
Độ khó 4/5 Nửa ngày Mức phù hợp với người mới 15/100
strapi/sdk-plugin#244 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
[bug]: build ignores exports file names and package.json#type, breaking "type": "module" pluginsCó thể đã có người làm @unrevised6419 đã nhận 44 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
strapi/sdk-plugin#242 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
strapi/sdk-plugin#241 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
[feat]: build a subset of bundles with --bundle, for per-bundle task cachingCó thể đã có người làm @unrevised6419 đã nhận 52 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
strapi/sdk-plugin#238 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
[bug]: When building with latest sdk-plugin version, I loose sub folders typesCó thể làm lại được @jhoward1994 đã nhận 248 ngày trước và không có pull request nào đang mở. Đang mởissue: bug
strapi/sdk-plugin#115 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 6 ngày
Tất cả issue của strapi/sdk-plugin
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
open-webui/tether#52 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`void platform install --app-access public` fails when Cloudflare reports Access is disabledĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
voidzero-dev/void#835 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AykutSarac/jsoncrack.com#616 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
melgarafael/DeskcommCRM#4679 ·
Maintainer thường phản hồi trong vòng 1 ngày