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

Failed to build Typescript Plugin after v4.5.1; Cannot find module design-system/icons #15072

Closed
HenryBrown0 opened this issue Dec 4, 2022 · 8 comments
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: typescript Source is related to TypeScript (typings, tooling, ...)

Comments

@HenryBrown0
Copy link

Bug report

Required System information

  • Node.js version: v18 (also checked with v16)
  • NPM version: Using Yarn v1.22.19
  • Strapi version: v4.5.2 (tested and working in v4.5.1)
  • Database: postgreSQL
  • Operating system: macOS v12.5

Describe the bug

Unable to use @strapi/icons or @strapi/design-system in custom typescript plugins after v4.5.1 as the modules/types cannot be found.

Cannot find module '@strapi/design-system/Box' or its corresponding type declarations.
Cannot find module '@strapi/icons/Puzzle' or its corresponding type declarations.

Steps to reproduce the behavior

  1. Create a new strapi project (select quickstart, I've also tried manual configuration with Typescript):
    yarn create strapi-app my-project
    
  2. Stop strapi running and change directory into the new project.
  3. Create a Typescript plugin (select typescript):
    yarn strapi generate plugin my-plugin
    
  4. (optional) Enable the plugin:
    // ./config/plugins.js
    module.exports = {
      'my-plugin': {
        enabled: true,
        resolve: './src/plugins/my-plugin'
      },
    }
  5. . Build the application (fails):
    yarn build
    

Expected behavior

Expect strapi to build successfully.

Screenshots

n/a

Code snippets

Cannot find module '@strapi/icons/Puzzle' or its corresponding type declarations.
Cannot find module '@strapi/design-system/Box' or its corresponding type declarations.

Additional context

If you downgrade strapi dependencies to v4.5.1 the build is successful.

May relate to: #14925

Adding @strapi/icons or @strapi/design-system to either/both the project/plugin does not solve the issue.

@joshuaellis joshuaellis added issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: typescript Source is related to TypeScript (typings, tooling, ...) labels Dec 5, 2022
@joshuaellis
Copy link
Member

The solution to this would be to add some sort of custom.d.ts file that declares:

declare module '@strapi/design-system/*';
declare module '@strapi/icons/*';

Because right now there are no types, but we're using the exports property of the package.json to direct @strapi/design-system/Box to @strapi/design-system/dist/Box where the TS compiler can't follow right now.

@Yizhachok
Copy link

@joshuaellis there is a combination of errors (not only with import)
image

Can you suggest how to fix this? This happens on clean project.
Also I think that instead of using VoidFunctionComponent we need to use FC

@Yizhachok
Copy link

The solution to this would be to add some sort of custom.d.ts file that declares:

declare module '@strapi/design-system/*';
declare module '@strapi/icons/*';

Because right now there are no types, but we're using the exports property of the package.json to direct @strapi/design-system/Box to @strapi/design-system/dist/Box where the TS compiler can't follow right now.

Also, this trick unfortunately didn't help :(

@andreiwow2

This comment was marked as spam.

@derrickmehaffy
Copy link
Member

Hello, we are marking this issue as closed as it has been combined into a centralized Tracking issue for all Typescript issues.

Please see: #15225

If you believe this was merged into the tracking issue in error please let us know. For any further debug information please use the tracking issue.

Thanks!

@jcAtRsi
Copy link

jcAtRsi commented Jan 14, 2023

Looks like the design system v2 items (pagelink, nextlink, previouslink, pagination) are still impacted by this. The icons part does work now (as of 4.5.6)

@matepaiva
Copy link

i don't understand why I have this error only at my server. If I try to build the project locally, it works fine. If I try to build at my digitalocean server, it throws this error. Both my server and my local servers are using the same version for node (v18.12.1) and for npm (6.14.18).

If someone think about a possible reason, please illuminate me!

@SvenWesterlaken
Copy link

Might be related to this issue @matepaiva

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: medium If it breaks the basic use of the product but can be worked around source: typescript Source is related to TypeScript (typings, tooling, ...)
Projects
Archived in project
Development

No branches or pull requests

8 participants