Using ES import issue with monorepo workspace packages #20294
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, ...)
status: pending reproduction
Waiting for free time to reproduce the issue, or more information
Bug report
Required System information
20.1.3 4.24.1Describe the bug
A clear and concise description of what the bug is.
I encountered the problem of not being able to import files from workspace packages (turbo monorepo with using workspaces), in my case it was the @some/common package, complaining that this is not supported in the ts file.
Steps to reproduce the behavior
Expected behavior
Want some help how to use monorepo packages in strapi, need solution to pass compilation step and problems with imports,
the main problem that the strapi expecting importing module building with CommonJS, but we don't needed
Screenshots
If applicable, add screenshots to help explain your problem.
Code snippets
strapi:build: cache bypass, force executing 9df377beb679af49
strapi:build: [WARN] [@strapi/strapi]: The NODE_ENV is not set to production. This may result in unexpected behavior.
strapi:build: ⠋ Compiling TS src/api/healthcheck/controllers/healthcheck.ts:4:38 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@some/common")' call instead.
@dbbs/strapi:build: To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field "type": "module" to '/apps/strapi/package.json'.
strapi:build:
strapi:build: import { SettingServiceClient } from '@some/common'
Additional context
my tsconfig configuration:
The text was updated successfully, but these errors were encountered: