@tramvai/cli 5.49.1 → 6.59.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/__migrations__/d2023-02-01b-tramvai-config-refactoring.js +78 -80
- package/__migrations__/d2025-04-11b-tramvai-config-remove-modern.js +13 -0
- package/bin/spawn.js +76 -4
- package/lib/api/analyze/index.d.ts +0 -1
- package/lib/api/analyze/index.d.ts.map +1 -1
- package/lib/api/analyze/index.js +2 -2
- package/lib/api/analyze/index.js.map +1 -1
- package/lib/api/build/application.d.ts.map +1 -1
- package/lib/api/build/application.js +2 -5
- package/lib/api/build/application.js.map +1 -1
- package/lib/api/build/child-app.d.ts.map +1 -1
- package/lib/api/build/child-app.js +1 -5
- package/lib/api/build/child-app.js.map +1 -1
- package/lib/api/build/index.d.ts +0 -2
- package/lib/api/build/index.d.ts.map +1 -1
- package/lib/api/build/index.js.map +1 -1
- package/lib/api/build/module.d.ts.map +1 -1
- package/lib/api/build/module.js +1 -3
- package/lib/api/build/module.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +0 -4
- package/lib/api/index.js.map +1 -1
- package/lib/api/start/application.experimental.d.ts +7 -0
- package/lib/api/start/application.experimental.d.ts.map +1 -0
- package/lib/api/start/application.experimental.js +275 -0
- package/lib/api/start/application.experimental.js.map +1 -0
- package/lib/api/start/index.d.ts +1 -1
- package/lib/api/start/index.d.ts.map +1 -1
- package/lib/api/start/index.js +17 -6
- package/lib/api/start/index.js.map +1 -1
- package/lib/api/start/utils/banner.d.ts.map +1 -1
- package/lib/api/start/utils/banner.js +0 -1
- package/lib/api/start/utils/banner.js.map +1 -1
- package/lib/api/start/utils/tips/tips.d.ts.map +1 -1
- package/lib/api/start/utils/tips/tips.js +0 -8
- package/lib/api/start/utils/tips/tips.js.map +1 -1
- package/lib/builder/webpack/devServer/pool/process/pool.d.ts.map +1 -1
- package/lib/builder/webpack/devServer/pool/process/pool.js +0 -2
- package/lib/builder/webpack/devServer/pool/process/pool.js.map +1 -1
- package/lib/builder/webpack/devServer/server.d.ts.map +1 -1
- package/lib/builder/webpack/devServer/server.js +4 -0
- package/lib/builder/webpack/devServer/server.js.map +1 -1
- package/lib/builder/webpack/devServer/setup.d.ts.map +1 -1
- package/lib/builder/webpack/devServer/setup.js +3 -1
- package/lib/builder/webpack/devServer/setup.js.map +1 -1
- package/lib/builder/webpack/index.d.ts.map +1 -1
- package/lib/builder/webpack/index.js +3 -5
- package/lib/builder/webpack/index.js.map +1 -1
- package/lib/builder/webpack/providers/analyze/shared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/analyze/shared.js +5 -9
- package/lib/builder/webpack/providers/analyze/shared.js.map +1 -1
- package/lib/builder/webpack/providers/build/client.d.ts.map +1 -1
- package/lib/builder/webpack/providers/build/client.js +0 -1
- package/lib/builder/webpack/providers/build/client.js.map +1 -1
- package/lib/builder/webpack/providers/build/clientShared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/build/clientShared.js +4 -6
- package/lib/builder/webpack/providers/build/clientShared.js.map +1 -1
- package/lib/builder/webpack/providers/client.d.ts.map +1 -1
- package/lib/builder/webpack/providers/client.js +10 -22
- package/lib/builder/webpack/providers/client.js.map +1 -1
- package/lib/builder/webpack/providers/server.d.ts.map +1 -1
- package/lib/builder/webpack/providers/server.js +10 -9
- package/lib/builder/webpack/providers/server.js.map +1 -1
- package/lib/builder/webpack/providers/shared.d.ts.map +1 -1
- package/lib/builder/webpack/providers/shared.js +2 -8
- package/lib/builder/webpack/providers/shared.js.map +1 -1
- package/lib/builder/webpack/tokens.d.ts +4 -139
- package/lib/builder/webpack/tokens.d.ts.map +1 -1
- package/lib/builder/webpack/tokens.js +1 -4
- package/lib/builder/webpack/tokens.js.map +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.d.ts.map +1 -1
- package/lib/builder/webpack/utils/copyStatsJsonFile.js +0 -11
- package/lib/builder/webpack/utils/copyStatsJsonFile.js.map +1 -1
- package/lib/cli/CLI.d.ts +2 -2
- package/lib/cli/CLI.d.ts.map +1 -1
- package/lib/cli/CLI.js +2 -2
- package/lib/cli/CLI.js.map +1 -1
- package/lib/cli/bin-init.js +0 -2
- package/lib/cli/bin-init.js.map +1 -1
- package/lib/cli/index.d.ts.map +1 -1
- package/lib/cli/index.js +28 -18
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/runCLI.d.ts +3 -0
- package/lib/cli/runCLI.d.ts.map +1 -1
- package/lib/cli/runCLI.js +18 -6
- package/lib/cli/runCLI.js.map +1 -1
- package/lib/commands/add/command.d.ts +1 -4
- package/lib/commands/add/command.d.ts.map +1 -1
- package/lib/commands/add/command.js +3 -2
- package/lib/commands/add/command.js.map +1 -1
- package/lib/commands/analyze/command.d.ts +1 -1
- package/lib/commands/analyze/command.d.ts.map +1 -1
- package/lib/commands/analyze/command.js +11 -13
- package/lib/commands/analyze/command.js.map +1 -1
- package/lib/commands/benchmark/command.d.ts +1 -1
- package/lib/commands/benchmark/command.d.ts.map +1 -1
- package/lib/commands/benchmark/command.js +8 -9
- package/lib/commands/benchmark/command.js.map +1 -1
- package/lib/commands/build/build.d.ts.map +1 -1
- package/lib/commands/build/build.js +1 -0
- package/lib/commands/build/build.js.map +1 -1
- package/lib/commands/build/command.d.ts +2 -2
- package/lib/commands/build/command.d.ts.map +1 -1
- package/lib/commands/build/command.js +53 -28
- package/lib/commands/build/command.js.map +1 -1
- package/lib/commands/createApp.d.ts.map +1 -1
- package/lib/commands/createApp.js +0 -1
- package/lib/commands/createApp.js.map +1 -1
- package/lib/commands/generate/command.d.ts +1 -1
- package/lib/commands/generate/command.d.ts.map +1 -1
- package/lib/commands/generate/command.js +3 -2
- package/lib/commands/generate/command.js.map +1 -1
- package/lib/commands/lint/command.d.ts +1 -1
- package/lib/commands/lint/command.d.ts.map +1 -1
- package/lib/commands/lint/command.js +3 -2
- package/lib/commands/lint/command.js.map +1 -1
- package/lib/commands/new/command.d.ts +0 -1
- package/lib/commands/new/command.d.ts.map +1 -1
- package/lib/commands/new/command.js +0 -1
- package/lib/commands/new/command.js.map +1 -1
- package/lib/commands/new/new.d.ts.map +1 -1
- package/lib/commands/new/new.js +28 -3
- package/lib/commands/new/new.js.map +1 -1
- package/lib/commands/new/steps/installDependencies.js +3 -3
- package/lib/commands/new/steps/installDependencies.js.map +1 -1
- package/lib/commands/start/command.d.ts +2 -2
- package/lib/commands/start/command.d.ts.map +1 -1
- package/lib/commands/start/command.js +57 -22
- package/lib/commands/start/command.js.map +1 -1
- package/lib/commands/start/start.d.ts +1 -1
- package/lib/commands/start/start.d.ts.map +1 -1
- package/lib/commands/start/start.js +2 -1
- package/lib/commands/start/start.js.map +1 -1
- package/lib/commands/start-prod/command.d.ts +1 -1
- package/lib/commands/start-prod/command.d.ts.map +1 -1
- package/lib/commands/start-prod/command.js +11 -13
- package/lib/commands/start-prod/command.js.map +1 -1
- package/lib/commands/static/application.d.ts.map +1 -1
- package/lib/commands/static/application.js +0 -1
- package/lib/commands/static/application.js.map +1 -1
- package/lib/commands/static/command.d.ts +1 -1
- package/lib/commands/static/command.d.ts.map +1 -1
- package/lib/commands/static/command.js +7 -3
- package/lib/commands/static/command.js.map +1 -1
- package/lib/commands/update/command.d.ts +7 -5
- package/lib/commands/update/command.d.ts.map +1 -1
- package/lib/commands/update/command.js +11 -3
- package/lib/commands/update/command.js.map +1 -1
- package/lib/commands/update/dependantLibs.d.ts +2 -1
- package/lib/commands/update/dependantLibs.d.ts.map +1 -1
- package/lib/commands/update/dependantLibs.js +17 -4
- package/lib/commands/update/dependantLibs.js.map +1 -1
- package/lib/commands/update/update.d.ts +2 -1
- package/lib/commands/update/update.d.ts.map +1 -1
- package/lib/commands/update/update.js +6 -6
- package/lib/commands/update/update.js.map +1 -1
- package/lib/commands/update/updatePackageJson.d.ts +1 -1
- package/lib/commands/update/updatePackageJson.d.ts.map +1 -1
- package/lib/commands/update/updatePackageJson.js +10 -14
- package/lib/commands/update/updatePackageJson.js.map +1 -1
- package/lib/config/configManager.d.ts +0 -1
- package/lib/config/configManager.d.ts.map +1 -1
- package/lib/config/configManager.js +2 -17
- package/lib/config/configManager.js.map +1 -1
- package/lib/config/validate.d.ts.map +1 -1
- package/lib/config/validate.js +8 -1
- package/lib/config/validate.js.map +1 -1
- package/lib/di/providers/index.d.ts +0 -1
- package/lib/di/providers/index.d.ts.map +1 -1
- package/lib/di/providers/index.js +0 -1
- package/lib/di/providers/index.js.map +1 -1
- package/lib/di/tokens/config.d.ts +2 -0
- package/lib/di/tokens/config.d.ts.map +1 -1
- package/lib/di/tokens/index.d.ts +0 -1
- package/lib/di/tokens/index.d.ts.map +1 -1
- package/lib/di/tokens/index.js +0 -1
- package/lib/di/tokens/index.js.map +1 -1
- package/lib/external/config.d.ts.map +1 -1
- package/lib/external/config.js.map +1 -1
- package/lib/library/babel/index.d.ts +3 -53
- package/lib/library/babel/index.d.ts.map +1 -1
- package/lib/library/babel/index.js +3 -139
- package/lib/library/babel/index.js.map +1 -1
- package/lib/library/swc/index.d.ts +3 -3
- package/lib/library/swc/index.d.ts.map +1 -1
- package/lib/library/swc/index.js +4 -114
- package/lib/library/swc/index.js.map +1 -1
- package/lib/library/typescript/index.d.ts +0 -23
- package/lib/library/typescript/index.d.ts.map +1 -1
- package/lib/library/typescript/index.js +1 -2
- package/lib/library/typescript/index.js.map +1 -1
- package/lib/library/webpack/application/client/common.d.ts.map +1 -1
- package/lib/library/webpack/application/client/common.js +45 -10
- package/lib/library/webpack/application/client/common.js.map +1 -1
- package/lib/library/webpack/application/client/dev.js +2 -2
- package/lib/library/webpack/application/client/dev.js.map +1 -1
- package/lib/library/webpack/application/client/prod.d.ts.map +1 -1
- package/lib/library/webpack/application/client/prod.js +1 -2
- package/lib/library/webpack/application/client/prod.js.map +1 -1
- package/lib/library/webpack/application/common.d.ts.map +1 -1
- package/lib/library/webpack/application/common.js +4 -5
- package/lib/library/webpack/application/common.js.map +1 -1
- package/lib/library/webpack/application/server/common.js +1 -1
- package/lib/library/webpack/application/server/common.js.map +1 -1
- package/lib/library/webpack/application/server/dev.js +1 -1
- package/lib/library/webpack/application/server/dev.js.map +1 -1
- package/lib/library/webpack/application/server/prod.js +1 -1
- package/lib/library/webpack/application/server/prod.js.map +1 -1
- package/lib/library/webpack/blocks/css.d.ts.map +1 -1
- package/lib/library/webpack/blocks/css.js +15 -11
- package/lib/library/webpack/blocks/css.js.map +1 -1
- package/lib/library/webpack/blocks/optimize.js +2 -2
- package/lib/library/webpack/blocks/optimize.js.map +1 -1
- package/lib/library/webpack/blocks/pwa/client.d.ts.map +1 -1
- package/lib/library/webpack/blocks/pwa/client.js +11 -63
- package/lib/library/webpack/blocks/pwa/client.js.map +1 -1
- package/lib/library/webpack/blocks/pwa/shared.d.ts.map +1 -1
- package/lib/library/webpack/blocks/pwa/shared.js +2 -3
- package/lib/library/webpack/blocks/pwa/shared.js.map +1 -1
- package/lib/library/webpack/blocks/resolve.d.ts.map +1 -1
- package/lib/library/webpack/blocks/resolve.js +3 -2
- package/lib/library/webpack/blocks/resolve.js.map +1 -1
- package/lib/library/webpack/blocks/serverInline.d.ts.map +1 -1
- package/lib/library/webpack/blocks/serverInline.js +1 -2
- package/lib/library/webpack/blocks/serverInline.js.map +1 -1
- package/lib/library/webpack/blocks/sourcemaps.d.ts +1 -1
- package/lib/library/webpack/blocks/sourcemaps.d.ts.map +1 -1
- package/lib/library/webpack/blocks/sourcemaps.js +4 -2
- package/lib/library/webpack/blocks/sourcemaps.js.map +1 -1
- package/lib/library/webpack/child-app/client/common.d.ts.map +1 -1
- package/lib/library/webpack/child-app/client/common.js +8 -3
- package/lib/library/webpack/child-app/client/common.js.map +1 -1
- package/lib/library/webpack/child-app/client/dev.d.ts.map +1 -1
- package/lib/library/webpack/child-app/client/dev.js +5 -1
- package/lib/library/webpack/child-app/client/dev.js.map +1 -1
- package/lib/library/webpack/child-app/client/prod.d.ts.map +1 -1
- package/lib/library/webpack/child-app/client/prod.js +4 -0
- package/lib/library/webpack/child-app/client/prod.js.map +1 -1
- package/lib/library/webpack/child-app/common.d.ts.map +1 -1
- package/lib/library/webpack/child-app/common.js +4 -9
- package/lib/library/webpack/child-app/common.js.map +1 -1
- package/lib/library/webpack/child-app/server/dev.d.ts.map +1 -1
- package/lib/library/webpack/child-app/server/dev.js +4 -0
- package/lib/library/webpack/child-app/server/dev.js.map +1 -1
- package/lib/library/webpack/child-app/server/prod.d.ts.map +1 -1
- package/lib/library/webpack/child-app/server/prod.js +4 -0
- package/lib/library/webpack/child-app/server/prod.js.map +1 -1
- package/lib/library/webpack/common/client/prod.js +1 -1
- package/lib/library/webpack/common/client/prod.js.map +1 -1
- package/lib/library/webpack/common/main.d.ts.map +1 -1
- package/lib/library/webpack/common/main.js +1 -2
- package/lib/library/webpack/common/main.js.map +1 -1
- package/lib/library/webpack/constants/stats.d.ts.map +1 -1
- package/lib/library/webpack/constants/stats.js +2 -0
- package/lib/library/webpack/constants/stats.js.map +1 -1
- package/lib/library/webpack/loaders/image-loader/getImageMiniatureURL.js +1 -1
- package/lib/library/webpack/loaders/image-loader/getImageMiniatureURL.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.js +1 -1
- package/lib/library/webpack/module/externals.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/RuntimePathPlugin.d.ts.map +1 -1
- package/lib/library/webpack/plugins/RuntimePathPlugin.js +7 -3
- package/lib/library/webpack/plugins/RuntimePathPlugin.js.map +1 -1
- package/lib/library/webpack/utils/threadLoader.d.ts.map +1 -1
- package/lib/library/webpack/utils/threadLoader.js +20 -3
- package/lib/library/webpack/utils/threadLoader.js.map +1 -1
- package/lib/library/webpack/utils/transpiler.d.ts +0 -1
- package/lib/library/webpack/utils/transpiler.d.ts.map +1 -1
- package/lib/library/webpack/utils/transpiler.js +2 -6
- package/lib/library/webpack/utils/transpiler.js.map +1 -1
- package/lib/models/analytics/utils.d.ts +16 -0
- package/lib/models/analytics/utils.d.ts.map +1 -0
- package/lib/models/analytics/utils.js +88 -0
- package/lib/models/analytics/utils.js.map +1 -0
- package/lib/models/command.d.ts +1 -1
- package/lib/models/command.d.ts.map +1 -1
- package/lib/models/command.js +2 -8
- package/lib/models/command.js.map +1 -1
- package/lib/models/context.d.ts +4 -4
- package/lib/models/context.d.ts.map +1 -1
- package/lib/models/context.js +3 -2
- package/lib/models/context.js.map +1 -1
- package/lib/models/logger.js +1 -1
- package/lib/models/logger.js.map +1 -1
- package/lib/models/task.d.ts.map +1 -1
- package/lib/models/task.js +1 -7
- package/lib/models/task.js.map +1 -1
- package/lib/schema/autogeneratedSchema.json +161 -20
- package/lib/schema/topLevelSchema.d.ts +14 -0
- package/lib/schema/topLevelSchema.d.ts.map +1 -1
- package/lib/schema/topLevelSchema.js +14 -0
- package/lib/schema/topLevelSchema.js.map +1 -1
- package/lib/typings/build/Builder.d.ts +2 -6
- package/lib/typings/build/Builder.d.ts.map +1 -1
- package/lib/typings/configEntry/application.d.ts +11 -6
- package/lib/typings/configEntry/application.d.ts.map +1 -1
- package/lib/typings/configEntry/cli.d.ts +13 -0
- package/lib/typings/configEntry/cli.d.ts.map +1 -1
- package/lib/typings/projectType.d.ts +5 -0
- package/lib/typings/projectType.d.ts.map +1 -1
- package/lib/typings/public.d.ts +0 -1
- package/lib/typings/public.d.ts.map +1 -1
- package/lib/typings/public.js +0 -2
- package/lib/typings/public.js.map +1 -1
- package/lib/typings/target.d.ts +1 -1
- package/lib/typings/target.d.ts.map +1 -1
- package/lib/utils/commands/dependencies/findTramvaiVersion.d.ts +1 -1
- package/lib/utils/commands/dependencies/findTramvaiVersion.d.ts.map +1 -1
- package/lib/utils/commands/dependencies/findTramvaiVersion.js +4 -11
- package/lib/utils/commands/dependencies/findTramvaiVersion.js.map +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.d.ts +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.d.ts.map +1 -1
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js +7 -3
- package/lib/utils/commands/dependencies/getLatestPackageVersion.js.map +1 -1
- package/lib/utils/cpu-profile.d.ts +3 -0
- package/lib/utils/cpu-profile.d.ts.map +1 -1
- package/lib/utils/cpu-profile.js +8 -4
- package/lib/utils/cpu-profile.js.map +1 -1
- package/lib/utils/safeRequire.d.ts +1 -1
- package/lib/utils/safeRequire.d.ts.map +1 -1
- package/lib/utils/safeRequire.js +13 -3
- package/lib/utils/safeRequire.js.map +1 -1
- package/package.json +26 -32
- package/schema.json +175 -20
- package/src/api/analyze/index.ts +2 -3
- package/src/api/benchmark/__integration__/__fixtures__/tramvai.json +3 -0
- package/src/api/build/__integration__/__fixtures__/tramvai.json +4 -2
- package/src/api/build/__integration__/build.test.ts +0 -1
- package/src/api/build/application.ts +2 -5
- package/src/api/build/child-app.ts +1 -5
- package/src/api/build/index.ts +0 -2
- package/src/api/build/module.ts +1 -3
- package/src/api/index.ts +1 -10
- package/src/api/start/__integration__/__fixtures__/app/server.tsx +1 -0
- package/src/api/start/__integration__/__fixtures__/package.json +0 -3
- package/src/api/start/__integration__/__fixtures__/tramvai.json +3 -0
- package/src/api/start/__integration__/start.test.ts +10 -1
- package/src/api/start/application.experimental.ts +305 -0
- package/src/api/start/index.ts +20 -5
- package/src/api/start/utils/banner.ts +0 -1
- package/src/api/start/utils/tips/tips.ts +0 -9
- package/src/builder/webpack/devServer/pool/process/pool.ts +0 -2
- package/src/builder/webpack/devServer/server.ts +5 -0
- package/src/builder/webpack/devServer/setup.ts +1 -0
- package/src/builder/webpack/index.ts +3 -5
- package/src/builder/webpack/providers/analyze/shared.ts +6 -10
- package/src/builder/webpack/providers/build/client.ts +0 -1
- package/src/builder/webpack/providers/build/clientShared.ts +5 -11
- package/src/builder/webpack/providers/client.ts +16 -29
- package/src/builder/webpack/providers/server.ts +15 -10
- package/src/builder/webpack/providers/shared.ts +2 -9
- package/src/builder/webpack/tokens.ts +0 -9
- package/src/builder/webpack/utils/copyStatsJsonFile.ts +0 -17
- package/src/cli/CLI.ts +6 -4
- package/src/cli/bin-init.ts +0 -2
- package/src/cli/index.ts +36 -18
- package/src/cli/runCLI.ts +26 -6
- package/src/commands/add/command.ts +3 -2
- package/src/commands/analyze/command.ts +12 -14
- package/src/commands/benchmark/command.ts +9 -10
- package/src/commands/build/build.ts +2 -0
- package/src/commands/build/command.ts +58 -29
- package/src/commands/createApp.ts +0 -2
- package/src/commands/generate/command.ts +3 -2
- package/src/commands/lint/command.ts +3 -2
- package/src/commands/new/command.ts +0 -2
- package/src/commands/new/new.ts +39 -7
- package/src/commands/new/steps/installDependencies.ts +3 -3
- package/src/commands/new/templates/packageManagerConfig/yarnPackageManagerConfig/_yarnrc.yml.hbs +9 -0
- package/src/commands/new/templates/shared/_gitignore.hbs +10 -0
- package/src/commands/new/templates/shared/_prettierrc.js.hbs +1 -1
- package/src/commands/new/templates/shared/package.json.hbs +5 -1
- package/src/commands/start/command.ts +62 -23
- package/src/commands/start/start.ts +7 -1
- package/src/commands/start-prod/command.ts +12 -14
- package/src/commands/static/application.ts +0 -1
- package/src/commands/static/command.ts +7 -3
- package/src/commands/update/command.ts +12 -3
- package/src/commands/update/dependantLibs.ts +23 -8
- package/src/commands/update/update.ts +7 -6
- package/src/commands/update/updatePackageJson.spec.ts +66 -3
- package/src/commands/update/updatePackageJson.ts +28 -16
- package/src/config/__integration__/__fixtures__/relative/src/index.ts +0 -0
- package/src/config/__integration__/__fixtures__/relative/src/polyfill.ts +0 -0
- package/src/config/__integration__/validate.test.ts +94 -0
- package/src/config/configManager.ts +2 -19
- package/src/config/validate.ts +8 -1
- package/src/di/providers/index.ts +0 -1
- package/src/di/tokens/index.ts +0 -1
- package/src/external/config.ts +1 -0
- package/src/library/babel/index.ts +3 -166
- package/src/library/swc/__integration__/__snapshots__/swc.build.test.ts.snap +61 -236
- package/src/library/swc/__integration__/__snapshots__/swc.start.test.ts.snap +19 -18
- package/src/library/swc/__integration__/swc.build.test.ts +1 -13
- package/src/library/swc/__integration__/swc.start.test.ts +4 -1
- package/src/library/swc/index.ts +3 -139
- package/src/library/typescript/index.ts +1 -3
- package/src/library/webpack/application/client/common.ts +71 -9
- package/src/library/webpack/application/client/dev.ts +2 -2
- package/src/library/webpack/application/client/prod.ts +1 -2
- package/src/library/webpack/application/common.ts +9 -5
- package/src/library/webpack/application/server/common.ts +1 -1
- package/src/library/webpack/application/server/dev.ts +1 -1
- package/src/library/webpack/application/server/prod.ts +1 -1
- package/src/library/webpack/blocks/css.ts +17 -11
- package/src/library/webpack/blocks/optimize.ts +2 -2
- package/src/library/webpack/blocks/pwa/client.ts +14 -70
- package/src/library/webpack/blocks/pwa/shared.ts +1 -3
- package/src/library/webpack/blocks/resolve.ts +3 -2
- package/src/library/webpack/blocks/serverInline.ts +1 -2
- package/src/library/webpack/blocks/sourcemaps.ts +4 -2
- package/src/library/webpack/child-app/client/common.ts +9 -3
- package/src/library/webpack/child-app/client/dev.ts +6 -1
- package/src/library/webpack/child-app/client/prod.ts +5 -0
- package/src/library/webpack/child-app/common.ts +8 -12
- package/src/library/webpack/child-app/server/dev.ts +5 -0
- package/src/library/webpack/child-app/server/prod.ts +5 -0
- package/src/library/webpack/common/client/prod.ts +1 -1
- package/src/library/webpack/common/main.ts +1 -5
- package/src/library/webpack/constants/stats.ts +2 -0
- package/src/library/webpack/loaders/image-loader/getImageMiniatureURL.ts +1 -1
- package/src/library/webpack/module/client/common.ts +1 -1
- package/src/library/webpack/module/externals.ts +1 -1
- package/src/library/webpack/module/server/common.ts +1 -1
- package/src/library/webpack/plugins/RuntimePathPlugin.ts +8 -3
- package/src/library/webpack/utils/threadLoader.ts +21 -0
- package/src/library/webpack/utils/transpiler.ts +3 -7
- package/src/models/analytics/utils.ts +126 -0
- package/src/models/command.ts +4 -12
- package/src/models/config.spec.ts +6 -2
- package/src/models/context.ts +4 -5
- package/src/models/logger.ts +1 -1
- package/src/models/task.ts +1 -7
- package/src/schema/autogeneratedSchema.json +161 -20
- package/src/schema/topLevelSchema.js +14 -0
- package/src/schema/tramvai.spec.ts +3 -1
- package/src/typings/build/Builder.ts +3 -8
- package/src/typings/configEntry/application.ts +16 -7
- package/src/typings/configEntry/cli.ts +14 -0
- package/src/typings/projectType.ts +5 -0
- package/src/typings/public.ts +0 -2
- package/src/typings/target.ts +1 -1
- package/src/utils/commands/dependencies/findTramvaiVersion.ts +5 -12
- package/src/utils/commands/dependencies/getLatestPackageVersion.ts +11 -3
- package/src/utils/cpu-profile.ts +14 -4
- package/src/utils/safeRequire.spec.ts +36 -0
- package/src/utils/safeRequire.ts +12 -3
- package/lib/builder/webpack/providers/build/clientModern.d.ts +0 -3
- package/lib/builder/webpack/providers/build/clientModern.d.ts.map +0 -1
- package/lib/builder/webpack/providers/build/clientModern.js +0 -60
- package/lib/builder/webpack/providers/build/clientModern.js.map +0 -1
- package/lib/di/providers/analytics.d.ts +0 -3
- package/lib/di/providers/analytics.d.ts.map +0 -1
- package/lib/di/providers/analytics.js +0 -20
- package/lib/di/providers/analytics.js.map +0 -1
- package/lib/di/tokens/analytics.d.ts +0 -14
- package/lib/di/tokens/analytics.d.ts.map +0 -1
- package/lib/di/tokens/analytics.js +0 -8
- package/lib/di/tokens/analytics.js.map +0 -1
- package/lib/library/babel/plugins/create-token-pure.d.ts +0 -7
- package/lib/library/babel/plugins/create-token-pure.d.ts.map +0 -1
- package/lib/library/babel/plugins/create-token-pure.js +0 -39
- package/lib/library/babel/plugins/create-token-pure.js.map +0 -1
- package/lib/library/babel/plugins/fill-action-name.d.ts +0 -3
- package/lib/library/babel/plugins/fill-action-name.d.ts.map +0 -1
- package/lib/library/babel/plugins/fill-action-name.js +0 -107
- package/lib/library/babel/plugins/fill-action-name.js.map +0 -1
- package/lib/library/babel/plugins/fill-declare-action-name.d.ts +0 -6
- package/lib/library/babel/plugins/fill-declare-action-name.d.ts.map +0 -1
- package/lib/library/babel/plugins/fill-declare-action-name.js +0 -94
- package/lib/library/babel/plugins/fill-declare-action-name.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/lazy-component.d.ts +0 -7
- package/lib/library/babel/plugins/lazy-component/lazy-component.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/lazy-component.js +0 -75
- package/lib/library/babel/plugins/lazy-component/lazy-component.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/legacy-universal-replace.d.ts +0 -14
- package/lib/library/babel/plugins/lazy-component/legacy-universal-replace.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/legacy-universal-replace.js +0 -53
- package/lib/library/babel/plugins/lazy-component/legacy-universal-replace.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/chunkName.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/chunkName.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/chunkName.js +0 -133
- package/lib/library/babel/plugins/lazy-component/properties/chunkName.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/importAsync.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/importAsync.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/importAsync.js +0 -11
- package/lib/library/babel/plugins/lazy-component/properties/importAsync.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/isReady.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/isReady.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/isReady.js +0 -14
- package/lib/library/babel/plugins/lazy-component/properties/isReady.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/requireAsync.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/requireAsync.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/requireAsync.js +0 -15
- package/lib/library/babel/plugins/lazy-component/properties/requireAsync.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/requireSync.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/requireSync.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/requireSync.js +0 -16
- package/lib/library/babel/plugins/lazy-component/properties/requireSync.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/resolve.d.ts +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/resolve.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/resolve.js +0 -14
- package/lib/library/babel/plugins/lazy-component/properties/resolve.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/types.d.ts +0 -14
- package/lib/library/babel/plugins/lazy-component/properties/types.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/types.js +0 -3
- package/lib/library/babel/plugins/lazy-component/properties/types.js.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/utils/webpackComments.d.ts +0 -14
- package/lib/library/babel/plugins/lazy-component/properties/utils/webpackComments.d.ts.map +0 -1
- package/lib/library/babel/plugins/lazy-component/properties/utils/webpackComments.js +0 -57
- package/lib/library/babel/plugins/lazy-component/properties/utils/webpackComments.js.map +0 -1
- package/lib/library/babel/plugins/provider-stack.d.ts +0 -4
- package/lib/library/babel/plugins/provider-stack.d.ts.map +0 -1
- package/lib/library/babel/plugins/provider-stack.js +0 -63
- package/lib/library/babel/plugins/provider-stack.js.map +0 -1
- package/lib/library/babel/plugins/react-compiler.d.ts +0 -13
- package/lib/library/babel/plugins/react-compiler.d.ts.map +0 -1
- package/lib/library/babel/plugins/react-compiler.js +0 -27
- package/lib/library/babel/plugins/react-compiler.js.map +0 -1
- package/lib/library/babel/plugins/react-element-info-unique.d.ts +0 -26
- package/lib/library/babel/plugins/react-element-info-unique.d.ts.map +0 -1
- package/lib/library/babel/plugins/react-element-info-unique.js +0 -112
- package/lib/library/babel/plugins/react-element-info-unique.js.map +0 -1
- package/lib/library/babel/plugins/types.h.d.ts +0 -7
- package/lib/library/babel/plugins/types.h.d.ts.map +0 -1
- package/lib/library/babel/plugins/types.h.js +0 -3
- package/lib/library/babel/plugins/types.h.js.map +0 -1
- package/lib/library/webpack/plugins/AutoPublicPathPlugin.d.ts +0 -4
- package/lib/library/webpack/plugins/AutoPublicPathPlugin.d.ts.map +0 -1
- package/lib/library/webpack/plugins/AutoPublicPathPlugin.js +0 -23
- package/lib/library/webpack/plugins/AutoPublicPathPlugin.js.map +0 -1
- package/lib/library/webpack/plugins/ModuleFederationFixRange.d.ts +0 -24
- package/lib/library/webpack/plugins/ModuleFederationFixRange.d.ts.map +0 -1
- package/lib/library/webpack/plugins/ModuleFederationFixRange.js +0 -127
- package/lib/library/webpack/plugins/ModuleFederationFixRange.js.map +0 -1
- package/lib/library/webpack/plugins/ModuleFederationIgnoreEntries.d.ts +0 -15
- package/lib/library/webpack/plugins/ModuleFederationIgnoreEntries.d.ts.map +0 -1
- package/lib/library/webpack/plugins/ModuleFederationIgnoreEntries.js +0 -49
- package/lib/library/webpack/plugins/ModuleFederationIgnoreEntries.js.map +0 -1
- package/lib/library/webpack/plugins/PolyfillCondition.d.ts +0 -8
- package/lib/library/webpack/plugins/PolyfillCondition.d.ts.map +0 -1
- package/lib/library/webpack/plugins/PolyfillCondition.js +0 -46
- package/lib/library/webpack/plugins/PolyfillCondition.js.map +0 -1
- package/lib/library/webpack/plugins/PwaIconsPlugin.d.ts +0 -12
- package/lib/library/webpack/plugins/PwaIconsPlugin.d.ts.map +0 -1
- package/lib/library/webpack/plugins/PwaIconsPlugin.js +0 -78
- package/lib/library/webpack/plugins/PwaIconsPlugin.js.map +0 -1
- package/lib/library/webpack/plugins/WebManifestPlugin.d.ts +0 -13
- package/lib/library/webpack/plugins/WebManifestPlugin.d.ts.map +0 -1
- package/lib/library/webpack/plugins/WebManifestPlugin.js +0 -47
- package/lib/library/webpack/plugins/WebManifestPlugin.js.map +0 -1
- package/lib/library/webpack/utils/polyfills/const.d.ts +0 -3
- package/lib/library/webpack/utils/polyfills/const.d.ts.map +0 -1
- package/lib/library/webpack/utils/polyfills/const.js +0 -49
- package/lib/library/webpack/utils/polyfills/const.js.map +0 -1
- package/lib/library/webpack/utils/polyfills/polyfillCondition.d.ts +0 -8
- package/lib/library/webpack/utils/polyfills/polyfillCondition.d.ts.map +0 -1
- package/lib/library/webpack/utils/polyfills/polyfillCondition.js +0 -51
- package/lib/library/webpack/utils/polyfills/polyfillCondition.js.map +0 -1
- package/lib/library/webpack/utils/polyfills/specToFeature.d.ts +0 -7
- package/lib/library/webpack/utils/polyfills/specToFeature.d.ts.map +0 -1
- package/lib/library/webpack/utils/polyfills/specToFeature.js +0 -207
- package/lib/library/webpack/utils/polyfills/specToFeature.js.map +0 -1
- package/lib/models/analytics.d.ts +0 -31
- package/lib/models/analytics.d.ts.map +0 -1
- package/lib/models/analytics.js +0 -79
- package/lib/models/analytics.js.map +0 -1
- package/lib/typings/pwa/index.d.ts +0 -80
- package/lib/typings/pwa/index.d.ts.map +0 -1
- package/lib/typings/pwa/index.js +0 -3
- package/lib/typings/pwa/index.js.map +0 -1
- package/lib/utils/sentry.d.ts +0 -2
- package/lib/utils/sentry.d.ts.map +0 -1
- package/lib/utils/sentry.js +0 -27
- package/lib/utils/sentry.js.map +0 -1
- package/src/builder/webpack/providers/build/clientModern.ts +0 -64
- package/src/di/providers/analytics.ts +0 -22
- package/src/di/tokens/analytics.ts +0 -8
- package/src/library/babel/plugins/__fixtures__/create-token-pure/already-has-comment.ts +0 -5
- package/src/library/babel/plugins/__fixtures__/create-token-pure/do-nothing.ts +0 -10
- package/src/library/babel/plugins/__fixtures__/create-token-pure/from-core.ts +0 -5
- package/src/library/babel/plugins/__fixtures__/create-token-pure/from-dippy.ts +0 -5
- package/src/library/babel/plugins/__fixtures__/create-token-pure/many-imports.ts +0 -9
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/import-mixed.ts +0 -17
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/import-with-name.ts +0 -28
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/import-without-name.ts +0 -25
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/require-with-name.ts +0 -21
- package/src/library/babel/plugins/__fixtures__/fill-declare-action-name/require-without-name.ts +0 -19
- package/src/library/babel/plugins/__fixtures__/lazy-component/base.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/lazy-component/cmp.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/comments.ts +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/dynamic.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/lazy-component/inner/first.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/inner/path/cmp.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/inner/second.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/inner/third.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/lazy+hmr.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/lazy-component/long-import.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/lazy-component/not-lazy-import.ts +0 -7
- package/src/library/babel/plugins/__fixtures__/lazy-component/not-lazy.ts +0 -8
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/cmp.tsx +0 -7
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/not-universal.ts +0 -8
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/platform-legacy.ts +0 -5
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/react-universal.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/legacy-universal-replace/tramvai/react/index.es.ts +0 -3
- package/src/library/babel/plugins/__fixtures__/provider-stack/add-stack.ts +0 -22
- package/src/library/babel/plugins/__fixtures__/provider-stack/check-function-name.ts +0 -10
- package/src/library/babel/plugins/__fixtures__/provider-stack/do-nothing.ts +0 -16
- package/src/library/babel/plugins/__fixtures__/provider-stack/error-in-scope.ts +0 -24
- package/src/library/babel/plugins/__fixtures__/provider-stack/inside-await.ts +0 -12
- package/src/library/babel/plugins/__fixtures__/provider-stack/module-decorator.ts +0 -27
- package/src/library/babel/plugins/__snapshots__/create-token-pure.spec.ts.snap +0 -108
- package/src/library/babel/plugins/__snapshots__/fill-declare-action-name.spec.ts.snap +0 -266
- package/src/library/babel/plugins/__snapshots__/provider-stack.spec.ts.snap +0 -381
- package/src/library/babel/plugins/create-token-pure.spec.ts +0 -39
- package/src/library/babel/plugins/create-token-pure.ts +0 -47
- package/src/library/babel/plugins/fill-action-name.ts +0 -126
- package/src/library/babel/plugins/fill-declare-action-name.spec.ts +0 -37
- package/src/library/babel/plugins/fill-declare-action-name.ts +0 -110
- package/src/library/babel/plugins/lazy-component/__snapshots__/lazy-component.spec.ts.snap +0 -313
- package/src/library/babel/plugins/lazy-component/__snapshots__/legacy-universal-replace.spec.ts.snap +0 -114
- package/src/library/babel/plugins/lazy-component/lazy-component.spec.ts +0 -47
- package/src/library/babel/plugins/lazy-component/lazy-component.ts +0 -91
- package/src/library/babel/plugins/lazy-component/legacy-universal-replace.spec.ts +0 -34
- package/src/library/babel/plugins/lazy-component/legacy-universal-replace.ts +0 -88
- package/src/library/babel/plugins/lazy-component/properties/chunkName.ts +0 -185
- package/src/library/babel/plugins/lazy-component/properties/importAsync.ts +0 -8
- package/src/library/babel/plugins/lazy-component/properties/isReady.ts +0 -19
- package/src/library/babel/plugins/lazy-component/properties/requireAsync.ts +0 -20
- package/src/library/babel/plugins/lazy-component/properties/requireSync.ts +0 -21
- package/src/library/babel/plugins/lazy-component/properties/resolve.ts +0 -21
- package/src/library/babel/plugins/lazy-component/properties/types.ts +0 -20
- package/src/library/babel/plugins/lazy-component/properties/utils/webpackComments.ts +0 -61
- package/src/library/babel/plugins/provider-stack.spec.ts +0 -55
- package/src/library/babel/plugins/provider-stack.ts +0 -88
- package/src/library/babel/plugins/react-compiler.ts +0 -39
- package/src/library/babel/plugins/react-element-info-unique.ts +0 -144
- package/src/library/babel/plugins/types.h.ts +0 -8
- package/src/library/webpack/plugins/AutoPublicPathPlugin.ts +0 -23
- package/src/library/webpack/plugins/ModuleFederationFixRange.ts +0 -181
- package/src/library/webpack/plugins/ModuleFederationIgnoreEntries.ts +0 -59
- package/src/library/webpack/plugins/PolyfillCondition.ts +0 -62
- package/src/library/webpack/plugins/PwaIconsPlugin.ts +0 -94
- package/src/library/webpack/plugins/WebManifestPlugin.ts +0 -62
- package/src/library/webpack/utils/polyfills/__integration__/__snapshots__/condition.test.ts.snap +0 -1348
- package/src/library/webpack/utils/polyfills/__integration__/condition.test.ts +0 -128
- package/src/library/webpack/utils/polyfills/const.ts +0 -46
- package/src/library/webpack/utils/polyfills/polyfillCondition.ts +0 -63
- package/src/library/webpack/utils/polyfills/specToFeature.ts +0 -243
- package/src/models/analytics.ts +0 -116
- package/src/typings/pwa/index.ts +0 -83
- package/src/utils/sentry.ts +0 -25
- /package/src/commands/new/templates/{shared → packageManagerConfig/defaultPackageManagerConfig}/_npmrc.hbs +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import pluginTester from 'babel-plugin-tester';
|
|
3
|
-
import babelConfig from '../../index';
|
|
4
|
-
|
|
5
|
-
pluginTester({
|
|
6
|
-
plugin: {}, // плагин уже есть в основном конфиге, если подключить ещё тут то babel упадёт
|
|
7
|
-
pluginName: 'lazy-component',
|
|
8
|
-
filename: path.join(__dirname, '..', '__fixtures__', 'lazy-component', 'test'),
|
|
9
|
-
babelOptions: babelConfig({
|
|
10
|
-
typescript: true,
|
|
11
|
-
generateDataQaTag: false,
|
|
12
|
-
loader: false,
|
|
13
|
-
hot: true,
|
|
14
|
-
actualTarget: 'modern',
|
|
15
|
-
browsersListTargets: ['defaults'],
|
|
16
|
-
}),
|
|
17
|
-
tests: {
|
|
18
|
-
'not lazy': {
|
|
19
|
-
fixture: 'not-lazy.ts',
|
|
20
|
-
snapshot: true,
|
|
21
|
-
},
|
|
22
|
-
'tramvai react but not lazy': {
|
|
23
|
-
fixture: 'not-lazy-import.ts',
|
|
24
|
-
snapshot: true,
|
|
25
|
-
},
|
|
26
|
-
base: {
|
|
27
|
-
fixture: 'base.ts',
|
|
28
|
-
snapshot: true,
|
|
29
|
-
},
|
|
30
|
-
'long import': {
|
|
31
|
-
fixture: 'long-import.ts',
|
|
32
|
-
snapshot: true,
|
|
33
|
-
},
|
|
34
|
-
dynamic: {
|
|
35
|
-
fixture: 'dynamic.ts',
|
|
36
|
-
snapshot: true,
|
|
37
|
-
},
|
|
38
|
-
comments: {
|
|
39
|
-
fixture: 'comments.ts',
|
|
40
|
-
snapshot: true,
|
|
41
|
-
},
|
|
42
|
-
hmr: {
|
|
43
|
-
fixture: 'lazy+hmr.ts',
|
|
44
|
-
snapshot: true,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { NodePath } from '@babel/traverse';
|
|
2
|
-
import type { CallExpression, Import } from '@babel/types';
|
|
3
|
-
import type { Plugin } from '../types.h';
|
|
4
|
-
import { resolveMethod } from './properties/resolve';
|
|
5
|
-
import { requireSyncMethod } from './properties/requireSync';
|
|
6
|
-
import { isReadyMethod } from './properties/isReady';
|
|
7
|
-
import { importAsyncMethod } from './properties/importAsync';
|
|
8
|
-
import { requireAsyncMethod } from './properties/requireAsync';
|
|
9
|
-
import { chunkNameMethod } from './properties/chunkName';
|
|
10
|
-
|
|
11
|
-
interface InnerState {
|
|
12
|
-
tramvaiReactLazyLocal: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const lazyComponentPlugin: Plugin<InnerState> = (api) => {
|
|
16
|
-
const { types: t } = api;
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
pre() {
|
|
20
|
-
this.tramvaiReactLazyLocal = null;
|
|
21
|
-
},
|
|
22
|
-
visitor: {
|
|
23
|
-
// находим импорты `import { lazy } from '@tramvai/react'` т.к. будем преобразовывать импорты только для них
|
|
24
|
-
ImportDeclaration(path) {
|
|
25
|
-
if (path.get('source').node.value === '@tramvai/react') {
|
|
26
|
-
const specifiers = path.get('specifiers');
|
|
27
|
-
|
|
28
|
-
for (const specifier of specifiers) {
|
|
29
|
-
if (
|
|
30
|
-
t.isImportSpecifier(specifier.node) &&
|
|
31
|
-
t.isIdentifier(specifier.node.imported) &&
|
|
32
|
-
specifier.node.imported.name === 'lazy'
|
|
33
|
-
) {
|
|
34
|
-
// учитываем что локальная переменная в файле может быть названа по-другому
|
|
35
|
-
this.tramvaiReactLazyLocal = specifier.node.local.name;
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
CallExpression(path) {
|
|
42
|
-
if (!this.tramvaiReactLazyLocal) {
|
|
43
|
-
// если импорт lazy не был найден, то нет смысла работать с файлом дальше
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// проверяет только вызовы lazy
|
|
48
|
-
if (path.get('callee').isIdentifier({ name: this.tramvaiReactLazyLocal })) {
|
|
49
|
-
const imports: NodePath<Import>[] = [];
|
|
50
|
-
|
|
51
|
-
// ищем импорты внутри вызова lazy
|
|
52
|
-
path.traverse({
|
|
53
|
-
Import(importPath) {
|
|
54
|
-
imports.push(importPath);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (imports.length !== 1) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// локальное имя для lazy из @tramvai/react
|
|
63
|
-
const lazyCallPath = path;
|
|
64
|
-
// ссылка на вызов импорта - чтобы можно было получить аргументы импорта
|
|
65
|
-
const importPath = imports[0].parentPath as NodePath<CallExpression>;
|
|
66
|
-
// ссылка на функцию, которая была передана в lazy
|
|
67
|
-
const funcPath = importPath.parentPath;
|
|
68
|
-
|
|
69
|
-
if (!funcPath.isFunctionExpression() && !funcPath.isArrowFunctionExpression()) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const properties = [
|
|
74
|
-
chunkNameMethod,
|
|
75
|
-
requireSyncMethod,
|
|
76
|
-
isReadyMethod,
|
|
77
|
-
importAsyncMethod,
|
|
78
|
-
requireAsyncMethod,
|
|
79
|
-
resolveMethod,
|
|
80
|
-
].map((init) => init(api));
|
|
81
|
-
|
|
82
|
-
const opts = { lazyCallPath, funcPath, importPath };
|
|
83
|
-
|
|
84
|
-
funcPath.replaceWith(t.objectExpression(properties.map((factory) => factory(opts))));
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export default lazyComponentPlugin;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import pluginTester from 'babel-plugin-tester';
|
|
3
|
-
import babelConfig from '../../index';
|
|
4
|
-
|
|
5
|
-
pluginTester({
|
|
6
|
-
plugin: {}, // плагин уже есть в основном конфиге, если подключить ещё тут то babel упадёт
|
|
7
|
-
pluginName: 'legacy-universal-replace',
|
|
8
|
-
filename: path.join(__dirname, '..', '__fixtures__', 'legacy-universal-replace', 'test'),
|
|
9
|
-
babelOptions: babelConfig({
|
|
10
|
-
typescript: true,
|
|
11
|
-
generateDataQaTag: false,
|
|
12
|
-
loader: false,
|
|
13
|
-
actualTarget: 'modern',
|
|
14
|
-
browsersListTargets: ['defaults'],
|
|
15
|
-
}),
|
|
16
|
-
tests: {
|
|
17
|
-
'not universal': {
|
|
18
|
-
fixture: 'not-universal.ts',
|
|
19
|
-
snapshot: true,
|
|
20
|
-
},
|
|
21
|
-
'react-universal': {
|
|
22
|
-
fixture: 'react-universal.ts',
|
|
23
|
-
snapshot: true,
|
|
24
|
-
},
|
|
25
|
-
'platform legacy': {
|
|
26
|
-
fixture: 'platform-legacy.ts',
|
|
27
|
-
snapshot: true,
|
|
28
|
-
},
|
|
29
|
-
'tramvai-react': {
|
|
30
|
-
fixture: 'tramvai/react/index.es.ts',
|
|
31
|
-
snapshot: true,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type { Identifier } from '@babel/types';
|
|
2
|
-
import type { Plugin } from '../types.h';
|
|
3
|
-
|
|
4
|
-
interface InnerState {
|
|
5
|
-
legacyImport: string;
|
|
6
|
-
lazyIdentifier: Identifier;
|
|
7
|
-
file: {
|
|
8
|
-
opts: {
|
|
9
|
-
filename: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const legacyUniversalReplace: Plugin<InnerState> = (api) => {
|
|
15
|
-
const { types: t } = api;
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
visitor: {
|
|
19
|
-
// находим импорты `import universal from 'react-universal-component'` или `import async from '/decorators/asyncUniversal`
|
|
20
|
-
ImportDeclaration(path) {
|
|
21
|
-
const { filename } = this.file.opts;
|
|
22
|
-
|
|
23
|
-
const isTramvaiReact = /tramvai\/react/.test(filename);
|
|
24
|
-
|
|
25
|
-
const { value: source } = path.get('source').node;
|
|
26
|
-
if (
|
|
27
|
-
source === 'react-universal-component' ||
|
|
28
|
-
/\/decorators\/asyncUniversal(\.js)?$/.test(source)
|
|
29
|
-
) {
|
|
30
|
-
const specifiers = path.get('specifiers');
|
|
31
|
-
|
|
32
|
-
if (isTramvaiReact) {
|
|
33
|
-
path.replaceWith(
|
|
34
|
-
t.importDeclaration(
|
|
35
|
-
[t.importDefaultSpecifier(t.identifier('universal'))],
|
|
36
|
-
t.stringLiteral('@loadable/component')
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
for (const specifier of specifiers) {
|
|
44
|
-
if (t.isImportDefaultSpecifier(specifier.node)) {
|
|
45
|
-
this.legacyImport = specifier.node.local.name;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (this.legacyImport) {
|
|
50
|
-
const oldImport = path.node;
|
|
51
|
-
|
|
52
|
-
this.lazyIdentifier = path.scope.generateUidIdentifier('lazy');
|
|
53
|
-
|
|
54
|
-
path.replaceWith(
|
|
55
|
-
t.importDeclaration(
|
|
56
|
-
[t.importSpecifier(this.lazyIdentifier, t.identifier('lazy'))],
|
|
57
|
-
t.stringLiteral('@tramvai/react')
|
|
58
|
-
)
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
if (specifiers.length > 1) {
|
|
62
|
-
// возвращаем старый импорт на место, если вдруг используются другие импорты из legacy файла
|
|
63
|
-
path.insertBefore(oldImport);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
CallExpression(path) {
|
|
69
|
-
if (!this.legacyImport) {
|
|
70
|
-
// если импорт не был найден, то нет смысла работать с файлом дальше
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (path.get('callee').isIdentifier({ name: this.legacyImport })) {
|
|
75
|
-
const impPath = path.get('arguments')[0];
|
|
76
|
-
|
|
77
|
-
if (impPath.isCallExpression() && impPath.get('callee').isImport()) {
|
|
78
|
-
path.replaceWith(
|
|
79
|
-
t.callExpression(this.lazyIdentifier, [t.arrowFunctionExpression([], impPath.node)])
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export default legacyUniversalReplace;
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import type { NodePath } from '@babel/core';
|
|
2
|
-
import type {
|
|
3
|
-
BinaryExpression,
|
|
4
|
-
CallExpression,
|
|
5
|
-
Expression,
|
|
6
|
-
StringLiteral,
|
|
7
|
-
TemplateElement,
|
|
8
|
-
TemplateLiteral,
|
|
9
|
-
} from '@babel/types';
|
|
10
|
-
import type { ImportPath, PropertyFactory } from './types';
|
|
11
|
-
import type { WebpackComments } from './utils/webpackComments';
|
|
12
|
-
import { generateWebpackComments, parseWebpackComments } from './utils/webpackComments';
|
|
13
|
-
|
|
14
|
-
const JS_PATH_REGEXP = /^[./]+|(\.js$)/g;
|
|
15
|
-
const MATCH_LEFT_HYPHENS_REPLACE_REGEX = /^-/g;
|
|
16
|
-
const WEBPACK_CHUNK_NAME_REGEXP = /webpackChunkName/;
|
|
17
|
-
const WEBPACK_PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g;
|
|
18
|
-
const WEBPACK_MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
|
|
19
|
-
|
|
20
|
-
const getChunkNameComment = (importArg: NodePath) => {
|
|
21
|
-
const comments = importArg.node.leadingComments;
|
|
22
|
-
|
|
23
|
-
if (!comments) return null;
|
|
24
|
-
|
|
25
|
-
return comments.find((comment) => comment.value.match(WEBPACK_CHUNK_NAME_REGEXP));
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const getRawChunkNameFromComments = (importArg: NodePath) => {
|
|
29
|
-
const chunkNameComment = getChunkNameComment(importArg);
|
|
30
|
-
|
|
31
|
-
if (!chunkNameComment) return null;
|
|
32
|
-
|
|
33
|
-
return parseWebpackComments(chunkNameComment.value);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const moduleToChunk = (str?: string) => {
|
|
37
|
-
if (typeof str !== 'string') return '';
|
|
38
|
-
|
|
39
|
-
return str
|
|
40
|
-
.replace(JS_PATH_REGEXP, '')
|
|
41
|
-
.replace(WEBPACK_PATH_NAME_NORMALIZE_REPLACE_REGEX, '-')
|
|
42
|
-
.replace(WEBPACK_MATCH_PADDED_HYPHENS_REPLACE_REGEX, '');
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const replaceQuasi = (str: string, stripLeftHyphen: boolean) => {
|
|
46
|
-
if (!str) return '';
|
|
47
|
-
const result = str.replace(WEBPACK_PATH_NAME_NORMALIZE_REPLACE_REGEX, '-');
|
|
48
|
-
if (!stripLeftHyphen) return result;
|
|
49
|
-
return result.replace(MATCH_LEFT_HYPHENS_REPLACE_REGEX, '');
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const getChunkNamePrefix = (chunkName?: string) => {
|
|
53
|
-
if (typeof chunkName !== 'string') return '';
|
|
54
|
-
const match = chunkName.match(/(.+?)\[(request|index)\]$/);
|
|
55
|
-
return match ? match[1] : '';
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const getImportArg = (importPath: ImportPath) => {
|
|
59
|
-
const arg = importPath.get('arguments')[0];
|
|
60
|
-
|
|
61
|
-
if (arg.isStringLiteral() || arg.isTemplateLiteral()) {
|
|
62
|
-
return arg;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// высчитывает имя чанка, учитывая разные кейсы нейминга и использование динамических испортов на основании пропсов
|
|
67
|
-
// также добавляет комментарий для webpack чтобы это имя чанка использовалось для файла
|
|
68
|
-
export const chunkNameMethod: PropertyFactory = ({ types: t }) => {
|
|
69
|
-
const transformQuasi = (quasi: TemplateElement, first: boolean, single: boolean) => {
|
|
70
|
-
return t.templateElement(
|
|
71
|
-
{
|
|
72
|
-
raw: single ? moduleToChunk(quasi.value.raw) : replaceQuasi(quasi.value.raw, first),
|
|
73
|
-
cooked: single
|
|
74
|
-
? moduleToChunk(quasi.value.cooked)
|
|
75
|
-
: replaceQuasi(quasi.value.cooked, first),
|
|
76
|
-
},
|
|
77
|
-
quasi.tail
|
|
78
|
-
);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const sanitizeChunkNameTemplateLiteral = (node: Expression) => {
|
|
82
|
-
return t.callExpression(t.memberExpression(node, t.identifier('replace')), [
|
|
83
|
-
t.regExpLiteral(WEBPACK_PATH_NAME_NORMALIZE_REPLACE_REGEX.source, 'g'),
|
|
84
|
-
t.stringLiteral('-'),
|
|
85
|
-
]);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const combineExpressions = (node: TemplateLiteral) => {
|
|
89
|
-
const expressions = node.expressions as Expression[];
|
|
90
|
-
const { length } = expressions;
|
|
91
|
-
|
|
92
|
-
if (length === 1) {
|
|
93
|
-
return expressions[0];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return expressions.slice(1).reduce((r, p) => t.binaryExpression('+', r, p), expressions[0]);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const generateChunkNameNode = (importPath: ImportPath, prefix?: string) => {
|
|
100
|
-
const importArg = getImportArg(importPath);
|
|
101
|
-
if (importArg.isTemplateLiteral()) {
|
|
102
|
-
return prefix
|
|
103
|
-
? t.binaryExpression(
|
|
104
|
-
'+',
|
|
105
|
-
t.stringLiteral(prefix),
|
|
106
|
-
sanitizeChunkNameTemplateLiteral(combineExpressions(importArg.node))
|
|
107
|
-
)
|
|
108
|
-
: t.templateLiteral(
|
|
109
|
-
importArg.node.quasis.map((quasi, index) =>
|
|
110
|
-
transformQuasi(quasi, index === 0, importArg.node.quasis.length === 1)
|
|
111
|
-
),
|
|
112
|
-
importArg.node.expressions
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
return t.stringLiteral(moduleToChunk(importArg.node.value));
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const getExistingChunkNameComment = (importPath: ImportPath) => {
|
|
119
|
-
const importArg = getImportArg(importPath);
|
|
120
|
-
const values = getRawChunkNameFromComments(importArg);
|
|
121
|
-
|
|
122
|
-
return values;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const isAggressiveImport = (importPath: ImportPath) => {
|
|
126
|
-
const importArg = getImportArg(importPath);
|
|
127
|
-
|
|
128
|
-
return importArg.isTemplateLiteral() && importArg.node.expressions.length > 0;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const addOrReplaceChunkNameComment = (importPath: ImportPath, values: WebpackComments) => {
|
|
132
|
-
const importArg = getImportArg(importPath);
|
|
133
|
-
const chunkNameComment = getChunkNameComment(importArg);
|
|
134
|
-
|
|
135
|
-
if (chunkNameComment) {
|
|
136
|
-
t.removeComments(importArg.node);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
importArg.addComment('leading', generateWebpackComments(values));
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const chunkNameFromTemplateLiteral = (node: TemplateLiteral) => {
|
|
143
|
-
const [q1] = node.quasis;
|
|
144
|
-
const v1 = q1 ? q1.value.cooked : '';
|
|
145
|
-
|
|
146
|
-
if (!node.expressions.length) return v1;
|
|
147
|
-
|
|
148
|
-
return `${v1}[request]`;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const replaceChunkName = (importPath: ImportPath) => {
|
|
152
|
-
const aggressiveImport = isAggressiveImport(importPath);
|
|
153
|
-
const values = getExistingChunkNameComment(importPath);
|
|
154
|
-
let { webpackChunkName } = values || {};
|
|
155
|
-
|
|
156
|
-
if (!aggressiveImport && values) {
|
|
157
|
-
addOrReplaceChunkNameComment(importPath, values);
|
|
158
|
-
return t.stringLiteral(webpackChunkName);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
let chunkNameNode: CallExpression | TemplateLiteral | StringLiteral | BinaryExpression =
|
|
162
|
-
generateChunkNameNode(importPath, getChunkNamePrefix(webpackChunkName));
|
|
163
|
-
|
|
164
|
-
if (t.isTemplateLiteral(chunkNameNode)) {
|
|
165
|
-
webpackChunkName = chunkNameFromTemplateLiteral(chunkNameNode);
|
|
166
|
-
chunkNameNode = sanitizeChunkNameTemplateLiteral(chunkNameNode);
|
|
167
|
-
} else if (t.isStringLiteral(chunkNameNode)) {
|
|
168
|
-
webpackChunkName = chunkNameNode.value;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
addOrReplaceChunkNameComment(importPath, { ...values, webpackChunkName });
|
|
172
|
-
return chunkNameNode;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
return ({ funcPath, importPath }) => {
|
|
176
|
-
const chunkName = replaceChunkName(importPath);
|
|
177
|
-
|
|
178
|
-
return t.objectMethod(
|
|
179
|
-
'method',
|
|
180
|
-
t.identifier('chunkName'),
|
|
181
|
-
funcPath.node.params,
|
|
182
|
-
t.blockStatement([t.returnStatement(chunkName)])
|
|
183
|
-
);
|
|
184
|
-
};
|
|
185
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { PropertyFactory } from './types';
|
|
2
|
-
|
|
3
|
-
// просто оставляет импорт как есть + добавляет автоматически указание имени чанка для вебпака
|
|
4
|
-
export const importAsyncMethod: PropertyFactory = ({ types: t }) => {
|
|
5
|
-
return ({ funcPath }) => {
|
|
6
|
-
return t.objectProperty(t.identifier('importAsync'), funcPath.node);
|
|
7
|
-
};
|
|
8
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Statement } from '@babel/types';
|
|
2
|
-
import type { PropertyFactory } from './types';
|
|
3
|
-
|
|
4
|
-
// проверяет на клиенте что нужный чанк загружен и его можно заполучить синхронно
|
|
5
|
-
export const isReadyMethod: PropertyFactory = ({ types: t, template }) => {
|
|
6
|
-
const statements = template.ast(`
|
|
7
|
-
const key=this.resolve(props);
|
|
8
|
-
|
|
9
|
-
return !!(__webpack_modules__[key]);
|
|
10
|
-
`);
|
|
11
|
-
|
|
12
|
-
return () =>
|
|
13
|
-
t.objectMethod(
|
|
14
|
-
'method',
|
|
15
|
-
t.identifier('isReady'),
|
|
16
|
-
[t.identifier('props')],
|
|
17
|
-
t.blockStatement(statements as Statement[])
|
|
18
|
-
);
|
|
19
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Statement } from '@babel/types';
|
|
2
|
-
import type { PropertyFactory } from './types';
|
|
3
|
-
|
|
4
|
-
export const requireAsyncMethod: PropertyFactory = ({ types: t, template }) => {
|
|
5
|
-
const tracking = template.ast(`
|
|
6
|
-
const key = this.resolve(props);
|
|
7
|
-
|
|
8
|
-
return this.importAsync(props).then(resolved => {
|
|
9
|
-
return resolved;
|
|
10
|
-
});
|
|
11
|
-
`);
|
|
12
|
-
|
|
13
|
-
return () =>
|
|
14
|
-
t.objectMethod(
|
|
15
|
-
'method',
|
|
16
|
-
t.identifier('requireAsync'),
|
|
17
|
-
[t.identifier('props')],
|
|
18
|
-
t.blockStatement(tracking as Statement[])
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { PropertyFactory } from './types';
|
|
2
|
-
|
|
3
|
-
// позволяет загрузить модуль синхронно - нужно на сервере и чтобы не выполнять повторную загрузку,
|
|
4
|
-
// если чанк уже был загружен ранее на клиенте
|
|
5
|
-
export const requireSyncMethod: PropertyFactory = ({ types: t, template }) => {
|
|
6
|
-
return () =>
|
|
7
|
-
t.objectMethod(
|
|
8
|
-
'method',
|
|
9
|
-
t.identifier('requireSync'),
|
|
10
|
-
[t.identifier('props')],
|
|
11
|
-
t.blockStatement([
|
|
12
|
-
t.returnStatement(
|
|
13
|
-
t.callExpression(t.identifier('__webpack_require__'), [
|
|
14
|
-
t.callExpression(t.memberExpression(t.thisExpression(), t.identifier('resolve')), [
|
|
15
|
-
t.identifier('props'),
|
|
16
|
-
]),
|
|
17
|
-
])
|
|
18
|
-
),
|
|
19
|
-
])
|
|
20
|
-
);
|
|
21
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { PropertyFactory } from './types';
|
|
2
|
-
|
|
3
|
-
// позволяет получить в рантайме id модуля, который нужно загрузить. В деве это обычно путь к файлу и в @loadable
|
|
4
|
-
// это свойство используется преимущественно для логов
|
|
5
|
-
export const resolveMethod: PropertyFactory = ({ types: t }) => {
|
|
6
|
-
return ({ importPath, funcPath }) => {
|
|
7
|
-
return t.objectMethod(
|
|
8
|
-
'method',
|
|
9
|
-
t.identifier('resolve'),
|
|
10
|
-
funcPath.node.params ?? [],
|
|
11
|
-
t.blockStatement([
|
|
12
|
-
t.returnStatement(
|
|
13
|
-
t.callExpression(
|
|
14
|
-
t.memberExpression(t.identifier('require'), t.identifier('resolveWeak')),
|
|
15
|
-
[importPath.get('arguments')[0].node]
|
|
16
|
-
)
|
|
17
|
-
),
|
|
18
|
-
])
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { types, template, NodePath } from '@babel/core';
|
|
2
|
-
import type {
|
|
3
|
-
FunctionExpression,
|
|
4
|
-
CallExpression,
|
|
5
|
-
ObjectMember,
|
|
6
|
-
ArrowFunctionExpression,
|
|
7
|
-
} from '@babel/types';
|
|
8
|
-
|
|
9
|
-
export type LazyCallPath = NodePath<CallExpression>;
|
|
10
|
-
export type FuncPath = NodePath<FunctionExpression | ArrowFunctionExpression>;
|
|
11
|
-
export type ImportPath = NodePath<CallExpression>;
|
|
12
|
-
|
|
13
|
-
export type PropertyFactory = (arg: {
|
|
14
|
-
types: typeof types;
|
|
15
|
-
template: typeof template;
|
|
16
|
-
}) => (arg: {
|
|
17
|
-
lazyCallPath: LazyCallPath;
|
|
18
|
-
funcPath: FuncPath;
|
|
19
|
-
importPath: ImportPath;
|
|
20
|
-
}) => ObjectMember;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export interface WebpackComments {
|
|
2
|
-
webpackChunk?: string;
|
|
3
|
-
[key: string]: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const quotesRegex = /["']/g;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Expect string with specific magic comments here - `webpackChunkName`.
|
|
10
|
-
* Objects can be here - https://webpack.js.org/api/module-methods/#magic-comments:~:text=This%20is%20wrapped%20in%20a%20JavaScript%20object%20and%20executed%20using%20node%20VM
|
|
11
|
-
* But vm.runInThisContext is slow, and we can cover only simple case here, while use this helper only in `chunkName.ts`
|
|
12
|
-
*
|
|
13
|
-
* @param str - example: ' webpackChunkName: "any_chunk_name" '
|
|
14
|
-
*/
|
|
15
|
-
export const parseWebpackComments = (str: string): WebpackComments => {
|
|
16
|
-
try {
|
|
17
|
-
const rawValues = str.trim().split(',');
|
|
18
|
-
const values: WebpackComments = {};
|
|
19
|
-
|
|
20
|
-
rawValues.forEach((comment) => {
|
|
21
|
-
const [key, rawValue] = comment.trim().split(':');
|
|
22
|
-
let value: any = rawValue.trim();
|
|
23
|
-
|
|
24
|
-
switch (value) {
|
|
25
|
-
case 'true': {
|
|
26
|
-
value = true;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
case 'false': {
|
|
30
|
-
value = false;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
case 'null': {
|
|
34
|
-
value = null;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
default: {
|
|
38
|
-
value = value.replace(quotesRegex, '');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
values[key] = value;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return values;
|
|
46
|
-
} catch (e) {
|
|
47
|
-
throw Error(`compilation error while processing: /*${str}*/: ${e.message}`);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const generateWebpackComments = (values: WebpackComments) => {
|
|
52
|
-
try {
|
|
53
|
-
const str = Object.keys(values)
|
|
54
|
-
.map((key) => `${key}: ${JSON.stringify(values[key])}`)
|
|
55
|
-
.join(', ');
|
|
56
|
-
|
|
57
|
-
return ` ${str} `;
|
|
58
|
-
} catch (e) {
|
|
59
|
-
throw Error(`compilation error while processing: /*${values}*/: ${e.message}`);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import pluginTester from 'babel-plugin-tester';
|
|
3
|
-
import { providerStackPlugin } from './provider-stack';
|
|
4
|
-
import babelConfig from '../index';
|
|
5
|
-
|
|
6
|
-
pluginTester({
|
|
7
|
-
plugin: providerStackPlugin,
|
|
8
|
-
pluginName: 'provider-stack',
|
|
9
|
-
filename: path.join(__dirname, '__fixtures__', 'provider-stack', 'test'),
|
|
10
|
-
babelOptions: babelConfig({
|
|
11
|
-
typescript: true,
|
|
12
|
-
generateDataQaTag: false,
|
|
13
|
-
loader: false,
|
|
14
|
-
}),
|
|
15
|
-
tests: {
|
|
16
|
-
'do nothing': {
|
|
17
|
-
fixture: 'do-nothing.ts',
|
|
18
|
-
snapshot: true,
|
|
19
|
-
},
|
|
20
|
-
'add __stack property to module decorator providers': {
|
|
21
|
-
fixture: 'module-decorator.ts',
|
|
22
|
-
snapshot: true,
|
|
23
|
-
},
|
|
24
|
-
'add __stack property external providers': {
|
|
25
|
-
fixture: 'add-stack.ts',
|
|
26
|
-
snapshot: true,
|
|
27
|
-
},
|
|
28
|
-
'add __stack property if Error in scope': {
|
|
29
|
-
fixture: 'error-in-scope.ts',
|
|
30
|
-
snapshot: true,
|
|
31
|
-
},
|
|
32
|
-
'inside await': {
|
|
33
|
-
fixture: 'inside-await.ts',
|
|
34
|
-
snapshot: true,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
pluginTester({
|
|
40
|
-
plugin: providerStackPlugin,
|
|
41
|
-
pluginName: 'provider-stack',
|
|
42
|
-
filename: path.join(__dirname, '__fixtures__', 'provider-stack', 'test'),
|
|
43
|
-
babelOptions: babelConfig({
|
|
44
|
-
typescript: true,
|
|
45
|
-
generateDataQaTag: false,
|
|
46
|
-
loader: false,
|
|
47
|
-
excludesPresetEnv: ['transform-function-name'],
|
|
48
|
-
}),
|
|
49
|
-
tests: {
|
|
50
|
-
'check function naming': {
|
|
51
|
-
fixture: 'check-function-name.ts',
|
|
52
|
-
snapshot: true,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|