[bug]: can't `require` some dependencies on server component
I maintainer di solito rispondono entro 6 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 24
- Fork
- 13
- Merge medio
- 5g 3h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di strapi/sdk-plugin
-
Difficoltà 4/5 Mezza giornata Idoneità per principianti 15/100
strapi/sdk-plugin#244 ·
I maintainer di solito rispondono entro 6 giorni
-
[bug]: build ignores exports file names and package.json#type, breaking "type": "module" pluginsForse già presa @unrevised6419 l’ha presa 44 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
strapi/sdk-plugin#242 ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
strapi/sdk-plugin#241 ·
I maintainer di solito rispondono entro 6 giorni
-
[feat]: build a subset of bundles with --bundle, for per-bundle task cachingForse già presa @unrevised6419 l’ha presa 51 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
strapi/sdk-plugin#238 ·
I maintainer di solito rispondono entro 6 giorni
-
[bug]: When building with latest sdk-plugin version, I loose sub folders typesForse di nuovo libera @jhoward1994 l’ha presa 247 giorni fa e non c’è nessuna pull request aperta. Apertaissue: bug
strapi/sdk-plugin#115 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di strapi/sdk-plugin
Issue simili
-
[BUG]: Duplicate preposition in heading and unformatted feedback text on Strengthen Argument pageApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AOSSIE-Org/DebateAI#801 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
ci: repo has no GitHub Actions workflow, so pushes and pull requests are never built or testedApertaagents area: runtime automation chore cli consistency dependencies developer-experience difficulty: easy documentation enhancement good first issue help wanted hygiene json-output priority: P3 starters tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Add: BOM CineApertaapproved check:passed streams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno