-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: o.drapeza <[email protected]> GitOrigin-RevId: 3fe0f6d04256993631378bf856b2ce0c9cbd51de
- Loading branch information
1 parent
01c7209
commit f395710
Showing
35 changed files
with
642 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/cli/src/commands/new/templates/block/typings.d.ts.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
), | ||
}, | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}; |
Oops, something went wrong.