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

Cant build project with custom plugins [Typescript] #18912

Closed
hashedalgorithm opened this issue Nov 25, 2023 · 5 comments
Closed

Cant build project with custom plugins [Typescript] #18912

hashedalgorithm opened this issue Nov 25, 2023 · 5 comments

Comments

@hashedalgorithm
Copy link

Bug report

Required System information

  • Node.js version: 20.10.0
  • NPM version: 10.2.3
  • Strapi version: 4.15.4
  • Database: SQLLite/Postgresql
  • Operating system: Windows 11 Home (Version -22H2) - (OS Build - 22621.2715)
  • Is your project Javascript or Typescript: Typescript

Describe the bug

Building custom plugin fails. The plugin's source is not properly configured to generated/compiled properly results in the module not resolved error.

Steps to reproduce the behavior

  1. Your Strapi Project should be in Typescipt.
  2. Create a custom plugin as per the docs. (Choose preferred language : typescript)
  3. Add your plugin declarations in config/plugins.ts
  4. Build and run your strapi project.

Expected behavior

The Plugin should be added to the Side Navigation bar of the admin panel and accessible.

Screenshots

image

The auto-generated .strapi/client/app.js file below while running yarn build
.strapi/client/app.js
`/**

  • This file was automatically generated by Strapi.
  • Any modifications made will be discarded.
    */
    import usersPermissions from "@strapi/plugin-users-permissions/strapi-admin";
    import i18N from "@strapi/plugin-i18n/strapi-admin";
    import strapiCloud from "@strapi/plugin-cloud/strapi-admin";
    import myplugin from "....srcpluginsmyplugin/strapi-admin";
    import { renderAdmin } from "@strapi/strapi/admin";

renderAdmin(document.getElementById("strapi"), {
plugins: {
"users-permissions": usersPermissions,
i18n: i18N,
"strapi-cloud": strapiCloud,
myplugin: myplugin,
},
});
`

As you can see the import for the custom plugin "myplugin" is messed up or not generated correctly. This actually breaks whole building process and i cant use the plugins.

Additional Content

I have tried in various JS/TS environment combinations to check if this still a case for all possibilities.
image

@gacek1123
Copy link

Having the exact same issue in my project.
Running Node 20 on Windows 10 and using TS.

@sehrish30
Copy link

Having exact same issue in my project with typescript the imports in app.js are messed up. The only way to make it work is run with --watch-admin and manually change the paths in app.js. Using @strapi/strapi version 4.15.4.

@hashedalgorithm
Copy link
Author

Having exact same issue in my project with typescript the imports in app.js are messed up. The only way to make it work is run with --watch-admin and manually change the paths in app.js. Using @strapi/strapi version 4.15.4.

"yarn develop" initially builds the project with plugins. The whole .strapi folder contents are getting replaced, when the app builds.
So it basically reverts back to messed up import version.🥲

@monolithed
Copy link

Another problem is some plugins cannot be deleted:

➜ npm run strapi uninstall strapi-plugin-protected-populate

> strapi@0.1.0 strapi
> strapi uninstall strapi-plugin-protected-populate

? Do you want to delete the plugin generated files in the extensions folder ? Yes
Cannot find module '@strapi/plugin-strapi-plugin-protected-populate/package.json'
Require stack:
- /Users/monolithed/workspace/pergum/strapi/node_modules/@strapi/strapi/dist/load/package-path.js
- /Users/monolithed/workspace/pergum/strapi/node_modules/@strapi/strapi/dist/commands/actions/install/action.js
- /Users/monolithed/workspace/pergum/strapi/node_modules/@strapi/strapi/dist/commands/actions/install/command.js
- /Users/monolithed/workspace/pergum/strapi/node_modules/@strapi/strapi/dist/commands/index.js
- /Users/monolithed/workspace/pergum/strapi/node_modules/@strapi/strapi/dist/cli.js
- /Users/monolithed/workspace/pergum/strapi/node_modules/@strapi/strapi/bin/strapi.js

@joshuaellis
Copy link
Member

Please try the 4.15.5-alpha.5 this issue should be resolved there.

@joshuaellis joshuaellis closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

5 participants