mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
Merge pull request #16516 from strapi/ts-support-2/automatic-type-generation
This commit is contained in:
commit
cd5e791448
@ -106,12 +106,30 @@ const primaryProcess = async ({ distDir, appDir, build, isTSProject, watchAdmin,
|
||||
cluster.fork();
|
||||
};
|
||||
|
||||
const workerProcess = ({ appDir, distDir, watchAdmin, polling, isTSProject }) => {
|
||||
const strapiInstance = strapi({
|
||||
const workerProcess = async ({ appDir, distDir, watchAdmin, polling, isTSProject }) => {
|
||||
const strapiInstance = await strapi({
|
||||
distDir,
|
||||
autoReload: true,
|
||||
serveAdminPanel: !watchAdmin,
|
||||
});
|
||||
}).load();
|
||||
|
||||
/**
|
||||
* TypeScript automatic type generation upon dev server restart
|
||||
* Its implementation, configuration and behavior can change in future releases
|
||||
* @experimental
|
||||
*/
|
||||
const shouldGenerateTypeScriptTypes = strapiInstance.config.get('typescript.autogenerate', false);
|
||||
|
||||
if (shouldGenerateTypeScriptTypes) {
|
||||
// This is run in an uncaught promise on purpose so that it doesn't block Strapi startup
|
||||
// NOTE: We should probably add some configuration options to manage the file structure output or the verbosity level
|
||||
tsUtils.generators.generateSchemasDefinitions({
|
||||
strapi: strapiInstance,
|
||||
outDir: appDir,
|
||||
verbose: false,
|
||||
silent: true,
|
||||
});
|
||||
}
|
||||
|
||||
const adminWatchIgnoreFiles = strapiInstance.config.get('admin.watchIgnoreFiles', []);
|
||||
watchFileChanges({
|
||||
@ -179,6 +197,7 @@ function watchFileChanges({ appDir, strapiInstance, watchIgnoreFiles, polling })
|
||||
'**/*.db*',
|
||||
'**/exports/**',
|
||||
'**/dist/**',
|
||||
'**/*.d.ts',
|
||||
...watchIgnoreFiles,
|
||||
],
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user