diff --git a/scripts/build.cli.js b/scripts/build.cli.js index 1e864af4..c5e8791d 100644 --- a/scripts/build.cli.js +++ b/scripts/build.cli.js @@ -3,6 +3,8 @@ const esbuild = require('esbuild'); const tsPaths = require('./ts-paths'); const shell = require('shelljs'); +const buildPageConstuctorSchema = require('./build.page-constuctor-schema'); + const SEARCH_API = require.resolve('@diplodoc/search-extension/worker'); const SEARCH_LANGS = require.resolve('@diplodoc/search-extension/worker/langs'); const CLIENT_PATH = dirname(require.resolve('@diplodoc/client/manifest')); @@ -23,7 +25,6 @@ const assets = [ ]; const {version, dependencies} = require('../package.json'); -const generatePageConstuctorSchema = require('./generate-pc-schema'); const commonConfig = { tsconfig: './tsconfig.json', @@ -43,13 +44,13 @@ const commonConfig = { }, }; -generatePageConstuctorSchema(); - const builds = [ [['src/index.ts'], 'build/index.js'], [['src/workers/linter/index.ts'], 'build/linter.js'], ]; +buildPageConstuctorSchema(); + Promise.all(builds.map(([entries, outfile]) => { const currentConfig = { ...commonConfig, diff --git a/scripts/build.page-constuctor-schema.js b/scripts/build.page-constuctor-schema.js new file mode 100644 index 00000000..79ecdc5f --- /dev/null +++ b/scripts/build.page-constuctor-schema.js @@ -0,0 +1,20 @@ +const esbuild = require('esbuild'); +const shell = require('shelljs'); + +const SCHEMA_GENERATOR_PATH = 'build/generate-pc-schema.js' + +module.exports = () => { + esbuild.buildSync({ + platform: 'node', + entryPoints: ['scripts/generate-pc-schema.js'], + bundle: true, + outfile: SCHEMA_GENERATOR_PATH, + loader: { + '.css': 'empty', + }, + }) + + require(`../${SCHEMA_GENERATOR_PATH}`)(); + + shell.rm('-f', SCHEMA_GENERATOR_PATH); +} diff --git a/scripts/generate-pc-schema.js b/scripts/generate-pc-schema.js index 940cc185..ca0d6aaa 100644 --- a/scripts/generate-pc-schema.js +++ b/scripts/generate-pc-schema.js @@ -1,6 +1,4 @@ const fs = require('fs'); - -//TODO: server export for generateDefaultSchema in @gravity-ui/page-constructor const {generateDefaultSchema} = require('@gravity-ui/page-constructor'); function replaceField(obj, oldFieldName, newFieldName, newFieldValue) {