diff --git a/src/cli/commands/plugin/init/action.ts b/src/cli/commands/plugin/init/action.ts index efa8fef..9ce1e2e 100644 --- a/src/cli/commands/plugin/init/action.ts +++ b/src/cli/commands/plugin/init/action.ts @@ -449,6 +449,15 @@ const getPluginTemplate = ({ suggestedPackageName }: PluginTemplateOptions) => { '@strapi/typescript-utils': '*', typescript: '*', }; + } else { + // If the plugin is not typescript, we need to add a jsconfig.json file + // to the frontend code. This configuration ensures we have no + // build errors for the frontend javascript code. + if (isRecord(pkgJson.exports['./strapi-admin'])) { + const { adminJsConfigFile } = await import('./files/javascript'); + + files.push(adminJsConfigFile); + } } /** diff --git a/src/cli/commands/plugin/init/files/javascript.ts b/src/cli/commands/plugin/init/files/javascript.ts new file mode 100644 index 0000000..fd8aaea --- /dev/null +++ b/src/cli/commands/plugin/init/files/javascript.ts @@ -0,0 +1,24 @@ +import { outdent } from 'outdent'; + +import type { TemplateFile } from '@strapi/pack-up'; + +const ADMIN: TemplateFile = { + name: 'admin/jsconfig.json', + contents: outdent` + { + "compilerOptions": { + "target": "es6", + "jsx": "react", + "module": "esnext", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true + }, + "include": [ + "./src/**/*.js", + "./src/**/*.jsx" + ] + } + `, +}; + +export { ADMIN as adminJsConfigFile };