Skip to content

Commit

Permalink
Release v1.28.0
Browse files Browse the repository at this point in the history
Co-authored-by: o.drapeza <[email protected]>
GitOrigin-RevId: 3fe0f6d04256993631378bf856b2ce0c9cbd51de
  • Loading branch information
tinkoff-bot and o.drapeza committed Nov 8, 2021
1 parent 01c7209 commit f395710
Show file tree
Hide file tree
Showing 35 changed files with 642 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages-versions.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

{"@tramvai/cli":"1.27.0","@tramvai/core":"1.27.0","@tramvai/mock":"1.27.0","@tramvai/papi":"1.27.0","@tramvai/react":"1.27.0","@tramvai/react-query":"1.27.0","@tramvai/state":"1.27.0","@tramvai/types-actions-state-context":"1.27.0","@tramvai/test-unit-jest":"1.27.0","@tramvai/test-unit":"1.27.0","@tramvai/test-react":"1.27.0","@tramvai/test-puppeteer":"1.27.0","@tramvai/test-mocks":"1.27.0","@tramvai/test-jsdom":"1.27.0","@tramvai/test-integration-jest":"1.27.0","@tramvai/test-integration":"1.27.0","@tramvai/test-helpers":"1.27.0","@tramvai/tools-migrate":"0.5.118","@tramvai/tools-check-versions":"0.3.6","@tramvai/tools-generate-schema":"0.0.7","@tramvai/build":"2.6.1","@tinkoff-monorepo/depscheck":"1.8.4","@tinkoff-monorepo/fix-ts-references":"1.8.4","@tinkoff-monorepo/pkgs-collector":"1.8.4","@tinkoff-monorepo/pkgs-collector-dir":"1.8.4","@tinkoff-monorepo/pkgs-collector-workspaces":"1.8.4","@tramvai/tokens-common":"1.27.0","@tramvai/tokens-http-client":"1.27.0","@tramvai/tokens-metrics":"1.27.0","@tramvai/tokens-render":"1.27.0","@tramvai/tokens-router":"1.27.0","@tramvai/tokens-server":"1.27.0","@tramvai/module-common":"1.27.0","@tramvai/module-cookie":"1.27.0","@tramvai/module-environment":"1.27.0","@tramvai/module-log":"1.27.0","@tramvai/module-render":"1.27.0","@tramvai/module-server":"1.27.0","@tramvai/module-router":"1.27.0","@tramvai/module-http-client":"1.27.0","@tramvai/module-seo":"1.27.0","@tramvai/module-error-interceptor":"1.27.0","@tramvai/module-sentry":"1.27.0","@tramvai/module-metrics":"1.27.0","@tramvai/module-deps-graph":"1.27.0","@tramvai/module-react-query":"1.27.0","@tramvai/module-mocker":"1.27.0","@tramvai/module-cache-warmup":"1.27.0","@tramvai/module-client-hints":"1.27.0","@tramvai/module-autoscroll":"1.27.0","@tramvai/react-lazy-hydration-render":"0.1.28","@tramvai/safe-strings":"0.4.2","@tinkoff/errors":"0.2.18","@tinkoff/pubsub":"0.4.22","@tinkoff/url":"0.7.37","@tinkoff/browser-cookies":"1.4.2","@tinkoff/logger":"0.10.4","@tinkoff/is-modern-lib":"1.2.9","@tinkoff/minicss-class-generator":"0.1.13","@tinkoff/dippy":"0.7.35","@tinkoff/router":"0.1.60","@tinkoff/browserslist-config":"0.1.13","@tinkoff/layout-factory":"0.2.27","@tinkoff/user-agent":"0.3.139","@tinkoff/htmlpagebuilder":"0.4.22","@tinkoff/express-terminus":"0.1.11","@tinkoff/monkeypatch":"1.3.3","@tinkoff/meta-tags-generate":"0.4.26","@tinkoff/error-handlers":"0.4.26","@tinkoff/measure-express-requests":"1.4.2","@tinkoff/browser-timings":"0.9.4","@tinkoff/mocker":"1.5.2","@tinkoff/metrics-noop":"1.0.2","@tramvai/http-client":"0.1.22","@tramvai/tinkoff-request-http-client-adapter":"0.8.147","@tinkoff/react-hooks":"0.0.23","@tinkoff/hook-runner":"0.3.21","@tinkoff/eslint-plugin-tramvai":"0.5.12","prettier-config-tinkoff":"0.1.9","@tinkoff/pack-polyfills":"0.2.39","@tinkoff/package-manager-wrapper":"0.0.1"}
{"@tramvai/cli":"1.28.0","@tramvai/core":"1.28.0","@tramvai/mock":"1.28.0","@tramvai/papi":"1.28.0","@tramvai/react":"1.28.0","@tramvai/react-query":"1.28.0","@tramvai/state":"1.28.0","@tramvai/types-actions-state-context":"1.28.0","@tramvai/experiments":"1.28.0","@tramvai/test-unit-jest":"1.28.0","@tramvai/test-unit":"1.28.0","@tramvai/test-react":"1.28.0","@tramvai/test-puppeteer":"1.28.0","@tramvai/test-mocks":"1.28.0","@tramvai/test-jsdom":"1.28.0","@tramvai/test-integration-jest":"1.28.0","@tramvai/test-integration":"1.28.0","@tramvai/test-helpers":"1.28.0","@tramvai/tools-migrate":"0.5.118","@tramvai/tools-check-versions":"0.3.6","@tramvai/tools-generate-schema":"0.0.7","@tramvai/build":"2.6.1","@tinkoff-monorepo/depscheck":"1.8.4","@tinkoff-monorepo/fix-ts-references":"1.8.4","@tinkoff-monorepo/pkgs-collector":"1.8.4","@tinkoff-monorepo/pkgs-collector-dir":"1.8.4","@tinkoff-monorepo/pkgs-collector-workspaces":"1.8.4","@tramvai/tokens-common":"1.28.0","@tramvai/tokens-http-client":"1.28.0","@tramvai/tokens-metrics":"1.28.0","@tramvai/tokens-render":"1.28.0","@tramvai/tokens-router":"1.28.0","@tramvai/tokens-server":"1.28.0","@tramvai/module-common":"1.28.0","@tramvai/module-cookie":"1.28.0","@tramvai/module-environment":"1.28.0","@tramvai/module-log":"1.28.0","@tramvai/module-render":"1.28.0","@tramvai/module-server":"1.28.0","@tramvai/module-router":"1.28.0","@tramvai/module-http-client":"1.28.0","@tramvai/module-seo":"1.28.0","@tramvai/module-error-interceptor":"1.28.0","@tramvai/module-sentry":"1.28.0","@tramvai/module-metrics":"1.28.0","@tramvai/module-deps-graph":"1.28.0","@tramvai/module-react-query":"1.28.0","@tramvai/module-mocker":"1.28.0","@tramvai/module-cache-warmup":"1.28.0","@tramvai/module-client-hints":"1.28.0","@tramvai/module-autoscroll":"1.28.0","@tramvai/react-lazy-hydration-render":"0.1.28","@tramvai/safe-strings":"0.4.2","@tinkoff/errors":"0.2.18","@tinkoff/pubsub":"0.4.22","@tinkoff/url":"0.7.37","@tinkoff/browser-cookies":"1.4.2","@tinkoff/logger":"0.10.4","@tinkoff/is-modern-lib":"1.2.9","@tinkoff/minicss-class-generator":"0.1.13","@tinkoff/dippy":"0.7.35","@tinkoff/router":"0.1.61","@tinkoff/browserslist-config":"0.1.13","@tinkoff/layout-factory":"0.2.27","@tinkoff/user-agent":"0.3.140","@tinkoff/htmlpagebuilder":"0.4.22","@tinkoff/express-terminus":"0.1.11","@tinkoff/monkeypatch":"1.3.3","@tinkoff/meta-tags-generate":"0.4.26","@tinkoff/error-handlers":"0.4.26","@tinkoff/measure-express-requests":"1.4.2","@tinkoff/browser-timings":"0.9.4","@tinkoff/mocker":"1.5.2","@tinkoff/metrics-noop":"1.0.2","@tramvai/http-client":"0.1.22","@tramvai/tinkoff-request-http-client-adapter":"0.8.148","@tinkoff/react-hooks":"0.0.23","@tinkoff/hook-runner":"0.3.21","@tinkoff/eslint-plugin-tramvai":"0.5.12","prettier-config-tinkoff":"0.1.9","@tinkoff/pack-polyfills":"0.2.39","@tinkoff/package-manager-wrapper":"0.0.1"}
92 changes: 92 additions & 0 deletions packages/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,29 @@
}
},
"additionalProperties": false
},
"fileSystemPages": {
"title": "experimental settings for File-System Routing feature",
"default": {},
"type": "object",
"properties": {
"enable": {
"title": "Read pages from file system",
"default": false,
"type": "boolean"
},
"staticPagesDir": {
"title": "Folder with pages",
"default": "pages",
"type": "string"
},
"externalPagesDir": {
"title": "Folder with pages",
"default": "external-pages",
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down Expand Up @@ -1272,6 +1295,29 @@
}
},
"additionalProperties": false
},
"fileSystemPages": {
"title": "experimental settings for File-System Routing feature",
"default": {},
"type": "object",
"properties": {
"enable": {
"title": "Read pages from file system",
"default": false,
"type": "boolean"
},
"staticPagesDir": {
"title": "Folder with pages",
"default": "pages",
"type": "string"
},
"externalPagesDir": {
"title": "Folder with pages",
"default": "external-pages",
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down Expand Up @@ -1704,6 +1750,29 @@
}
},
"additionalProperties": false
},
"fileSystemPages": {
"title": "experimental settings for File-System Routing feature",
"default": {},
"type": "object",
"properties": {
"enable": {
"title": "Read pages from file system",
"default": false,
"type": "boolean"
},
"staticPagesDir": {
"title": "Folder with pages",
"default": "pages",
"type": "string"
},
"externalPagesDir": {
"title": "Folder with pages",
"default": "external-pages",
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down Expand Up @@ -2020,6 +2089,29 @@
}
},
"additionalProperties": false
},
"fileSystemPages": {
"title": "experimental settings for File-System Routing feature",
"default": {},
"type": "object",
"properties": {
"enable": {
"title": "Read pages from file system",
"default": false,
"type": "boolean"
},
"staticPagesDir": {
"title": "Folder with pages",
"default": "pages",
"type": "string"
},
"externalPagesDir": {
"title": "Folder with pages",
"default": "external-pages",
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/api/start/utils/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ export function showBanner(di: Container) {

// Features
if (config.type !== 'application') {
titleLines.push(`${label('Type')} ${config.type}`);
titleLines.push(`${label('Type')} ${config.type}`);
}
titleLines.push(`${label('Modern')} ${config.modern}`);
titleLines.push(`${label('ReactRefresh')} ${config.hotRefresh}`);

if (config.build.configurations.experiments.fileSystemPages.enable) {
titleLines.push(`${label('FileSystemPages')} true`);
}
titleLines.push(`${label('Modern')} ${config.modern}`);
titleLines.push(`${label('ReactRefresh')} ${config.hotRefresh}`);

// Listeners
messageLines.push(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module '*.css' {
interface IClassNames {
[className: string]: string;
}
const classNames: IClassNames;
export = classNames;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"noUnusedLocals": true,
"noUnusedParameters": false,
"noEmitOnError": true,
"importHelpers": true
"importHelpers": true,
"skipLibCheck": true
}
}
12 changes: 12 additions & 0 deletions packages/cli/src/external/pages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface Page {
default?: any;
}

// eslint-disable-next-line import/no-default-export
export default {
staticPages: {},
externalPages: {},
} as {
staticPages: Record<string, Page>;
externalPages: Record<string, Page>;
};
15 changes: 14 additions & 1 deletion packages/cli/src/library/webpack/application/client/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,33 @@ import less from '../../blocks/less';
import css from '../../blocks/css';
import postcssAssets from '../../blocks/postcssAssets';
import nodeClient from '../../blocks/nodeClient';
import { pagesResolve } from '../../blocks/pagesResolve';
import { DEFAULT_STATS_OPTIONS, DEFAULT_STATS_FIELDS } from '../../constants/stats';
import { configToEnv } from '../../blocks/configToEnv';

export default (configManager: ConfigManager<ApplicationConfigEntry>) => (config: Config) => {
const { options: { polyfill = '', vendor = '' } = {} } = configManager.build;
const {
options: { polyfill = '', vendor = '' } = {},
configurations: {
experiments: { fileSystemPages },
},
} = configManager.build;

config.name('client');

config.batch(common(configManager));
config.batch(files(configManager));

if (fileSystemPages.enable) {
config.batch(pagesResolve(configManager));
}

const portal = path.resolve(configManager.rootDir, `packages/${process.env.APP_ID}/portal.js`);

config.target(configManager.modern ? 'web' : ['web', 'es5']);

config.batch(configToEnv(configManager));

config
.entry('platform')
.add(path.resolve(configManager.rootDir, `${configManager.root}/index`))
Expand Down
15 changes: 14 additions & 1 deletion packages/cli/src/library/webpack/application/server/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,30 @@ import ts from '../../blocks/ts';
import js from '../../blocks/js';
import css from '../../blocks/css';
import apiResolve from '../../blocks/apiResolve';
import { pagesResolve } from '../../blocks/pagesResolve';
import { serverInline } from '../../blocks/serverInline';
import { browserslistConfigResolve } from '../../blocks/browserslistConfig';
import { configToEnv } from '../../blocks/configToEnv';

// eslint-disable-next-line import/no-default-export
export default (configManager: ConfigManager<ApplicationConfigEntry>) => (config: Config) => {
const { options: { server = '', outputServer = '' } = {} } = configManager.build;
const {
options: { server = '', outputServer = '' } = {},
configurations: {
experiments: { fileSystemPages },
},
} = configManager.build;

config.name('server');

config.batch(common(configManager));
config.batch(files(configManager));
config.batch(apiResolve(configManager));

if (fileSystemPages.enable) {
config.batch(pagesResolve(configManager));
}

config.target('node');
config.output.libraryTarget('commonjs2');

Expand All @@ -49,6 +60,8 @@ export default (configManager: ConfigManager<ApplicationConfigEntry>) => (config
.use('ignore')
.loader('null-loader');

config.batch(configToEnv(configManager));

config.plugin('define').tap((args) => [
{
...args[0],
Expand Down
24 changes: 24 additions & 0 deletions packages/cli/src/library/webpack/blocks/configToEnv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type Config from 'webpack-chain';
import type { ConfigManager } from '../../../config/configManager';
import type { ApplicationConfigEntry } from '../../../typings/configEntry/application';

export const configToEnv = (configManager: ConfigManager<ApplicationConfigEntry>) => (
config: Config
) => {
const { fileSystemPages } = configManager.build.configurations.experiments;

config.plugin('define').tap((args) => [
{
...args[0],
'process.env.__TRAMVAI_EXPERIMENTAL_ENABLE_FILE_SYSTEM_PAGES': JSON.stringify(
fileSystemPages.enable
),
'process.env.__TRAMVAI_EXPERIMENTAL_STATIC_PAGES_DIR': JSON.stringify(
fileSystemPages.staticPagesDir
),
'process.env.__TRAMVAI_EXPERIMENTAL_EXTERNAL_PAGES_DIR': JSON.stringify(
fileSystemPages.externalPagesDir
),
},
]);
};
79 changes: 79 additions & 0 deletions packages/cli/src/library/webpack/blocks/pagesResolve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import path from 'path';
import type Config from 'webpack-chain';
import readDir from 'fs-readdir-recursive';
import type { ConfigManager } from '../../../config/configManager';
import type { ApplicationConfigEntry } from '../../../typings/configEntry/application';

const filesToPages = ({
configManager,
pagesRootDirectory,
config,
}: {
configManager: ConfigManager<ApplicationConfigEntry>;
pagesRootDirectory: string;
config: Config;
}) => {
const pagesDir = path.resolve(configManager.rootDir, configManager.root, pagesRootDirectory);

const pagesFiles = readDir(pagesDir);
const fsPages = [];

for (const file of pagesFiles) {
const extname = path.extname(file);
const name = file.replace(new RegExp(`\\${extname}$`), '').replace(/\\/g, '/');

if (config.resolve.extensions.has(extname)) {
const pageComponentName = `@/${pagesRootDirectory}/${name}`;
const pageComponentPath = path.resolve(pagesDir, name).replace(/\\/g, '\\\\');
const pageComponentChunkName = pageComponentName.replace(/\//g, '_');

// @example '@/pages/MainPage': lazy(() => import(/* webpackChunkName: "@_pages_MainPage" */ '/tramvai-app/src/pages/MainPage'))
fsPages.push(
`'${pageComponentName}': lazy(() => import(/* webpackChunkName: "${pageComponentChunkName}" */ '${pageComponentPath}'))`
);
}
}

return fsPages;
};

export const pagesResolve = (configManager: ConfigManager<ApplicationConfigEntry>) => (
config: Config
) => {
const { fileSystemPages } = configManager.build.configurations.experiments;

const staticFsPages = filesToPages({
config,
configManager,
pagesRootDirectory: fileSystemPages.staticPagesDir,
});
const externalFsPages = filesToPages({
config,
configManager,
pagesRootDirectory: fileSystemPages.externalPagesDir,
});

config.module
.rule('external-pages')
// [\\/]cli вместо @tramvai[\\/]cli, т.к. после слияния репозиториев tramvai и tramvai-cli,
// webpack резолвит симлинк с фактическим путем до packages/cli
// @todo: найти более надежный вариант, т.к. есть шанс, что будет импортироваться одноименный модуль
.test(/[\\/]cli[\\/]lib[\\/]external[\\/]pages.js$/)
.use('replace')
.loader(path.resolve(__dirname, '../loaders/replaceContent'))
.options({
code: `import { lazy } from '@tramvai/react';
export default {
staticPages: {
${staticFsPages.join(',\n')}
},
externalPages: {
${externalFsPages.join(',\n')}
},
}`,
})
.end()
// babel-loader is required to process this file
.enforce('pre');
};
Loading

0 comments on commit f395710

Please sign in to comment.