[bug]: one .d.ts serves both import and require outputs, so types masquerade as CJS for ESM consumers
Los mantenedores suelen responder en 6 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- typescript, vite
- Área
- build-system, cli, tooling
Línea de trabajo
Start with the vite-plugin-dts setup in build, then trace the default exports map written by init and the export checks in verify. Reproduce the issue with src/__tests__/fixtures/typescript-plugin and @arethetypeswrong/cli. Done means import and require conditions point to declarations in matching formats, and verification accepts the nested exports map.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What version of @strapi/sdk-plugin are you using?
@strapi/sdk-plugin6.1.1 (also currentmain)- Node.js 24.21.0
- TypeScript 5.x (checked with
@arethetypeswrong/cli0.18.5)
What's Wrong?
strapi-plugin build emits a single declaration file per bundle (dist/admin/src/index.d.ts, dist/server/src/index.d.ts), and the exports map generated by init points one top-level types condition at it for both the import (index.mjs) and require (index.js) outputs:
"./strapi-server": {
"types": "./dist/server/src/index.d.ts",
"source": "./server/src/index.ts",
"import": "./dist/server/index.mjs",
"require": "./dist/server/index.js",
"default": "./dist/server/index.js"
}
TypeScript decides a .d.ts file's module format from the nearest package.json#type. In a "type": "commonjs" plugin (what init generates), that one .d.ts is read as CommonJS, so ESM consumers resolving under node16/nodenext get CommonJS types for an ES module. Are the Types Wrong reports this as 🎭 Masquerading as CJS for both ./strapi-admin and ./strapi-server.
In a "type": "module" plugin the same layout flips the problem: the .d.ts is read as ESM, so require consumers would get ESM types (Masquerading as ESM).
To Reproduce
Using the repo's own typescript-plugin test fixture:
- Copy
src/__tests__/fixtures/typescript-pluginsomewhere outside the repo. - Build it with
strapi-plugin build. - Run
npx @arethetypeswrong/cli --pack .in that directory.
Output:
│ node10 │ node16 (from CJS) │ node16 (from ESM) │ bundler
"@strapi/plugin-test/strapi-admin" │ 💀 Resolution failed │ 🟢 (CJS) │ 🎭 Masquerading as CJS │ 🟢
"@strapi/plugin-test/strapi-server" │ 💀 Resolution failed │ 🟢 (CJS) │ 🎭 Masquerading as CJS │ 🟢
(The node10 failure is expected for an exports-only package with no top-level main/types. This issue is about the node16 (from ESM) column.)
Expected Behaviour
Each output format gets declarations TypeScript reads in the matching format, and the exports map points to them per condition, for example:
"./strapi-server": {
"source": "./server/src/index.ts",
"import": {
"types": "./dist/server/src/index.d.mts",
"default": "./dist/server/index.mjs"
},
"require": {
"types": "./dist/server/src/index.d.ts",
"default": "./dist/server/index.js"
},
"default": "./dist/server/index.js"
}
i.e. .d.mts next to ESM output and .d.ts / .d.cts next to CommonJS output, chosen to match package.json#type. ESM-only or CJS-only plugins keep a single declaration file in the right format.
This would touch:
- the
vite-plugin-dtssetup inbuild(emit declarations per format), - the default exports map written by
init, verify's export checks, which currently expect a top-leveltypesfirst and flat stringimport/requirevalues.
- Lenguaje dominante
- TypeScript
- Estrellas
- 24
- Forks
- 13
- Merge medio
- 5 d 3 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de strapi/sdk-plugin
-
Dificultad 4/5 Medio día Aptitud para principiantes 15/100
strapi/sdk-plugin#244 ·
Los mantenedores suelen responder en 6 días
-
[bug]: build ignores exports file names and package.json#type, breaking "type": "module" pluginsPosiblemente ocupada @unrevised6419 la tomó hace 44 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
strapi/sdk-plugin#242 ·
Los mantenedores suelen responder en 6 días
-
[feat]: build a subset of bundles with --bundle, for per-bundle task cachingPosiblemente ocupada @unrevised6419 la tomó hace 52 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
strapi/sdk-plugin#238 ·
Los mantenedores suelen responder en 6 días
-
[bug]: When building with latest sdk-plugin version, I loose sub folders typesQuizá libre de nuevo @jhoward1994 la tomó hace 248 días y no hay ningún pull request abierto. Abiertoissue: bug
strapi/sdk-plugin#115 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 6 días
-
issue: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 58/100
strapi/sdk-plugin#111 · 2 comentarios ·
Los mantenedores suelen responder en 6 días
Todos los issues de strapi/sdk-plugin
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
open-webui/tether#52 ·
Los mantenedores suelen responder en 1 día
-
`void platform install --app-access public` fails when Cloudflare reports Access is disabledAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
voidzero-dev/void#835 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
AykutSarac/jsoncrack.com#616 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
melgarafael/DeskcommCRM#4679 ·
Los mantenedores suelen responder en 1 día