@tramvai/cli 2.64.0 → 2.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -38
- package/lib/api/analyze/providers/shared.js +1 -1
- package/lib/api/analyze/providers/shared.js.map +1 -1
- package/lib/api/benchmark/index.d.ts +1 -1
- package/lib/api/build/child-app.js +3 -2
- package/lib/api/build/child-app.js.map +1 -1
- package/lib/api/build/module.js +1 -2
- package/lib/api/build/module.js.map +1 -1
- package/lib/api/build/providers/shared.js +1 -1
- package/lib/api/build/providers/shared.js.map +1 -1
- package/lib/api/index.d.ts +6 -2
- package/lib/api/index.js +3 -3
- package/lib/api/index.js.map +1 -1
- package/lib/api/shared/types/withConfig.d.ts +3 -2
- package/lib/api/start/providers/application/server.js +11 -18
- package/lib/api/start/providers/application/server.js.map +1 -1
- package/lib/api/start/providers/application/shared.js +17 -25
- package/lib/api/start/providers/application/shared.js.map +1 -1
- package/lib/api/start/providers/child-app/shared.js +19 -25
- package/lib/api/start/providers/child-app/shared.js.map +1 -1
- package/lib/api/start/providers/module/shared.js +18 -24
- package/lib/api/start/providers/module/shared.js.map +1 -1
- package/lib/api/start/utils/banner.js +3 -2
- package/lib/api/start/utils/banner.js.map +1 -1
- package/lib/api/start/utils/listenServer.js +3 -2
- package/lib/api/start/utils/listenServer.js.map +1 -1
- package/lib/api/start/utils/tips/tips.js +10 -8
- package/lib/api/start/utils/tips/tips.js.map +1 -1
- package/lib/api/start-prod/providers/application.js +6 -5
- package/lib/api/start-prod/providers/application.js.map +1 -1
- package/lib/api/start-prod/providers/child-app.js +3 -2
- package/lib/api/start-prod/providers/child-app.js.map +1 -1
- package/lib/api/start-prod/providers/shared.js +5 -13
- package/lib/api/start-prod/providers/shared.js.map +1 -1
- package/lib/builder/webpack/devServer/client.js +18 -15
- package/lib/builder/webpack/devServer/client.js.map +1 -1
- package/lib/builder/webpack/devServer/notifier.d.ts +2 -2
- package/lib/builder/webpack/devServer/notifier.js +3 -3
- package/lib/builder/webpack/devServer/notifier.js.map +1 -1
- package/lib/builder/webpack/devServer/pool/process/pool.js +3 -2
- package/lib/builder/webpack/devServer/pool/process/pool.js.map +1 -1
- package/lib/builder/webpack/devServer/pool/thread/pool.js +7 -0
- package/lib/builder/webpack/devServer/pool/thread/pool.js.map +1 -1
- package/lib/builder/webpack/devServer/server.js +7 -2
- package/lib/builder/webpack/devServer/server.js.map +1 -1
- package/lib/builder/webpack/providers/analyze/shared.js +3 -3
- package/lib/builder/webpack/providers/analyze/shared.js.map +1 -1
- package/lib/builder/webpack/providers/build/application/server.js.map +1 -1
- package/lib/builder/webpack/providers/build/client.js +3 -3
- package/lib/builder/webpack/providers/build/client.js.map +1 -1
- package/lib/builder/webpack/providers/build/server.js +1 -1
- package/lib/builder/webpack/providers/build/server.js.map +1 -1
- package/lib/builder/webpack/tokens.d.ts +313 -3
- package/lib/builder/webpack/tokens.js.map +1 -1
- package/lib/builder/webpack/utils/copyBuildFile.d.ts +2 -1
- package/lib/builder/webpack/utils/copyBuildFile.js +2 -3
- package/lib/builder/webpack/utils/copyBuildFile.js.map +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.d.ts +2 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.js +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.js.map +1 -1
- package/lib/cli/CLI.d.ts +2 -2
- package/lib/cli/CLI.js +2 -2
- package/lib/cli/CLI.js.map +1 -1
- package/lib/cli/index.js.map +1 -1
- package/lib/commands/analyze/command.d.ts +1 -1
- package/lib/commands/analyze/command.js.map +1 -1
- package/lib/commands/benchmark/command.d.ts +1 -1
- package/lib/commands/benchmark/command.js.map +1 -1
- package/lib/commands/build/command.d.ts +1 -1
- package/lib/commands/build/command.js.map +1 -1
- package/lib/commands/new/new.js +0 -1
- package/lib/commands/new/new.js.map +1 -1
- package/lib/commands/new/questions/packageManager.d.ts +1 -1
- package/lib/commands/new/questions/packageManager.js.map +1 -1
- package/lib/commands/new/questions/template.d.ts +1 -1
- package/lib/commands/new/questions/template.js.map +1 -1
- package/lib/commands/new/questions/testingFramework.d.ts +1 -1
- package/lib/commands/new/questions/testingFramework.js.map +1 -1
- package/lib/commands/new/questions/type.d.ts +1 -1
- package/lib/commands/new/questions/type.js.map +1 -1
- package/lib/commands/new/steps/initializationGit.d.ts +1 -1
- package/lib/commands/new/steps/initializationGit.js.map +1 -1
- package/lib/commands/start/command.d.ts +1 -1
- package/lib/commands/start/command.js.map +1 -1
- package/lib/commands/start-prod/command.d.ts +1 -1
- package/lib/commands/start-prod/command.js.map +1 -1
- package/lib/commands/static/application.js +4 -4
- package/lib/commands/static/application.js.map +1 -1
- package/lib/commands/static/command.d.ts +1 -1
- package/lib/commands/static/command.js.map +1 -1
- package/lib/commands/static/generate.js +2 -2
- package/lib/commands/static/generate.js.map +1 -1
- package/lib/commands/static/server.d.ts +2 -1
- package/lib/commands/static/server.js +1 -1
- package/lib/commands/static/server.js.map +1 -1
- package/lib/commands/static/staticServer.d.ts +2 -1
- package/lib/commands/static/staticServer.js +1 -1
- package/lib/commands/static/staticServer.js.map +1 -1
- package/lib/commands/update/updatePackageJson.js +3 -0
- package/lib/commands/update/updatePackageJson.js.map +1 -1
- package/lib/config/configManager.d.ts +15 -73
- package/lib/config/configManager.js +64 -92
- package/lib/config/configManager.js.map +1 -1
- package/lib/config/showConfig.d.ts +1 -1
- package/lib/config/showConfig.js +1 -1
- package/lib/config/showConfig.js.map +1 -1
- package/lib/config/validate.d.ts +5 -4
- package/lib/config/validate.js +2 -9
- package/lib/config/validate.js.map +1 -1
- package/lib/di/tokens/config.d.ts +106 -1
- package/lib/di/tokens/config.js.map +1 -1
- package/lib/external/config.d.ts +2 -2
- package/lib/library/babel/index.js +1 -0
- package/lib/library/babel/index.js.map +1 -1
- package/lib/library/swc/index.js +1 -1
- package/lib/library/swc/index.js.map +1 -1
- package/lib/library/webpack/application/client/common.js +6 -4
- package/lib/library/webpack/application/client/common.js.map +1 -1
- package/lib/library/webpack/application/client/dev.js +9 -8
- package/lib/library/webpack/application/client/dev.js.map +1 -1
- package/lib/library/webpack/application/client/prod/optimization/splitChunks.js +40 -39
- package/lib/library/webpack/application/client/prod/optimization/splitChunks.js.map +1 -1
- package/lib/library/webpack/application/client/prod.js +3 -4
- package/lib/library/webpack/application/client/prod.js.map +1 -1
- package/lib/library/webpack/application/server/common.js +5 -5
- package/lib/library/webpack/application/server/common.js.map +1 -1
- package/lib/library/webpack/application/server/dev.js +3 -6
- package/lib/library/webpack/application/server/dev.js.map +1 -1
- package/lib/library/webpack/application/server/prod.js +3 -4
- package/lib/library/webpack/application/server/prod.js.map +1 -1
- package/lib/library/webpack/blocks/apiResolve.js +1 -1
- package/lib/library/webpack/blocks/apiResolve.js.map +1 -1
- package/lib/library/webpack/blocks/configResolve.js +2 -2
- package/lib/library/webpack/blocks/configResolve.js.map +1 -1
- package/lib/library/webpack/blocks/configToEnv.js +5 -2
- package/lib/library/webpack/blocks/configToEnv.js.map +1 -1
- package/lib/library/webpack/blocks/css.d.ts +3 -1
- package/lib/library/webpack/blocks/css.js +17 -6
- package/lib/library/webpack/blocks/css.js.map +1 -1
- package/lib/library/webpack/blocks/extractCssPlugin.d.ts +4 -3
- package/lib/library/webpack/blocks/extractCssPlugin.js +4 -6
- package/lib/library/webpack/blocks/extractCssPlugin.js.map +1 -1
- package/lib/library/webpack/blocks/filesClient.d.ts +3 -2
- package/lib/library/webpack/blocks/filesClient.js +7 -7
- package/lib/library/webpack/blocks/filesClient.js.map +1 -1
- package/lib/library/webpack/blocks/filesServer.d.ts +2 -1
- package/lib/library/webpack/blocks/filesServer.js +3 -3
- package/lib/library/webpack/blocks/filesServer.js.map +1 -1
- package/lib/library/webpack/blocks/js.d.ts +2 -1
- package/lib/library/webpack/blocks/js.js +1 -1
- package/lib/library/webpack/blocks/js.js.map +1 -1
- package/lib/library/webpack/blocks/nodeClient.d.ts +2 -1
- package/lib/library/webpack/blocks/nodeClient.js +2 -2
- package/lib/library/webpack/blocks/nodeClient.js.map +1 -1
- package/lib/library/webpack/blocks/optimize.d.ts +2 -1
- package/lib/library/webpack/blocks/optimize.js +3 -3
- package/lib/library/webpack/blocks/optimize.js.map +1 -1
- package/lib/library/webpack/blocks/pagesResolve.js +1 -1
- package/lib/library/webpack/blocks/pagesResolve.js.map +1 -1
- package/lib/library/webpack/blocks/postcssAssets.d.ts +2 -1
- package/lib/library/webpack/blocks/postcssAssets.js +2 -2
- package/lib/library/webpack/blocks/postcssAssets.js.map +1 -1
- package/lib/library/webpack/blocks/serverInline.d.ts +2 -1
- package/lib/library/webpack/blocks/serverInline.js.map +1 -1
- package/lib/library/webpack/blocks/ts.d.ts +2 -1
- package/lib/library/webpack/blocks/ts.js.map +1 -1
- package/lib/library/webpack/child-app/client/common.d.ts +2 -2
- package/lib/library/webpack/child-app/client/common.js +1 -1
- package/lib/library/webpack/child-app/client/common.js.map +1 -1
- package/lib/library/webpack/child-app/client/dev.d.ts +2 -2
- package/lib/library/webpack/child-app/client/dev.js +6 -5
- package/lib/library/webpack/child-app/client/dev.js.map +1 -1
- package/lib/library/webpack/child-app/client/prod.d.ts +2 -2
- package/lib/library/webpack/child-app/client/prod.js.map +1 -1
- package/lib/library/webpack/child-app/common.d.ts +2 -2
- package/lib/library/webpack/child-app/common.js.map +1 -1
- package/lib/library/webpack/child-app/server/common.d.ts +2 -2
- package/lib/library/webpack/child-app/server/common.js +1 -1
- package/lib/library/webpack/child-app/server/common.js.map +1 -1
- package/lib/library/webpack/child-app/server/dev.d.ts +2 -2
- package/lib/library/webpack/child-app/server/dev.js.map +1 -1
- package/lib/library/webpack/child-app/server/prod.d.ts +2 -2
- package/lib/library/webpack/child-app/server/prod.js.map +1 -1
- package/lib/library/webpack/common/client/prod.d.ts +2 -1
- package/lib/library/webpack/common/client/prod.js +4 -5
- package/lib/library/webpack/common/client/prod.js.map +1 -1
- package/lib/library/webpack/common/main.d.ts +2 -1
- package/lib/library/webpack/common/main.js +3 -3
- package/lib/library/webpack/common/main.js.map +1 -1
- package/lib/library/webpack/common/server/prod.d.ts +2 -1
- package/lib/library/webpack/common/server/prod.js +4 -5
- package/lib/library/webpack/common/server/prod.js.map +1 -1
- package/lib/library/webpack/index.js +1 -2
- package/lib/library/webpack/index.js.map +1 -1
- package/lib/library/webpack/loaders/image-loader/index.d.ts +2 -1
- package/lib/library/webpack/loaders/image-loader/index.js.map +1 -1
- package/lib/library/webpack/loaders/pagesResolve.d.ts +10 -1
- package/lib/library/webpack/loaders/pagesResolve.js +4 -3
- package/lib/library/webpack/loaders/pagesResolve.js.map +1 -1
- package/lib/library/webpack/loaders/replaceContent.d.ts +6 -1
- package/lib/library/webpack/loaders/replaceContent.js +4 -3
- package/lib/library/webpack/loaders/replaceContent.js.map +1 -1
- package/lib/library/webpack/module/client/common.js +1 -1
- package/lib/library/webpack/module/client/common.js.map +1 -1
- package/lib/library/webpack/module/externals.d.ts +1 -1
- package/lib/library/webpack/module/externals.js.map +1 -1
- package/lib/library/webpack/module/resolveExternal.d.ts +1 -1
- package/lib/library/webpack/module/resolveExternal.js.map +1 -1
- package/lib/library/webpack/module/server/common.js +1 -1
- package/lib/library/webpack/module/server/common.js.map +1 -1
- package/lib/library/webpack/plugins/LazyModuleInitialization.d.ts +2 -2
- package/lib/library/webpack/plugins/LazyModuleInitialization.js +1 -0
- package/lib/library/webpack/plugins/LazyModuleInitialization.js.map +1 -1
- package/lib/library/webpack/plugins/WebpackBar/utils/index.d.ts +7 -7
- package/lib/library/webpack/plugins/WebpackBar/utils/index.js.map +1 -1
- package/lib/library/webpack/plugins/WebpackBar/utils/webpack.d.ts +2 -2
- package/lib/library/webpack/plugins/WebpackBar/utils/webpack.js.map +1 -1
- package/lib/library/webpack/types/webpack.d.ts +2 -2
- package/lib/library/webpack/utils/files.d.ts +4 -3
- package/lib/library/webpack/utils/files.js +2 -2
- package/lib/library/webpack/utils/files.js.map +1 -1
- package/lib/library/webpack/utils/transpiler.d.ts +3 -2
- package/lib/library/webpack/utils/transpiler.js +2 -2
- package/lib/library/webpack/utils/transpiler.js.map +1 -1
- package/lib/library/webpack/utils/workersPool.d.ts +3 -6
- package/lib/library/webpack/utils/workersPool.js +1 -1
- package/lib/library/webpack/utils/workersPool.js.map +1 -1
- package/lib/models/config.d.ts +2 -3
- package/lib/models/config.js +32 -3
- package/lib/models/config.js.map +1 -1
- package/lib/schema/ConfigSchema.d.ts +13 -4
- package/lib/schema/autogeneratedSchema.json +1808 -2074
- package/lib/typings/configEntry/application.d.ts +81 -86
- package/lib/typings/configEntry/child-app.d.ts +10 -29
- package/lib/typings/configEntry/cli.d.ts +254 -0
- package/lib/typings/configEntry/{CheckAsyncTsConfig.js → cli.js} +1 -1
- package/lib/typings/configEntry/cli.js.map +1 -0
- package/lib/typings/configEntry/common.d.ts +16 -276
- package/lib/typings/configEntry/common.js +15 -0
- package/lib/typings/configEntry/common.js.map +1 -1
- package/lib/typings/configEntry/module.d.ts +10 -29
- package/lib/typings/configEntry/package.d.ts +2 -1
- package/lib/ui/commander.js +1 -1
- package/lib/ui/commander.js.map +1 -1
- package/lib/utils/applyTemplate.js.map +1 -1
- package/lib/utils/detectPortSync.d.ts +1 -0
- package/lib/utils/detectPortSync.js +10 -0
- package/lib/utils/detectPortSync.js.map +1 -0
- package/lib/utils/safeRequire.js +5 -1
- package/lib/utils/safeRequire.js.map +1 -1
- package/lib/utils/webpackBuild.d.ts +2 -1
- package/lib/utils/webpackBuild.js +3 -3
- package/lib/utils/webpackBuild.js.map +1 -1
- package/package.json +14 -9
- package/schema.json +1802 -2068
- package/src/api/analyze/providers/shared.ts +3 -2
- package/src/api/benchmark/__integration__/__fixtures__/tramvai.json +1 -8
- package/src/api/benchmark/index.ts +1 -1
- package/src/api/build/__integration__/__fixtures__/app/App.tsx +0 -1
- package/src/api/build/__integration__/__fixtures__/app/index.tsx +14 -8
- package/src/api/build/__integration__/__fixtures__/app/server.tsx +0 -1
- package/src/api/build/__integration__/__fixtures__/tramvai.json +1 -10
- package/src/api/build/__integration__/build.test.ts +4 -13
- package/src/api/build/child-app.ts +4 -4
- package/src/api/build/module.ts +2 -4
- package/src/api/build/providers/shared.ts +2 -2
- package/src/api/index.ts +6 -2
- package/src/api/shared/types/withConfig.ts +5 -6
- package/src/api/start/__integration__/__fixtures__/app/index.tsx +11 -7
- package/src/api/start/__integration__/__fixtures__/tramvai.json +6 -17
- package/src/api/start/__integration__/start.test.ts +38 -13
- package/src/api/start/providers/application/server.ts +14 -23
- package/src/api/start/providers/application/shared.ts +26 -52
- package/src/api/start/providers/child-app/shared.ts +23 -46
- package/src/api/start/providers/module/shared.ts +24 -47
- package/src/api/start/utils/banner.ts +3 -2
- package/src/api/start/utils/listenServer.ts +2 -1
- package/src/api/start/utils/tips/tips.ts +11 -8
- package/src/api/start-prod/providers/application.ts +19 -19
- package/src/api/start-prod/providers/child-app.ts +7 -8
- package/src/api/start-prod/providers/shared.ts +6 -20
- package/src/builder/webpack/devServer/client.ts +22 -15
- package/src/builder/webpack/devServer/notifier.ts +6 -6
- package/src/builder/webpack/devServer/pool/process/pool.ts +3 -3
- package/src/builder/webpack/devServer/pool/thread/pool.ts +7 -0
- package/src/builder/webpack/devServer/server.ts +13 -6
- package/src/builder/webpack/providers/analyze/shared.ts +3 -2
- package/src/builder/webpack/providers/build/application/server.ts +5 -1
- package/src/builder/webpack/providers/build/client.ts +2 -2
- package/src/builder/webpack/providers/build/server.ts +1 -1
- package/src/builder/webpack/tokens.ts +4 -3
- package/src/builder/webpack/utils/copyBuildFile.ts +4 -5
- package/src/builder/webpack/utils/copyStatsJsonFile.ts +5 -2
- package/src/cli/CLI.ts +6 -6
- package/src/cli/index.ts +1 -1
- package/src/commands/analyze/command.ts +1 -1
- package/src/commands/benchmark/command.ts +1 -1
- package/src/commands/build/command.ts +2 -2
- package/src/commands/new/new.ts +0 -1
- package/src/commands/new/questions/packageManager.ts +1 -1
- package/src/commands/new/questions/template.ts +1 -1
- package/src/commands/new/questions/testingFramework.ts +1 -1
- package/src/commands/new/questions/type.ts +1 -1
- package/src/commands/new/steps/initializationGit.ts +1 -1
- package/src/commands/new/templates/app/monorepo/tramvai.json.hbs +6 -32
- package/src/commands/new/templates/app/multirepo/tramvai.json.hbs +6 -23
- package/src/commands/new/templates/child-app/monorepo/tramvai.json.hbs +3 -18
- package/src/commands/new/templates/child-app/multirepo/tramvai.json.hbs +3 -9
- package/src/commands/start/command.ts +2 -2
- package/src/commands/start-prod/command.ts +2 -2
- package/src/commands/static/application.ts +5 -14
- package/src/commands/static/command.ts +1 -1
- package/src/commands/static/generate.ts +2 -2
- package/src/commands/static/server.ts +5 -2
- package/src/commands/static/staticServer.ts +6 -3
- package/src/commands/update/updatePackageJson.ts +6 -2
- package/src/config/configManager.spec.ts +49 -0
- package/src/config/configManager.ts +129 -197
- package/src/config/showConfig.ts +2 -2
- package/src/config/validate.ts +14 -25
- package/src/di/tokens/config.ts +2 -1
- package/src/library/babel/index.ts +1 -0
- package/src/library/swc/__integration__/swc.build.test.ts +3 -21
- package/src/library/swc/__integration__/swc.start.test.ts +3 -21
- package/src/library/swc/index.ts +1 -1
- package/src/library/webpack/application/client/common.ts +7 -7
- package/src/library/webpack/application/client/dev.ts +9 -9
- package/src/library/webpack/application/client/prod/optimization/splitChunks.ts +43 -44
- package/src/library/webpack/application/client/prod.ts +3 -5
- package/src/library/webpack/application/server/common.ts +5 -8
- package/src/library/webpack/application/server/dev.ts +5 -6
- package/src/library/webpack/application/server/prod.ts +3 -9
- package/src/library/webpack/blocks/apiResolve.ts +1 -1
- package/src/library/webpack/blocks/configResolve.ts +2 -2
- package/src/library/webpack/blocks/configToEnv.ts +5 -2
- package/src/library/webpack/blocks/css.ts +26 -17
- package/src/library/webpack/blocks/extractCssPlugin.ts +11 -10
- package/src/library/webpack/blocks/filesClient.ts +52 -50
- package/src/library/webpack/blocks/filesServer.ts +4 -3
- package/src/library/webpack/blocks/js.ts +3 -2
- package/src/library/webpack/blocks/nodeClient.ts +4 -3
- package/src/library/webpack/blocks/optimize.ts +5 -6
- package/src/library/webpack/blocks/pagesResolve.ts +1 -1
- package/src/library/webpack/blocks/postcssAssets.ts +6 -7
- package/src/library/webpack/blocks/serverInline.ts +2 -1
- package/src/library/webpack/blocks/ts.ts +2 -1
- package/src/library/webpack/child-app/client/common.ts +3 -3
- package/src/library/webpack/child-app/client/dev.ts +8 -8
- package/src/library/webpack/child-app/client/prod.ts +2 -2
- package/src/library/webpack/child-app/common.ts +2 -2
- package/src/library/webpack/child-app/server/common.ts +3 -3
- package/src/library/webpack/child-app/server/dev.ts +2 -2
- package/src/library/webpack/child-app/server/prod.ts +2 -2
- package/src/library/webpack/common/client/prod.ts +10 -6
- package/src/library/webpack/common/main.ts +9 -4
- package/src/library/webpack/common/server/prod.ts +10 -6
- package/src/library/webpack/index.ts +2 -3
- package/src/library/webpack/loaders/image-loader/index.ts +2 -1
- package/src/library/webpack/loaders/pagesResolve.ts +17 -5
- package/src/library/webpack/loaders/replaceContent.ts +11 -2
- package/src/library/webpack/module/client/common.ts +1 -1
- package/src/library/webpack/module/externals.ts +1 -1
- package/src/library/webpack/module/resolveExternal.ts +1 -1
- package/src/library/webpack/module/server/common.ts +1 -1
- package/src/library/webpack/plugins/LazyModuleInitialization.ts +6 -1
- package/src/library/webpack/plugins/WebpackBar/utils/index.ts +8 -8
- package/src/library/webpack/plugins/WebpackBar/utils/webpack.ts +1 -1
- package/src/library/webpack/types/webpack.ts +2 -2
- package/src/library/webpack/utils/files.ts +4 -3
- package/src/library/webpack/utils/transpiler.ts +6 -11
- package/src/library/webpack/utils/workersPool.ts +6 -9
- package/src/models/config.spec.ts +352 -0
- package/src/models/config.ts +41 -9
- package/src/schema/ConfigSchema.ts +15 -4
- package/src/schema/autogeneratedSchema.json +1808 -2074
- package/src/schema/tramvai.spec.ts +89 -184
- package/src/typings/configEntry/application.ts +85 -87
- package/src/typings/configEntry/child-app.ts +10 -30
- package/src/typings/configEntry/cli.ts +271 -0
- package/src/typings/configEntry/common.ts +26 -278
- package/src/typings/configEntry/module.ts +11 -30
- package/src/typings/configEntry/package.ts +3 -1
- package/src/ui/commander.ts +1 -1
- package/src/utils/applyTemplate.ts +2 -2
- package/src/utils/detectPortSync.ts +7 -0
- package/src/utils/safeRequire.ts +6 -1
- package/src/utils/webpackBuild.ts +4 -3
- package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.d.ts +0 -37
- package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.js +0 -241
- package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.js.map +0 -1
- package/lib/library/webpack/plugins/DedupePlugin/index.d.ts +0 -1
- package/lib/library/webpack/plugins/DedupePlugin/index.js +0 -6
- package/lib/library/webpack/plugins/DedupePlugin/index.js.map +0 -1
- package/lib/typings/configEntry/CheckAsyncTsConfig.d.ts +0 -13
- package/lib/typings/configEntry/CheckAsyncTsConfig.js.map +0 -1
- package/src/library/webpack/plugins/DedupePlugin/DedupePlugin.spec.ts +0 -95
- package/src/library/webpack/plugins/DedupePlugin/DedupePlugin.ts +0 -307
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/node_modules/package-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/node_modules/package-dep/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-1/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/node_modules/package-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/node_modules/package-dep/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-2/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/node_modules/package-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/node_modules/package-dep/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-3/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-dep/package.json +0 -7
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/node_modules/package-esm-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/node_modules/package-esm-dep/package.json +0 -8
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-1/package.json +0 -8
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/index.js +0 -3
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/node_modules/package-esm-dep/index.js +0 -1
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/node_modules/package-esm-dep/package.json +0 -8
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/node_modules/package-esm-2/package.json +0 -8
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/package-lock.json +0 -0
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/package.json +0 -14
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/src/index.js +0 -9
- package/src/library/webpack/plugins/DedupePlugin/__fixtures__/dedupe/tramvai.json +0 -67
- package/src/library/webpack/plugins/DedupePlugin/__integration__/DedupePlugin.test.ts +0 -90
- package/src/library/webpack/plugins/DedupePlugin/index.ts +0 -1
- package/src/typings/configEntry/CheckAsyncTsConfig.ts +0 -15
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ConfigEntry } from '../typings/configEntry/common';
|
|
2
|
+
import { createConfigManager } from './configManager';
|
|
3
|
+
|
|
4
|
+
jest.mock('./validate', () => {
|
|
5
|
+
const original = jest.requireActual('./validate');
|
|
6
|
+
|
|
7
|
+
return { ...original, validate: () => true };
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const configEntry: ConfigEntry & Record<string, any> = {
|
|
11
|
+
name: 'test',
|
|
12
|
+
root: 'src',
|
|
13
|
+
type: 'package',
|
|
14
|
+
optionBoolean: false,
|
|
15
|
+
optionString: 'str',
|
|
16
|
+
optionOverride: {
|
|
17
|
+
development: '123',
|
|
18
|
+
production: '456',
|
|
19
|
+
},
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
it('should pass configEntry options', () => {
|
|
23
|
+
const configManager = createConfigManager(configEntry, {});
|
|
24
|
+
|
|
25
|
+
expect(configManager.optionBoolean).toBe(false);
|
|
26
|
+
expect(configManager.optionString).toBe('str');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('should resolve settings depending on env', () => {
|
|
30
|
+
it('development', () => {
|
|
31
|
+
const configManager = createConfigManager(configEntry, { env: 'development' });
|
|
32
|
+
|
|
33
|
+
expect(configManager.optionOverride).toEqual('123');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('production', () => {
|
|
37
|
+
const configManager = createConfigManager(configEntry, { env: 'production' });
|
|
38
|
+
|
|
39
|
+
expect(configManager.optionOverride).toBe('456');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('hydration', () => {
|
|
44
|
+
const configManager = createConfigManager(configEntry, {});
|
|
45
|
+
|
|
46
|
+
const rehydrated = createConfigManager(...configManager.dehydrate());
|
|
47
|
+
|
|
48
|
+
expect(JSON.stringify(rehydrated)).toEqual(JSON.stringify(configManager));
|
|
49
|
+
});
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import isNil from '@tinkoff/utils/is/nil';
|
|
2
|
+
import isArray from '@tinkoff/utils/is/array';
|
|
3
|
+
import isObject from '@tinkoff/utils/is/object';
|
|
2
4
|
import prop from '@tinkoff/utils/object/prop';
|
|
5
|
+
import mapObj from '@tinkoff/utils/object/map';
|
|
3
6
|
import { resolve } from 'path';
|
|
4
|
-
import type {
|
|
7
|
+
import type { BuildType } from '../typings/projectType';
|
|
5
8
|
import type { Env } from '../typings/Env';
|
|
6
|
-
import type { ConfigEntry } from '../typings/configEntry/common';
|
|
7
|
-
import {
|
|
9
|
+
import type { ConfigEntry, OverridableOption } from '../typings/configEntry/common';
|
|
10
|
+
import { isOverridableOption } from '../typings/configEntry/common';
|
|
11
|
+
import { isApplication, isChildApp, isModule, validate } from './validate';
|
|
8
12
|
import moduleVersion from '../utils/moduleVersion';
|
|
9
13
|
import { packageVersion } from '../utils/packageVersion';
|
|
10
|
-
import type { DeduplicateStrategy } from '../library/webpack/plugins/DedupePlugin';
|
|
11
14
|
import { showConfig } from './showConfig';
|
|
12
15
|
import type { Target } from '../typings/target';
|
|
13
16
|
|
|
17
|
+
// @TODO: maybe split settings depending on env?
|
|
14
18
|
export interface Settings<E extends Env> {
|
|
15
19
|
env?: E;
|
|
16
20
|
rootDir?: string;
|
|
@@ -18,7 +22,6 @@ export interface Settings<E extends Env> {
|
|
|
18
22
|
buildType?: BuildType;
|
|
19
23
|
debug?: boolean;
|
|
20
24
|
trace?: boolean;
|
|
21
|
-
removeTypeofWindow?: boolean;
|
|
22
25
|
sourceMap?: boolean;
|
|
23
26
|
host?: string;
|
|
24
27
|
port?: number;
|
|
@@ -37,7 +40,7 @@ export interface Settings<E extends Env> {
|
|
|
37
40
|
csr?: boolean;
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
const getOption = <T>(optionName: string, cfgs: any[], dflt
|
|
43
|
+
const getOption = <T>(optionName: string, cfgs: any[], dflt: T): T => {
|
|
41
44
|
const getter = prop(optionName);
|
|
42
45
|
|
|
43
46
|
for (let i = 0; i < cfgs.length; i++) {
|
|
@@ -51,207 +54,136 @@ const getOption = <T>(optionName: string, cfgs: any[], dflt?: T): T => {
|
|
|
51
54
|
return dflt;
|
|
52
55
|
};
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
public type: ProjectType;
|
|
62
|
-
|
|
63
|
-
public root: string;
|
|
64
|
-
|
|
65
|
-
public build: T['commands']['build'];
|
|
66
|
-
|
|
67
|
-
public serve: T['commands']['serve'];
|
|
68
|
-
|
|
69
|
-
private settings: Settings<E>;
|
|
70
|
-
|
|
71
|
-
public version: string;
|
|
72
|
-
|
|
73
|
-
public env: E;
|
|
74
|
-
|
|
75
|
-
public buildType: BuildType;
|
|
76
|
-
|
|
77
|
-
public rootDir: string;
|
|
78
|
-
|
|
79
|
-
public debug: boolean;
|
|
80
|
-
|
|
81
|
-
public trace: boolean;
|
|
82
|
-
|
|
83
|
-
public sourceMap: boolean;
|
|
84
|
-
|
|
85
|
-
public host: string;
|
|
86
|
-
|
|
87
|
-
public port: number;
|
|
88
|
-
|
|
89
|
-
public staticHost: string;
|
|
90
|
-
|
|
91
|
-
public staticPort: number;
|
|
92
|
-
|
|
93
|
-
public profile: boolean;
|
|
94
|
-
|
|
95
|
-
public noServerRebuild: boolean;
|
|
96
|
-
|
|
97
|
-
public noClientRebuild: boolean;
|
|
98
|
-
|
|
99
|
-
public modern: boolean;
|
|
100
|
-
|
|
101
|
-
public dedupe: DeduplicateStrategy | false;
|
|
102
|
-
|
|
103
|
-
public dedupeIgnore?: RegExp[];
|
|
104
|
-
|
|
105
|
-
public removeTypeofWindow: boolean;
|
|
106
|
-
|
|
107
|
-
public resolveSymlinks: boolean;
|
|
108
|
-
|
|
109
|
-
public hotRefresh: boolean;
|
|
110
|
-
|
|
111
|
-
public disableProdOptimization: boolean;
|
|
112
|
-
|
|
113
|
-
public target: Target;
|
|
114
|
-
|
|
115
|
-
public fileCache: boolean;
|
|
116
|
-
|
|
117
|
-
public experiments: T['commands'][E extends 'development'
|
|
118
|
-
? 'serve'
|
|
119
|
-
: 'build']['configurations']['experiments'];
|
|
120
|
-
|
|
121
|
-
public showConfig: boolean;
|
|
122
|
-
|
|
123
|
-
public csr: boolean;
|
|
124
|
-
|
|
125
|
-
// eslint-disable-next-line complexity,max-statements
|
|
126
|
-
constructor(configEntry: T, settings: Settings<E>) {
|
|
127
|
-
this.configEntry = configEntry;
|
|
128
|
-
this.name = configEntry.name;
|
|
129
|
-
this.type = configEntry.type;
|
|
130
|
-
this.root = configEntry.root;
|
|
131
|
-
this.build = configEntry.commands.build || {};
|
|
132
|
-
this.serve = configEntry.commands.serve || {};
|
|
133
|
-
|
|
134
|
-
this.settings = settings;
|
|
135
|
-
this.env = settings.env || ('development' as E);
|
|
136
|
-
this.rootDir = settings.rootDir || process.cwd();
|
|
137
|
-
this.version =
|
|
138
|
-
settings.version ||
|
|
139
|
-
(this.type === 'module' ? moduleVersion(configEntry) : '') ||
|
|
140
|
-
(this.type === 'child-app' ? packageVersion(configEntry, this.env, this.rootDir) : '');
|
|
141
|
-
this.buildType = settings.buildType || 'client';
|
|
142
|
-
this.debug = settings.debug || false;
|
|
143
|
-
this.trace = settings.trace || false;
|
|
144
|
-
this.sourceMap =
|
|
145
|
-
this.buildType === 'server' && this.debug
|
|
146
|
-
? true
|
|
147
|
-
: getOption(
|
|
148
|
-
'sourceMap',
|
|
149
|
-
[
|
|
150
|
-
settings,
|
|
151
|
-
this.env === 'development' ? this.serve.configurations : this.build.configurations,
|
|
152
|
-
],
|
|
153
|
-
false
|
|
154
|
-
);
|
|
155
|
-
this.host = settings.host || '0.0.0.0';
|
|
156
|
-
this.port = Number(settings.port ?? 3000);
|
|
157
|
-
this.staticHost = settings.staticHost || 'localhost';
|
|
158
|
-
this.staticPort = Number(settings.staticPort ?? (this.type === 'module' ? 4040 : 4000));
|
|
159
|
-
this.profile = settings.profile || false;
|
|
160
|
-
this.noServerRebuild = settings.noServerRebuild || false;
|
|
161
|
-
this.noClientRebuild = settings.noClientRebuild || false;
|
|
162
|
-
this.modern = getOption(
|
|
163
|
-
'modern',
|
|
164
|
-
[
|
|
165
|
-
settings,
|
|
166
|
-
this.env === 'development' ? this.serve.configurations : this.build.configurations,
|
|
167
|
-
],
|
|
168
|
-
true
|
|
169
|
-
);
|
|
170
|
-
this.dedupe = this.build.configurations?.dedupe;
|
|
171
|
-
this.dedupeIgnore = this.build.configurations?.dedupeIgnore?.map(
|
|
172
|
-
(ignore) => new RegExp(`^${ignore}`)
|
|
173
|
-
);
|
|
174
|
-
this.removeTypeofWindow = this.build.configurations?.removeTypeofWindow;
|
|
175
|
-
this.resolveSymlinks = settings.resolveSymlinks ?? true;
|
|
176
|
-
this.hotRefresh = this.env === 'development' && this.serve.configurations?.hotRefresh;
|
|
177
|
-
this.disableProdOptimization = settings.disableProdOptimization ?? false;
|
|
178
|
-
this.onlyBundles = settings.onlyBundles;
|
|
179
|
-
this.target = this.resolveTarget();
|
|
180
|
-
// according to measures fileCache in webpack doesn't affect
|
|
181
|
-
// performance much so enable it by default as it always was before
|
|
182
|
-
this.fileCache = settings.fileCache ?? true;
|
|
183
|
-
this.experiments =
|
|
184
|
-
(this.env === 'development'
|
|
185
|
-
? this.serve.configurations?.experiments
|
|
186
|
-
: this.build.configurations?.experiments) ?? {};
|
|
187
|
-
this.showConfig = settings.showConfig ?? false;
|
|
188
|
-
this.csr = settings.csr ?? false;
|
|
57
|
+
type OmitOverridable<T extends Record<string, any>> = {
|
|
58
|
+
[key in keyof T]: T[key] extends OverridableOption<infer U>
|
|
59
|
+
? U
|
|
60
|
+
: T[key] extends Record<string, any>
|
|
61
|
+
? OmitOverridable<T[key]>
|
|
62
|
+
: T[key];
|
|
63
|
+
};
|
|
189
64
|
|
|
190
|
-
|
|
191
|
-
|
|
65
|
+
const omitEnvOptions = <T extends Record<string, any>>(
|
|
66
|
+
env: Env,
|
|
67
|
+
options: T
|
|
68
|
+
): OmitOverridable<T> => {
|
|
69
|
+
return mapObj((value) => {
|
|
70
|
+
if (isOverridableOption(value)) {
|
|
71
|
+
return value[env];
|
|
192
72
|
}
|
|
193
73
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
public onlyBundles: string[];
|
|
198
|
-
|
|
199
|
-
getBuildPath() {
|
|
200
|
-
switch (this.type) {
|
|
201
|
-
case 'application':
|
|
202
|
-
return resolve(
|
|
203
|
-
this.rootDir,
|
|
204
|
-
this.buildType === 'server'
|
|
205
|
-
? this.build.options.outputServer
|
|
206
|
-
: this.build.options.outputClient
|
|
207
|
-
);
|
|
208
|
-
case 'module':
|
|
209
|
-
return resolve(
|
|
210
|
-
this.rootDir,
|
|
211
|
-
...this.build.options.output.split('/'),
|
|
212
|
-
this.name,
|
|
213
|
-
this.version
|
|
214
|
-
);
|
|
215
|
-
case 'child-app':
|
|
216
|
-
return resolve(this.rootDir, ...this.build.options.output.split('/'));
|
|
74
|
+
if (isObject(value) && !isArray(value)) {
|
|
75
|
+
return omitEnvOptions(env, value);
|
|
217
76
|
}
|
|
218
77
|
|
|
219
|
-
|
|
220
|
-
}
|
|
78
|
+
return value;
|
|
79
|
+
}, options);
|
|
80
|
+
};
|
|
221
81
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
82
|
+
export type ConfigManager<
|
|
83
|
+
C extends ConfigEntry = ConfigEntry,
|
|
84
|
+
E extends Env = Env
|
|
85
|
+
> = OmitOverridable<C> &
|
|
86
|
+
Required<Settings<E>> & {
|
|
87
|
+
target: Target;
|
|
88
|
+
buildPath: string;
|
|
89
|
+
withSettings(settings: Settings<E>): ConfigManager<C, E>;
|
|
90
|
+
dehydrate(): [C, Settings<E>];
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const DEFAULT_PORT = 3000;
|
|
94
|
+
export const DEFAULT_STATIC_PORT = 4000;
|
|
95
|
+
export const DEFAULT_STATIC_MODULE_PORT = 4040;
|
|
96
|
+
|
|
97
|
+
export const createConfigManager = <C extends ConfigEntry = ConfigEntry, E extends Env = Env>(
|
|
98
|
+
configEntry: C,
|
|
99
|
+
settings: Settings<E>
|
|
100
|
+
): ConfigManager<C, E> => {
|
|
101
|
+
const env: E = settings.env ?? ('development' as E);
|
|
102
|
+
const normalizedConfigEntry = omitEnvOptions(env, configEntry);
|
|
103
|
+
|
|
104
|
+
const { type } = configEntry;
|
|
105
|
+
const rootDir = settings.rootDir ?? process.cwd();
|
|
106
|
+
const debug = settings.debug ?? false;
|
|
107
|
+
const modern = getOption('modern', [settings, configEntry], true);
|
|
108
|
+
const buildType = settings.buildType ?? 'client';
|
|
109
|
+
let target: Target = 'defaults';
|
|
110
|
+
|
|
111
|
+
if (buildType === 'server') {
|
|
112
|
+
target = 'node';
|
|
113
|
+
} else if (modern) {
|
|
114
|
+
target = 'modern';
|
|
227
115
|
}
|
|
228
116
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
117
|
+
const config: ConfigManager<C, E> = {
|
|
118
|
+
...normalizedConfigEntry,
|
|
119
|
+
version:
|
|
120
|
+
(type === 'module' ? moduleVersion(configEntry) : '') ||
|
|
121
|
+
(type === 'child-app' ? packageVersion(configEntry, env, rootDir) : ''),
|
|
122
|
+
trace: false,
|
|
123
|
+
host: '0.0.0.0',
|
|
124
|
+
staticHost: 'localhost',
|
|
125
|
+
profile: false,
|
|
126
|
+
noClientRebuild: false,
|
|
127
|
+
noServerRebuild: false,
|
|
128
|
+
resolveSymlinks: true,
|
|
129
|
+
disableProdOptimization: false,
|
|
130
|
+
onlyBundles: [],
|
|
131
|
+
// according to measures fileCache in webpack doesn't affect
|
|
132
|
+
// performance much so enable it by default as it always was before
|
|
133
|
+
fileCache: true,
|
|
134
|
+
showConfig: false,
|
|
135
|
+
csr: false,
|
|
136
|
+
...settings,
|
|
137
|
+
env,
|
|
138
|
+
rootDir,
|
|
139
|
+
buildType,
|
|
140
|
+
debug,
|
|
141
|
+
port: Number(settings.port ?? DEFAULT_PORT),
|
|
142
|
+
staticPort: Number(
|
|
143
|
+
settings.staticPort ?? (type === 'module' ? DEFAULT_STATIC_MODULE_PORT : DEFAULT_STATIC_PORT)
|
|
144
|
+
),
|
|
145
|
+
modern,
|
|
146
|
+
sourceMap:
|
|
147
|
+
buildType === 'server' && debug
|
|
148
|
+
? true
|
|
149
|
+
: getOption('sourceMap', [settings, normalizedConfigEntry], false),
|
|
150
|
+
target,
|
|
151
|
+
buildPath: '',
|
|
152
|
+
withSettings(overrideSettings) {
|
|
153
|
+
return createConfigManager(configEntry, {
|
|
154
|
+
...settings,
|
|
155
|
+
...overrideSettings,
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
dehydrate() {
|
|
159
|
+
return [
|
|
160
|
+
configEntry,
|
|
161
|
+
{
|
|
162
|
+
...settings,
|
|
163
|
+
// drop options that couldn't be serialized
|
|
164
|
+
stdout: undefined,
|
|
165
|
+
stderr: undefined,
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
if (isApplication(config)) {
|
|
172
|
+
config.buildPath = resolve(
|
|
173
|
+
rootDir,
|
|
174
|
+
buildType === 'server' ? config.output.server : config.output.client
|
|
175
|
+
);
|
|
176
|
+
} else if (isChildApp(config)) {
|
|
177
|
+
config.buildPath = resolve(rootDir, ...config.output.split('/'));
|
|
178
|
+
} else if (isModule(config)) {
|
|
179
|
+
config.buildPath = resolve(rootDir, ...config.output.split('/'), config.name, config.version);
|
|
240
180
|
}
|
|
241
181
|
|
|
242
|
-
|
|
243
|
-
|
|
182
|
+
if (config.showConfig) {
|
|
183
|
+
showConfig(config);
|
|
244
184
|
}
|
|
245
185
|
|
|
246
|
-
|
|
247
|
-
if (this.buildType === 'server') {
|
|
248
|
-
return 'node';
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (this.modern) {
|
|
252
|
-
return 'modern';
|
|
253
|
-
}
|
|
186
|
+
validate(config);
|
|
254
187
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
188
|
+
return config;
|
|
189
|
+
};
|
package/src/config/showConfig.ts
CHANGED
|
@@ -4,8 +4,8 @@ import chalk from 'chalk';
|
|
|
4
4
|
import type { ConfigManager } from './configManager';
|
|
5
5
|
import { box } from '../utils/formatting';
|
|
6
6
|
|
|
7
|
-
export const showConfig = (configManager: ConfigManager) => {
|
|
8
|
-
const configStr = prettyoutput(omit(['
|
|
7
|
+
export const showConfig = (configManager: ConfigManager<any, any>) => {
|
|
8
|
+
const configStr = prettyoutput(omit(['options'], configManager), {
|
|
9
9
|
hideUndefined: true,
|
|
10
10
|
maxDepth: Infinity,
|
|
11
11
|
});
|
package/src/config/validate.ts
CHANGED
|
@@ -3,24 +3,25 @@ import { sync as requireResolve } from 'resolve';
|
|
|
3
3
|
import type { ConfigManager } from './configManager';
|
|
4
4
|
import type { ApplicationConfigEntry } from '../typings/configEntry/application';
|
|
5
5
|
import type { ModuleConfigEntry } from '../typings/configEntry/module';
|
|
6
|
-
import { extensions } from './constants';
|
|
7
6
|
import type { ChildAppConfigEntry } from '../typings/configEntry/child-app';
|
|
7
|
+
import { extensions } from './constants';
|
|
8
|
+
import type { Env } from '../typings/Env';
|
|
8
9
|
|
|
9
|
-
export const isApplication = (
|
|
10
|
-
configManager: ConfigManager
|
|
11
|
-
): configManager is ConfigManager<ApplicationConfigEntry> => {
|
|
10
|
+
export const isApplication = <E extends Env>(
|
|
11
|
+
configManager: ConfigManager<any, E>
|
|
12
|
+
): configManager is ConfigManager<ApplicationConfigEntry, E> => {
|
|
12
13
|
return configManager.type === 'application';
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
export const isModule = (
|
|
16
|
-
configManager: ConfigManager
|
|
17
|
-
): configManager is ConfigManager<ModuleConfigEntry> => {
|
|
16
|
+
export const isModule = <E extends Env>(
|
|
17
|
+
configManager: ConfigManager<any, E>
|
|
18
|
+
): configManager is ConfigManager<ModuleConfigEntry, E> => {
|
|
18
19
|
return configManager.type === 'module';
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
export const isChildApp = (
|
|
22
|
-
configManager: ConfigManager
|
|
23
|
-
): configManager is ConfigManager<ChildAppConfigEntry> => {
|
|
22
|
+
export const isChildApp = <E extends Env>(
|
|
23
|
+
configManager: ConfigManager<any, E>
|
|
24
|
+
): configManager is ConfigManager<ChildAppConfigEntry, E> => {
|
|
24
25
|
return configManager.type === 'child-app';
|
|
25
26
|
};
|
|
26
27
|
|
|
@@ -28,7 +29,7 @@ const throwErrorMissing = (config: string, path: string) => {
|
|
|
28
29
|
throw new Error(`Can not resolve '${path}', check your configuration: '${config}'`);
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
export const validate = (configManager: ConfigManager) => {
|
|
32
|
+
export const validate = (configManager: ConfigManager<any, any>) => {
|
|
32
33
|
const { rootDir } = configManager;
|
|
33
34
|
|
|
34
35
|
const isMissing = (path: string) => {
|
|
@@ -43,27 +44,15 @@ export const validate = (configManager: ConfigManager) => {
|
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
if (isApplication(configManager)) {
|
|
46
|
-
const {
|
|
47
|
-
root,
|
|
48
|
-
buildType,
|
|
49
|
-
build: { options },
|
|
50
|
-
} = configManager;
|
|
47
|
+
const { root, buildType, polyfill } = configManager;
|
|
51
48
|
|
|
52
49
|
if (buildType === 'client') {
|
|
53
|
-
const { polyfill } = options;
|
|
54
|
-
|
|
55
50
|
if (isMissing(root)) {
|
|
56
51
|
throwErrorMissing('root', `${root}/index`);
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
if (polyfill && isMissing(polyfill)) {
|
|
60
|
-
throwErrorMissing('
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
const { server } = options;
|
|
64
|
-
|
|
65
|
-
if (isMissing(server)) {
|
|
66
|
-
throwErrorMissing('commands.build.options.server', server);
|
|
55
|
+
throwErrorMissing('polyfill', polyfill);
|
|
67
56
|
}
|
|
68
57
|
}
|
|
69
58
|
} else if (isModule(configManager)) {
|
package/src/di/tokens/config.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { createToken } from '@tinkoff/dippy';
|
|
|
2
2
|
import type { ConfigEntry } from '../../typings/configEntry/common';
|
|
3
3
|
import type { ConfigManager } from '../../config/configManager';
|
|
4
4
|
import type { Env } from '../../typings/Env';
|
|
5
|
+
import type { CliConfigEntry } from '../../typings/configEntry/cli';
|
|
5
6
|
|
|
6
7
|
export const CLI_ROOT_DIR_TOKEN = createToken<string>('cli rootDir');
|
|
7
8
|
export const CONFIG_ROOT_DIR_TOKEN = createToken<string>('config rootDir');
|
|
8
9
|
|
|
9
10
|
export const CONFIG_ENV_TOKEN = createToken<Env>('config env');
|
|
10
11
|
export const CONFIG_ENTRY_TOKEN = createToken<ConfigEntry>('config entry');
|
|
11
|
-
export const CONFIG_MANAGER_TOKEN = createToken<ConfigManager
|
|
12
|
+
export const CONFIG_MANAGER_TOKEN = createToken<ConfigManager<CliConfigEntry>>('config manager');
|
|
@@ -144,6 +144,7 @@ export const babelConfigFactory = ({
|
|
|
144
144
|
],
|
|
145
145
|
tramvai && env === 'development' && path.resolve(__dirname, './plugins/provider-stack'),
|
|
146
146
|
!isServer &&
|
|
147
|
+
env === 'development' &&
|
|
147
148
|
hot && ['react-refresh/babel', { skipEnvCheck: process.env.NODE_ENV === 'test' }],
|
|
148
149
|
]
|
|
149
150
|
.concat(cfg.plugins || [])
|
|
@@ -26,27 +26,9 @@ beforeAll(async () => {
|
|
|
26
26
|
name: 'swc-app',
|
|
27
27
|
type: 'application',
|
|
28
28
|
root: './',
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
server: 'index.ts',
|
|
33
|
-
},
|
|
34
|
-
configurations: {
|
|
35
|
-
experiments: {
|
|
36
|
-
transpilation: {
|
|
37
|
-
loader: 'swc',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
serve: {
|
|
43
|
-
configurations: {
|
|
44
|
-
experiments: {
|
|
45
|
-
transpilation: {
|
|
46
|
-
loader: 'swc',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
29
|
+
experiments: {
|
|
30
|
+
transpilation: {
|
|
31
|
+
loader: 'swc',
|
|
50
32
|
},
|
|
51
33
|
},
|
|
52
34
|
},
|
|
@@ -37,27 +37,9 @@ beforeAll(async () => {
|
|
|
37
37
|
name: 'swc-app',
|
|
38
38
|
type: 'application',
|
|
39
39
|
root: './',
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
server: 'index.ts',
|
|
44
|
-
},
|
|
45
|
-
configurations: {
|
|
46
|
-
experiments: {
|
|
47
|
-
transpilation: {
|
|
48
|
-
loader: 'swc',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
serve: {
|
|
54
|
-
configurations: {
|
|
55
|
-
experiments: {
|
|
56
|
-
transpilation: {
|
|
57
|
-
loader: 'swc',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
40
|
+
experiments: {
|
|
41
|
+
transpilation: {
|
|
42
|
+
loader: 'swc',
|
|
61
43
|
},
|
|
62
44
|
},
|
|
63
45
|
},
|
package/src/library/swc/index.ts
CHANGED
|
@@ -123,7 +123,7 @@ Having swc config may conflict with @tramvai/cli configuration`
|
|
|
123
123
|
react: {
|
|
124
124
|
runtime: hasJsxRuntime() ? 'automatic' : 'classic',
|
|
125
125
|
development: env === 'development',
|
|
126
|
-
refresh: hot && !isServer,
|
|
126
|
+
refresh: hot && env === 'development' && !isServer,
|
|
127
127
|
},
|
|
128
128
|
optimizer: {
|
|
129
129
|
globals: {
|
|
@@ -18,12 +18,10 @@ import nodeClient from '../../blocks/nodeClient';
|
|
|
18
18
|
import { pagesResolve } from '../../blocks/pagesResolve';
|
|
19
19
|
import { DEFAULT_STATS_OPTIONS, DEFAULT_STATS_FIELDS } from '../../constants/stats';
|
|
20
20
|
import { configToEnv } from '../../blocks/configToEnv';
|
|
21
|
+
import { safeRequireResolve } from '../../../../utils/safeRequire';
|
|
21
22
|
|
|
22
23
|
export default (configManager: ConfigManager<ApplicationConfigEntry>) => (config: Config) => {
|
|
23
|
-
const {
|
|
24
|
-
options: { polyfill = '' } = {},
|
|
25
|
-
configurations: { fileSystemPages },
|
|
26
|
-
} = configManager.build;
|
|
24
|
+
const { polyfill, fileSystemPages } = configManager;
|
|
27
25
|
|
|
28
26
|
config.name('client');
|
|
29
27
|
|
|
@@ -31,7 +29,7 @@ export default (configManager: ConfigManager<ApplicationConfigEntry>) => (config
|
|
|
31
29
|
config.batch(commonApplication(configManager));
|
|
32
30
|
config.batch(files(configManager));
|
|
33
31
|
|
|
34
|
-
if (fileSystemPages.
|
|
32
|
+
if (fileSystemPages.enabled) {
|
|
35
33
|
config.batch(pagesResolve(configManager));
|
|
36
34
|
}
|
|
37
35
|
|
|
@@ -56,8 +54,10 @@ export default (configManager: ConfigManager<ApplicationConfigEntry>) => (config
|
|
|
56
54
|
])
|
|
57
55
|
.end();
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const polyfillPath = path.resolve(configManager.rootDir, polyfill ?? 'src/polyfill');
|
|
58
|
+
|
|
59
|
+
if (safeRequireResolve(polyfillPath, typeof polyfill === 'undefined')) {
|
|
60
|
+
config.entry('polyfill').add(polyfillPath);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const statsFileName = configManager.modern ? 'stats.modern.json' : 'stats.json';
|