Allow for additional entries in plugin export maps, @strapi/plugin-sdk package.json validation too aggressive
E
Euan Robertson
When updating my plugins to support v5, I want to also export from the package a collection of types that can be used by developers/users of the plugin (things like the shape of the Config, shape of endpoint data, etc).
Now that Strapi v5 has switched to using the exports map I wanted to add my types to this export map.
"exports": {
"./package.json": "./package.json",
"./strapi-admin": {
"types": "./dist/admin/src/index.d.ts",
"source": "./admin/src/index.ts",
"import": "./dist/admin/index.mjs",
"require": "./dist/admin/index.js",
"default": "./dist/admin/index.js"
},
"./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"
},
"./types/
": "./dist-types/
.d.ts" // <--- Addition}
After adding it, trying to build/watch with the @strapi/plugin-sdk (strapi-plugin build) I get the following error
[ERROR] There seems to be an unexpected error, try again with --debug for more information
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│
││ ValidationError: exports["./types/
"] must match the following: "/^\.\/.
\.json$/" ││ at createError (C:\Projects\GESDev\ges-v2\packages\editorjs\strapi-plugin-react-editorjs\node_modules\y ││ up\lib\util\createValidation.js:54:21)
││ at C:\Projects\GESDev\ges-v2\packages\editorjs\strapi-plugin-react-editorjs\node_modules\yup\lib\util\c ││ reateValidation.js:72:107
││
│└─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
I also tried to use the object form of an export entry, and got a similar error, indicating that it had to use the same format as the strapi-admin/strapi-server objects, which doesn't work in this case.