@tramvai/cli 2.40.0 → 2.45.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/lib/api/analyze/index.d.ts +1 -1
- package/lib/api/benchmark/index.d.ts +1 -1
- package/lib/api/benchmark/types.d.ts +2 -2
- package/lib/api/build/index.d.ts +3 -3
- package/lib/api/shared/types/withConfig.d.ts +1 -1
- package/lib/api/shared/types/withRootDir.d.ts +1 -1
- package/lib/api/start/index.d.ts +3 -3
- package/lib/api/start-prod/index.d.ts +3 -3
- package/lib/builder/webpack/types.d.ts +1 -1
- package/lib/commands/add/add.d.ts +1 -1
- package/lib/commands/analyze/command.d.ts +1 -1
- package/lib/commands/benchmark/command.d.ts +1 -1
- package/lib/commands/build/command.d.ts +1 -1
- package/lib/commands/generate/command.d.ts +2 -2
- package/lib/commands/generate/generators/typings.d.ts +2 -2
- package/lib/commands/generate/utils/withAutocomplete.d.ts +1 -1
- package/lib/commands/new/questions/packageManager.d.ts +1 -1
- package/lib/commands/new/questions/template.d.ts +1 -1
- package/lib/commands/new/questions/testingFramework.d.ts +1 -1
- package/lib/commands/new/questions/type.d.ts +1 -1
- package/lib/commands/new/typings.d.ts +2 -2
- package/lib/commands/start/command.d.ts +1 -1
- package/lib/commands/static/command.d.ts +1 -1
- package/lib/commands/update/checkVersionValidator.d.ts +1 -1
- package/lib/commands/update/command.d.ts +1 -1
- package/lib/commands/update/update.d.ts +2 -2
- package/lib/di/providers/commands.d.ts +1 -1
- package/lib/external/pages.d.ts +2 -1
- package/lib/external/pages.js +1 -0
- package/lib/external/pages.js.map +1 -1
- package/lib/library/babel/index.d.ts +3 -3
- package/lib/library/babel/plugins/lazy-component/properties/types.d.ts +4 -4
- package/lib/library/babel/plugins/types.h.d.ts +1 -1
- package/lib/library/generate/printResultInfo.d.ts +1 -1
- package/lib/library/generate/runGenerator.d.ts +1 -1
- package/lib/library/swc/index.d.ts +3 -34
- package/lib/library/swc/index.js +39 -11
- package/lib/library/swc/index.js.map +1 -1
- package/lib/library/typescript/index.d.ts +1 -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/ts.js +1 -1
- package/lib/library/webpack/blocks/ts.js.map +1 -1
- package/lib/library/webpack/loaders/pagesResolve.js +15 -1
- package/lib/library/webpack/loaders/pagesResolve.js.map +1 -1
- package/lib/library/webpack/plugins/DedupePlugin/DedupePlugin.d.ts +1 -1
- package/lib/library/webpack/types/webpack.d.ts +3 -3
- package/lib/library/webpack/utils/transpiler.js +9 -0
- package/lib/library/webpack/utils/transpiler.js.map +1 -1
- package/lib/models/command.d.ts +3 -3
- package/lib/models/task.d.ts +2 -2
- package/lib/schema/ConfigSchema.d.ts +1 -1
- package/lib/typings/Env.d.ts +1 -1
- package/lib/typings/build/Builder.d.ts +2 -2
- package/lib/typings/configEntry/application.d.ts +1 -1
- package/lib/typings/configEntry/common.d.ts +1 -1
- package/lib/typings/projectType.d.ts +4 -4
- package/lib/typings/public.d.ts +1 -1
- package/lib/typings/target.d.ts +1 -1
- package/lib/validators/commands/validator.h.d.ts +1 -1
- package/package.json +5 -7
- package/src/api/start/__integration__/start.test.ts +1 -0
- package/src/external/pages.ts +3 -1
- package/src/library/babel/index.ts +1 -1
- package/src/library/swc/index.ts +44 -12
- package/src/library/webpack/blocks/js.ts +1 -1
- package/src/library/webpack/blocks/ts.ts +1 -1
- package/src/library/webpack/loaders/pagesResolve.ts +29 -1
- package/src/library/webpack/utils/transpiler.ts +9 -0
|
@@ -6,6 +6,6 @@ export interface Params {
|
|
|
6
6
|
showConfig?: boolean;
|
|
7
7
|
fileCache?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type AnalyzeCommand = (params: Params, providers?: Provider[]) => Promise<void>;
|
|
10
10
|
declare const _default: import("../../typings/commands").Command;
|
|
11
11
|
export default _default;
|
|
@@ -10,6 +10,6 @@ export interface Params {
|
|
|
10
10
|
export interface Result {
|
|
11
11
|
[key: string]: RunStats;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type BenchmarkCommand = (params: StartParams | BuildParams, providers?: Provider[]) => Promise<StartResult | BuildResult>;
|
|
14
14
|
declare const _default: import("../../typings/commands").Command;
|
|
15
15
|
export default _default;
|
|
@@ -4,11 +4,11 @@ export interface Stats {
|
|
|
4
4
|
std: number;
|
|
5
5
|
variance: number;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type Samples = {
|
|
8
8
|
clientSamples: Stats['samples'];
|
|
9
9
|
serverSamples: Stats['samples'];
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type RunStats = {
|
|
12
12
|
client: Stats;
|
|
13
13
|
server: Stats;
|
|
14
14
|
};
|
package/lib/api/build/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { PromiseType } from 'utility-types';
|
|
|
2
2
|
import type { Provider } from '@tinkoff/dippy';
|
|
3
3
|
import type { WithConfig } from '../shared/types/withConfig';
|
|
4
4
|
import type { Builder } from '../../typings/build/Builder';
|
|
5
|
-
export
|
|
5
|
+
export type Params = WithConfig<{
|
|
6
6
|
buildType?: 'server' | 'client' | 'all' | 'none';
|
|
7
7
|
debug?: boolean;
|
|
8
8
|
profile?: boolean;
|
|
@@ -16,9 +16,9 @@ export declare type Params = WithConfig<{
|
|
|
16
16
|
watchMode?: boolean;
|
|
17
17
|
forPublish?: boolean;
|
|
18
18
|
}>;
|
|
19
|
-
export
|
|
19
|
+
export type Result<T extends string = any> = Promise<PromiseType<ReturnType<Builder<T>['build']>> & {
|
|
20
20
|
builder?: Builder<T>;
|
|
21
21
|
}>;
|
|
22
|
-
export
|
|
22
|
+
export type BuildCommand = (params: Params, providers?: Provider[]) => Result;
|
|
23
23
|
declare const _default: import("../../typings/commands").Command;
|
|
24
24
|
export default _default;
|
|
@@ -3,7 +3,7 @@ import type { ModuleConfigEntry } from '../../../typings/configEntry/module';
|
|
|
3
3
|
import type { WithRootDir } from './withRootDir';
|
|
4
4
|
import type { PackageConfigEntry } from '../../../typings/configEntry/package';
|
|
5
5
|
import type { ChildAppConfigEntry } from '../../../typings/configEntry/child-app';
|
|
6
|
-
export
|
|
6
|
+
export type WithConfig<T> = WithRootDir<T> & ({
|
|
7
7
|
target: string;
|
|
8
8
|
} | {
|
|
9
9
|
config: ApplicationConfigEntry | ModuleConfigEntry | PackageConfigEntry | ChildAppConfigEntry;
|
package/lib/api/start/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { PromiseType } from 'utility-types';
|
|
|
4
4
|
import type { Provider } from '@tinkoff/dippy';
|
|
5
5
|
import type { WithConfig } from '../shared/types/withConfig';
|
|
6
6
|
import type { Builder } from '../../typings/build/Builder';
|
|
7
|
-
export
|
|
7
|
+
export type Params = WithConfig<{
|
|
8
8
|
buildType?: 'server' | 'client' | 'all';
|
|
9
9
|
host?: string;
|
|
10
10
|
port?: number;
|
|
@@ -24,12 +24,12 @@ export declare type Params = WithConfig<{
|
|
|
24
24
|
strictErrorHandle?: boolean;
|
|
25
25
|
fileCache?: boolean;
|
|
26
26
|
}>;
|
|
27
|
-
export
|
|
27
|
+
export type Result<T extends string = any> = Promise<PromiseType<ReturnType<Builder<T>['start']>> & {
|
|
28
28
|
close: () => Promise<void>;
|
|
29
29
|
staticServer?: Server;
|
|
30
30
|
server?: Server;
|
|
31
31
|
builder: Builder<T>;
|
|
32
32
|
}>;
|
|
33
|
-
export
|
|
33
|
+
export type StartCommand = (params: Params, providers?: Provider[]) => Result;
|
|
34
34
|
declare const _default: import("../../typings/commands").Command;
|
|
35
35
|
export default _default;
|
|
@@ -6,7 +6,7 @@ import type { ChildProcess } from 'child_process';
|
|
|
6
6
|
import type { Provider } from '@tinkoff/dippy';
|
|
7
7
|
import type { WithConfig } from '../shared/types/withConfig';
|
|
8
8
|
import type { Builder } from '../../typings/build/Builder';
|
|
9
|
-
export
|
|
9
|
+
export type Params = WithConfig<{
|
|
10
10
|
buildType?: 'server' | 'client' | 'all' | 'none';
|
|
11
11
|
host?: string;
|
|
12
12
|
port?: number;
|
|
@@ -19,12 +19,12 @@ export declare type Params = WithConfig<{
|
|
|
19
19
|
env?: Record<string, string>;
|
|
20
20
|
fileCache?: boolean;
|
|
21
21
|
}>;
|
|
22
|
-
export
|
|
22
|
+
export type Result<T extends string = any> = Promise<PromiseType<ReturnType<Builder<T>['build']>> & {
|
|
23
23
|
close: () => Promise<void>;
|
|
24
24
|
staticServer?: Server;
|
|
25
25
|
serverProcess?: ChildProcess;
|
|
26
26
|
builder: Builder<T>;
|
|
27
27
|
}>;
|
|
28
|
-
export
|
|
28
|
+
export type StartProdCommand = (params: Params, providers?: Provider[]) => Result;
|
|
29
29
|
declare const _default: import("../../typings/commands").Command;
|
|
30
30
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Config from 'webpack-chain';
|
|
2
2
|
import type { ConfigManager } from '../../config/configManager';
|
|
3
|
-
export
|
|
3
|
+
export type ConfigGenerator = (arg: {
|
|
4
4
|
configManager: ConfigManager;
|
|
5
5
|
showProgress?: boolean;
|
|
6
6
|
}) => Config;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLICommand } from '../../models/command';
|
|
2
2
|
import type { Params as StartParams } from '../start/command';
|
|
3
|
-
export
|
|
3
|
+
export type Params = StartParams & {
|
|
4
4
|
times?: number;
|
|
5
5
|
};
|
|
6
6
|
export declare class BenchmarkCommand extends CLICommand<Params> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLICommand } from '../../models/command';
|
|
2
2
|
import type { BuildCommand as BuildCommandType } from '../../api/build';
|
|
3
|
-
export
|
|
3
|
+
export type Params = Parameters<BuildCommandType>[0] & {
|
|
4
4
|
target: string;
|
|
5
5
|
};
|
|
6
6
|
declare class BuildCommand extends CLICommand<Params> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLICommand } from '../../models/command';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type GeneratorName = 'action' | 'reducer' | 'component' | 'page' | 'bundle' | 'module';
|
|
3
|
+
export type Params = {
|
|
4
4
|
generator?: GeneratorName;
|
|
5
5
|
target?: string;
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PlopGeneratorConfig } from 'node-plop';
|
|
2
2
|
import type { ConfigEntry } from '../../../typings/configEntry/common';
|
|
3
|
-
export
|
|
3
|
+
export type GeneratorFactoryArgs = {
|
|
4
4
|
configEntry: ConfigEntry;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type GeneratorFactory = (args: GeneratorFactoryArgs) => PlopGeneratorConfig;
|
|
@@ -2,8 +2,8 @@ import type { Type } from './questions/type';
|
|
|
2
2
|
import type { Templates } from './questions/template';
|
|
3
3
|
import type { PackageManagers } from './questions/packageManager';
|
|
4
4
|
import type { TestingFrameworks } from './questions/testingFramework';
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type GeneratingType = 'application' | 'module' | 'package';
|
|
6
|
+
export type Params = {
|
|
7
7
|
name: string;
|
|
8
8
|
target: GeneratingType;
|
|
9
9
|
type: Type;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLICommand } from '../../models/command';
|
|
2
2
|
import type { StartCommand as StartCommandType } from '../../api/start';
|
|
3
|
-
export
|
|
3
|
+
export type Params = Parameters<StartCommandType>[0] & {
|
|
4
4
|
target: string;
|
|
5
5
|
};
|
|
6
6
|
export declare class StartCommand extends CLICommand<Params> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context } from '../../models/context';
|
|
2
2
|
import type { CommandResult } from '../../models/command';
|
|
3
|
-
export
|
|
3
|
+
export type Params = {
|
|
4
4
|
to: string;
|
|
5
5
|
};
|
|
6
|
-
declare const _default: (context: Context, { to }: Params) => Promise<CommandResult>;
|
|
6
|
+
declare const _default: (context: Context, { to: version }: Params) => Promise<CommandResult>;
|
|
7
7
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
2
|
import { DI_TOKEN } from '@tinkoff/dippy';
|
|
3
3
|
import { COMMAND_RUNNER_TOKEN, COMMAND_MAP_TOKEN } from '../tokens';
|
|
4
|
-
|
|
4
|
+
type Interface = typeof COMMAND_RUNNER_TOKEN;
|
|
5
5
|
export declare class CommandRunner implements Interface {
|
|
6
6
|
commands: typeof COMMAND_MAP_TOKEN;
|
|
7
7
|
rootContainer: typeof DI_TOKEN;
|
package/lib/external/pages.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { LazyComponentWrapper, PageComponent } from '@tramvai/react';
|
|
1
|
+
import type { LazyComponentWrapper, NestedLayoutComponent, PageComponent } from '@tramvai/react';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
routes: Record<string, LazyComponentWrapper<PageComponent>>;
|
|
4
4
|
pages: Record<string, LazyComponentWrapper<PageComponent>>;
|
|
5
|
+
layouts: Record<string, LazyComponentWrapper<NestedLayoutComponent>>;
|
|
5
6
|
};
|
|
6
7
|
export default _default;
|
package/lib/external/pages.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../../src/external/pages.ts"],"names":[],"mappings":";;AAEA,oDAAoD;AACpD,kBAAe;IACb,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../../src/external/pages.ts"],"names":[],"mappings":";;AAEA,oDAAoD;AACpD,kBAAe;IACb,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;CAKZ,CAAC"}
|
|
@@ -8,7 +8,7 @@ interface BabelConfig {
|
|
|
8
8
|
generateDataQaTag?: boolean;
|
|
9
9
|
enableFillActionNamePlugin?: boolean;
|
|
10
10
|
typescript?: boolean;
|
|
11
|
-
modules?: string |
|
|
11
|
+
modules?: string | false;
|
|
12
12
|
loader?: boolean;
|
|
13
13
|
useESModules?: boolean;
|
|
14
14
|
removeTypeofWindow?: boolean;
|
|
@@ -23,7 +23,7 @@ export declare const babelConfigFactory: ({ env, target, modern, isServer, modul
|
|
|
23
23
|
compact: boolean;
|
|
24
24
|
sourceType: "unambiguous";
|
|
25
25
|
presets: (string | (string | {
|
|
26
|
-
modules: string |
|
|
26
|
+
modules: string | false;
|
|
27
27
|
useBuiltIns: string;
|
|
28
28
|
corejs: string;
|
|
29
29
|
loose: boolean;
|
|
@@ -58,7 +58,7 @@ export declare const babelConfigFactory: ({ env, target, modern, isServer, modul
|
|
|
58
58
|
compact?: undefined;
|
|
59
59
|
sourceType: "unambiguous";
|
|
60
60
|
presets: (string | (string | {
|
|
61
|
-
modules: string |
|
|
61
|
+
modules: string | false;
|
|
62
62
|
useBuiltIns: string;
|
|
63
63
|
corejs: string;
|
|
64
64
|
loose: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { types, template, NodePath } from '@babel/core';
|
|
2
2
|
import type { FunctionExpression, CallExpression, ObjectMember, ArrowFunctionExpression } from '@babel/types';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
3
|
+
export type LazyCallPath = NodePath<CallExpression>;
|
|
4
|
+
export type FuncPath = NodePath<FunctionExpression | ArrowFunctionExpression>;
|
|
5
|
+
export type ImportPath = NodePath<CallExpression>;
|
|
6
|
+
export type PropertyFactory = (arg: {
|
|
7
7
|
types: typeof types;
|
|
8
8
|
template: typeof template;
|
|
9
9
|
}) => (arg: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PlopGenerator } from 'node-plop';
|
|
2
|
-
|
|
2
|
+
type RunActionsResult = ReturnType<PlopGenerator['runActions']> extends Promise<infer Result> ? Result : any;
|
|
3
3
|
export declare function printActionsResult({ changes, failures }: RunActionsResult): void;
|
|
4
4
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Config } from '@swc/core';
|
|
1
2
|
import type { Env } from '../../typings/Env';
|
|
2
3
|
import type { Target } from '../../typings/target';
|
|
3
4
|
interface SWCConfig {
|
|
@@ -6,7 +7,7 @@ interface SWCConfig {
|
|
|
6
7
|
modern?: boolean;
|
|
7
8
|
isServer?: boolean;
|
|
8
9
|
typescript?: boolean;
|
|
9
|
-
modules?:
|
|
10
|
+
modules?: Config['module']['type'] | false;
|
|
10
11
|
removeTypeofWindow?: boolean;
|
|
11
12
|
alias?: Record<string, any>;
|
|
12
13
|
bugfixes?: boolean;
|
|
@@ -14,37 +15,5 @@ interface SWCConfig {
|
|
|
14
15
|
hot?: boolean;
|
|
15
16
|
rootDir?: string;
|
|
16
17
|
}
|
|
17
|
-
export declare const getSwcOptions: ({ env, target, modern, isServer, modules, typescript, hot, rootDir, }: SWCConfig) =>
|
|
18
|
-
env: {
|
|
19
|
-
targets: string[];
|
|
20
|
-
corejs: string;
|
|
21
|
-
loose: boolean;
|
|
22
|
-
mode: string;
|
|
23
|
-
};
|
|
24
|
-
module: {
|
|
25
|
-
type: string | true;
|
|
26
|
-
};
|
|
27
|
-
jsc: {
|
|
28
|
-
parser: {
|
|
29
|
-
syntax: string;
|
|
30
|
-
decorators: boolean;
|
|
31
|
-
};
|
|
32
|
-
transform: {
|
|
33
|
-
legacyDecorator: boolean;
|
|
34
|
-
react: {
|
|
35
|
-
runtime: string;
|
|
36
|
-
useSpread: boolean;
|
|
37
|
-
development: boolean;
|
|
38
|
-
refresh: boolean;
|
|
39
|
-
};
|
|
40
|
-
optimizer: {
|
|
41
|
-
globals: {
|
|
42
|
-
typeofs: {
|
|
43
|
-
window: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
};
|
|
18
|
+
export declare const getSwcOptions: ({ env, target, modern, isServer, modules, typescript, hot, rootDir, }: SWCConfig) => Config;
|
|
50
19
|
export {};
|
package/lib/library/swc/index.js
CHANGED
|
@@ -5,17 +5,37 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const browserslist_1 = tslib_1.__importDefault(require("browserslist"));
|
|
6
6
|
const browserslist_config_1 = tslib_1.__importDefault(require("@tinkoff/browserslist-config"));
|
|
7
7
|
const resolve_1 = require("resolve");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
(0, resolve_1.sync)('react/jsx-runtime', { basedir: process.cwd() });
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch (e) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
8
|
+
const find_cache_dir_1 = tslib_1.__importDefault(require("find-cache-dir"));
|
|
9
|
+
const TRAMVAI_SWC_TARGET_PATH = '@tramvai/swc-integration/target/wasm32-wasi';
|
|
17
10
|
const getSwcOptions = ({ env = 'development', target, modern, isServer = false, modules = false, typescript = false, hot = false, rootDir = process.cwd(), }) => {
|
|
18
11
|
var _a, _b;
|
|
12
|
+
const resolveWasmFile = (pluginName, type) => {
|
|
13
|
+
return (0, resolve_1.sync)(`${TRAMVAI_SWC_TARGET_PATH}/${type}/${pluginName}.wasm`, {
|
|
14
|
+
basedir: rootDir,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const resolveTramvaiSwcPlugin = (pluginName) => {
|
|
18
|
+
try {
|
|
19
|
+
return resolveWasmFile(pluginName, 'debug');
|
|
20
|
+
}
|
|
21
|
+
catch (_) {
|
|
22
|
+
try {
|
|
23
|
+
return resolveWasmFile(pluginName, 'release');
|
|
24
|
+
}
|
|
25
|
+
catch (__) {
|
|
26
|
+
throw new Error(`Cannot find tramvai swc-plugin "${pluginName}" related to the "${rootDir}" directory`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function hasJsxRuntime() {
|
|
31
|
+
try {
|
|
32
|
+
(0, resolve_1.sync)('react/jsx-runtime', { basedir: rootDir });
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
19
39
|
let resultTarget = target;
|
|
20
40
|
if (!target) {
|
|
21
41
|
if (isServer) {
|
|
@@ -35,7 +55,7 @@ const getSwcOptions = ({ env = 'development', target, modern, isServer = false,
|
|
|
35
55
|
return {
|
|
36
56
|
env: {
|
|
37
57
|
targets,
|
|
38
|
-
|
|
58
|
+
coreJs: '3',
|
|
39
59
|
loose: true,
|
|
40
60
|
mode: 'entry',
|
|
41
61
|
},
|
|
@@ -53,18 +73,26 @@ const getSwcOptions = ({ env = 'development', target, modern, isServer = false,
|
|
|
53
73
|
legacyDecorator: true,
|
|
54
74
|
react: {
|
|
55
75
|
runtime: hasJsxRuntime() ? 'automatic' : 'classic',
|
|
56
|
-
useSpread: true,
|
|
57
76
|
development: env === 'development',
|
|
58
77
|
refresh: hot && !isServer,
|
|
59
78
|
},
|
|
60
79
|
optimizer: {
|
|
61
80
|
globals: {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
// TODO: there is not typings for typeofs, but the field is mentioned in docs
|
|
62
83
|
typeofs: {
|
|
63
84
|
window: isServer ? 'undefined' : 'object',
|
|
64
85
|
},
|
|
65
86
|
},
|
|
66
87
|
},
|
|
67
88
|
},
|
|
89
|
+
experimental: {
|
|
90
|
+
cacheRoot: (0, find_cache_dir_1.default)({ cwd: rootDir, name: 'swc' }),
|
|
91
|
+
plugins: [
|
|
92
|
+
[resolveTramvaiSwcPlugin('create_token_pure'), {}],
|
|
93
|
+
[resolveTramvaiSwcPlugin('lazy_component'), {}],
|
|
94
|
+
],
|
|
95
|
+
},
|
|
68
96
|
},
|
|
69
97
|
};
|
|
70
98
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/library/swc/index.ts"],"names":[],"mappings":";;;;AAAA,wEAAwC;AACxC,+FAAsD;AACtD,qCAA0C;
|
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iBACF;aACF;YACD,YAAY,EAAE;gBACZ,SAAS,EAAE,IAAA,wBAAY,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gBACtD,OAAO,EAAE;oBACP,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,EAAE,EAAE,CAAC;oBAClD,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC;iBAChD;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAtGW,QAAA,aAAa,iBAsGxB"}
|
|
@@ -17,7 +17,7 @@ exports.default = (configManager) => (config) => {
|
|
|
17
17
|
.loader('thread-loader')
|
|
18
18
|
.options((0, workersPool_1.createWorkerPoolBabel)(configManager))
|
|
19
19
|
.end())
|
|
20
|
-
.use('
|
|
20
|
+
.use('transpiler');
|
|
21
21
|
return (0, transpiler_1.addTranspilerLoader)(configManager, cfg, babelCfg);
|
|
22
22
|
};
|
|
23
23
|
if (transpileOnlyModernLibs) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js.js","sourceRoot":"","sources":["../../../../src/library/webpack/blocks/js.ts"],"names":[],"mappings":";;AACA,0DAA0D;AAE1D,sDAA6D;AAE7D,oDAA+E;AAE/E,oDAAoD;AACpD,kBAAe,CAAC,aAA4B,EAAE,EAAE,CAAC,CAAC,MAAc,EAAE,EAAE;IAClE,MAAM,gBAAgB,GAAG,IAAA,gCAAmB,EAAC,aAAa,CAAC,CAAC;IAC5D,MAAM,EAAE,uBAAuB,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,cAAc,CAAC;IAEvE,MAAM,MAAM,GAAG,CAAC,QAA2C,EAAE,EAAE,CAAC,CAAC,IAAiB,EAAE,EAAE;QACpF,MAAM,GAAG,GAAG,IAAI;aACb,IAAI,CAAC,gBAAgB,CAAC;aACtB,KAAK,CAAC,SAAS,CAAC;YACjB,6DAA6D;aAC5D,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,O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CAAC,YAAY,CAAC;aAClB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;aAC3B,GAAG,EAAE;aACL,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAEnC,MAAM,CAAC,MAAM;aACV,IAAI,CAAC,iBAAiB,CAAC;aACvB,OAAO,CAAC,GAAG,CAAC,gCAAgB,CAAC;aAC7B,GAAG,EAAE;aACL,KAAK,CAAC,MAAM,iCAAM,gBAAgB,KAAE,GAAG,EAAE,KAAK,IAAG,CAAC;aAClD,KAAK,CAAC;YACL,sEAAsE;YACtE,8CAA8C;YAC9C,OAAO,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE;SACnC,CAAC,CAAC;KACN;SAAM;QACL,MAAM,CAAC,MAAM;aACV,IAAI,CAAC,YAAY,CAAC;aAClB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;aAC3B,GAAG,EAAE;aACL,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAEnC,MAAM,CAAC,MAAM;aACV,IAAI,CAAC,iBAAiB,CAAC;aACvB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;aAC3B,GAAG,EAAE;aACL,KAAK,CAAC,MAAM,iCAAM,gBAAgB,KAAE,GAAG,EAAE,KAAK,IAAG,CAAC;aAClD,KAAK,CAAC;YACL,sEAAsE;YACtE,8CAA8C;YAC9C,OAAO,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE;SACnC,CAAC,CAAC;KACN;AACH,CAAC,CAAC"}
|
|
@@ -12,7 +12,7 @@ exports.default = (configManager) => (config) => {
|
|
|
12
12
|
.oneOf('default')
|
|
13
13
|
// TODO разобраться почему на винде все плохо с thread-loader
|
|
14
14
|
.when(process.platform !== 'win32', (cfg) => cfg.use('thread').loader('thread-loader').options((0, workersPool_1.createWorkerPoolBabel)(configManager)).end())
|
|
15
|
-
.use('
|
|
15
|
+
.use('transpiler');
|
|
16
16
|
return (0, transpiler_1.addTranspilerLoader)(configManager, cfg, transpilerConfig);
|
|
17
17
|
};
|
|
18
18
|
//# sourceMappingURL=ts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts.js","sourceRoot":"","sources":["../../../../src/library/webpack/blocks/ts.ts"],"names":[],"mappings":";;AACA,sDAA6D;AAE7D,oDAA+E;AAE/E,kBAAe,CAAC,aAA4B,EAAE,EAAE,CAAC,CAAC,MAAc,EAAE,EAAE;IAClE,MAAM,gBAAgB,mCAAQ,IAAA,gCAAmB,EAAC,aAAa,CAAC,KAAE,UAAU,EAAE,IAAI,GAAE,CAAC;IAErF,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM;SACtB,IAAI,CAAC,YAAY,CAAC;SAClB,IAAI,CAAC,WAAW,CAAC;SACjB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;SAC3B,GAAG,EAAE;SACL,KAAK,CAAC,SAAS,CAAC;QACjB,6DAA6D;SAC5D,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAC1C,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,IAAA,mCAAqB,EAAC,aAAa,CAAC,CAAC,CAAC,GAAG,EAAE,CAC9F;SACA,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"ts.js","sourceRoot":"","sources":["../../../../src/library/webpack/blocks/ts.ts"],"names":[],"mappings":";;AACA,sDAA6D;AAE7D,oDAA+E;AAE/E,kBAAe,CAAC,aAA4B,EAAE,EAAE,CAAC,CAAC,MAAc,EAAE,EAAE;IAClE,MAAM,gBAAgB,mCAAQ,IAAA,gCAAmB,EAAC,aAAa,CAAC,KAAE,UAAU,EAAE,IAAI,GAAE,CAAC;IAErF,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM;SACtB,IAAI,CAAC,YAAY,CAAC;SAClB,IAAI,CAAC,WAAW,CAAC;SACjB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;SAC3B,GAAG,EAAE;SACL,KAAK,CAAC,SAAS,CAAC;QACjB,6DAA6D;SAC5D,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAC1C,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,IAAA,mCAAqB,EAAC,aAAa,CAAC,CAAC,CAAC,GAAG,EAAE,CAC9F;SACA,GAAG,CAAC,YAAY,CAAC,CAAC;IAErB,OAAO,IAAA,gCAAmB,EAAC,aAAa,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;AACnE,CAAC,CAAC"}
|
|
@@ -3,10 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
5
|
const fs_readdir_recursive_1 = tslib_1.__importDefault(require("fs-readdir-recursive"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
|
+
const LAYOUT_FILENAME = '_layout.tsx';
|
|
6
8
|
function default_1() {
|
|
7
9
|
const { fileSystemPages, rootDir, root, extensions } = this.getOptions();
|
|
10
|
+
const fsLayouts = [];
|
|
8
11
|
this.cacheable(false);
|
|
9
|
-
const filesToPages = ({ pagesRootDirectory }) => {
|
|
12
|
+
const filesToPages = ({ pagesRootDirectory, isRoutes = false, }) => {
|
|
10
13
|
const pagesDir = path_1.default.resolve(rootDir, root, pagesRootDirectory);
|
|
11
14
|
this.addContextDependency(pagesDir);
|
|
12
15
|
// skip files whose name starts with dot or underscore symbols
|
|
@@ -21,6 +24,13 @@ function default_1() {
|
|
|
21
24
|
const pageComponentChunkName = pageComponentName.replace(/\//g, '_');
|
|
22
25
|
// @example '@/pages/MainPage': lazy(() => import(/* webpackChunkName: "@_pages_MainPage" */ '/tramvai-app/src/pages/MainPage'))
|
|
23
26
|
fsPages.push(`'${pageComponentName}': lazy(() => import(/* webpackChunkName: "${pageComponentChunkName}" */ '${pageComponentPath}'))`);
|
|
27
|
+
if (isRoutes) {
|
|
28
|
+
const layoutPath = path_1.default.join(path_1.default.dirname(pageComponentPath), LAYOUT_FILENAME);
|
|
29
|
+
if (fs_1.default.existsSync(layoutPath)) {
|
|
30
|
+
// @example '@/pages/MainPage': lazy(() => import(/* webpackChunkName: "@_pages_MainPage_layout" */ '/tramvai-app/src/pages/MainPage_layout'))
|
|
31
|
+
fsLayouts.push(`'${pageComponentName}': lazy(() => import(/* webpackChunkName: "${pageComponentChunkName}__layout" */ '${layoutPath.replace('.tsx', '')}'))`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
24
34
|
}
|
|
25
35
|
}
|
|
26
36
|
return fsPages;
|
|
@@ -28,6 +38,7 @@ function default_1() {
|
|
|
28
38
|
const fsRoutes = fileSystemPages.routesDir
|
|
29
39
|
? filesToPages({
|
|
30
40
|
pagesRootDirectory: fileSystemPages.routesDir,
|
|
41
|
+
isRoutes: true,
|
|
31
42
|
})
|
|
32
43
|
: [];
|
|
33
44
|
const fsPages = fileSystemPages.pagesDir
|
|
@@ -44,6 +55,9 @@ export default {
|
|
|
44
55
|
pages: {
|
|
45
56
|
${fsPages.join(',\n')}
|
|
46
57
|
},
|
|
58
|
+
layouts: {
|
|
59
|
+
${fsLayouts.join(',\n')}
|
|
60
|
+
},
|
|
47
61
|
}`;
|
|
48
62
|
return code;
|
|
49
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagesResolve.js","sourceRoot":"","sources":["../../../../src/library/webpack/loaders/pagesResolve.ts"],"names":[],"mappings":";;;AAAA,wDAAwB;AACxB,wFAA2C;
|
|
1
|
+
{"version":3,"file":"pagesResolve.js","sourceRoot":"","sources":["../../../../src/library/webpack/loaders/pagesResolve.ts"],"names":[],"mappings":";;;AAAA,wDAAwB;AACxB,wFAA2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ativePath?: string;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export
|
|
17
|
+
export type DeduplicateStrategy = 'equality' | 'semver';
|
|
18
18
|
export declare class DedupePlugin {
|
|
19
19
|
private readonly strategy;
|
|
20
20
|
private readonly ignorePackages?;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { container, Configuration } from 'webpack';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export type ModuleFederationPluginOptions = ConstructorParameters<typeof container.ModuleFederationPlugin>[0];
|
|
3
|
+
export type ModuleFederationSharedObject = Record<string, Exclude<Exclude<ModuleFederationPluginOptions['shared'], any[]>[string], string>>;
|
|
4
|
+
export type SplitChunksOptions = Configuration['optimization']['splitChunks'];
|
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTranspilerConfig = exports.addTranspilerLoader = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const resolve_1 = require("resolve");
|
|
5
6
|
const swc_1 = require("../../swc");
|
|
6
7
|
const babel_1 = tslib_1.__importDefault(require("../../babel"));
|
|
7
8
|
const addTranspilerLoader = (configManager, rule, transpilerConfig) => {
|
|
8
9
|
const { loader } = configManager.experiments.transpilation;
|
|
9
10
|
if (loader === 'swc') {
|
|
11
|
+
try {
|
|
12
|
+
(0, resolve_1.sync)('@tramvai/swc-integration/package.json', { basedir: configManager.rootDir });
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
throw new Error(`You are using swc loader for the transpilation, but required module is not installed.
|
|
16
|
+
Please run "tramvai add --dev @tramvai/swc-integration" to fix the problem
|
|
17
|
+
`);
|
|
18
|
+
}
|
|
10
19
|
return rule.loader('swc-loader').options((0, swc_1.getSwcOptions)(transpilerConfig)).end();
|
|
11
20
|
}
|
|
12
21
|
if (loader === 'babel') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpiler.js","sourceRoot":"","sources":["../../../../src/library/webpack/utils/transpiler.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"transpiler.js","sourceRoot":"","sources":["../../../../src/library/webpack/utils/transpiler.ts"],"names":[],"mappings":";;;;AACA,qCAA0C;AAE1C,mCAA0C;AAC1C,gEAAsC;AAE/B,MAAM,mBAAmB,GAAG,CACjC,aAA4B,EAC5B,IAAgB,EAChB,gBAAqC,EACrC,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC;IAE3D,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,IAAI;YACF,IAAA,cAAO,EAAC,uCAAuC,EAAE,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;SACtF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC;;OAEf,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,IAAA,mBAAa,EAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;KACjF;IAED,IAAI,MAAM,KAAK,OAAO,EAAE;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,IAAA,eAAW,EAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;KACjF;AACH,CAAC,CAAC;AAtBW,QAAA,mBAAmB,uBAsB9B;AAEK,MAAM,mBAAmB,GAAG,CAAC,aAA4B,EAAE,EAAE;IAClE,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,GAChF,aAAa,CAAC,KAAK,CAAC,cAAc,CAAC;IACrC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC;IAEtC,OAAO;QACL,QAAQ,EAAE,aAAa,CAAC,SAAS,KAAK,QAAQ;QAC9C,GAAG;QACH,iBAAiB;QACjB,MAAM;QACN,KAAK;QACL,OAAO,EAAE,IAAI;QACb,kBAAkB;QAClB,GAAG,EAAE,aAAa,CAAC,UAAU;QAC7B,iBAAiB,EAAE,aAAa,CAAC,KAAK,CAAC,cAAc,CAAC,iBAAiB;QACvE,0BAA0B;QAC1B,OAAO,EAAE,aAAa,CAAC,OAAO;QAC9B,MAAM,EAAE,aAAa,CAAC,MAAM;KAC7B,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,mBAAmB,uBAmB9B"}
|
package/lib/models/command.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from './context';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type CommandConstructor = new (context: Context) => CLICommand;
|
|
3
|
+
export type CommandMap = CommandConstructor[];
|
|
4
4
|
export interface CommandResult {
|
|
5
5
|
status: string;
|
|
6
6
|
message?: string;
|
|
@@ -12,7 +12,7 @@ export interface Option {
|
|
|
12
12
|
readonly defaultValue?: any;
|
|
13
13
|
readonly transformer?: (...arg: any[]) => any;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
type validator<TParams> = (context: Context, parameters: TParams) => Promise<{
|
|
16
16
|
name: string;
|
|
17
17
|
status: string;
|
|
18
18
|
message?: string;
|
package/lib/models/task.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CommonOptions } from 'execa';
|
|
2
2
|
import execa from 'execa';
|
|
3
3
|
import type { Context } from './context';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type TaskConstructor = new (context: Context) => Task;
|
|
5
|
+
export type TaskMap = TaskConstructor[];
|
|
6
6
|
export interface TaskResult {
|
|
7
7
|
status: string;
|
|
8
8
|
code: number;
|
|
@@ -12,7 +12,7 @@ import type { ChildAppConfigEntry } from '../typings/configEntry/child-app';
|
|
|
12
12
|
* поэтому генерируем параллельно конфиги для разных типов приложений,
|
|
13
13
|
* которые можно использовать как угодно, в том числе внутри conditional веток с ключевыми словами `if`, `then`, `else`
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type ConfigSchema = {
|
|
16
16
|
application: ApplicationConfigEntry;
|
|
17
17
|
module: ModuleConfigEntry;
|
|
18
18
|
'child-app': ChildAppConfigEntry;
|
package/lib/typings/Env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Env = 'development' | 'production';
|
|
@@ -26,12 +26,12 @@ interface BuilderAnalyzeOptions {
|
|
|
26
26
|
modern?: boolean;
|
|
27
27
|
plugin?: string;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
29
|
+
export type GetBuildStats = () => {
|
|
30
30
|
clientBuildTime?: number;
|
|
31
31
|
clientModernBuildTime?: number;
|
|
32
32
|
serverBuildTime?: number;
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type BuildType = 'client' | 'server' | 'clientModern';
|
|
35
35
|
export interface BuilderEvents {
|
|
36
36
|
invalid: [];
|
|
37
37
|
done: [];
|
|
@@ -86,7 +86,7 @@ export interface ApplicationBuild {
|
|
|
86
86
|
postcss?: ConfigEntry['commands']['build']['configurations']['postcss'];
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
export
|
|
89
|
+
export type ApplicationServe = ConfigEntry['commands']['serve'] & {
|
|
90
90
|
/**
|
|
91
91
|
* @default {}
|
|
92
92
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Configuration } from 'webpack';
|
|
2
2
|
import type { ProjectType } from '../projectType';
|
|
3
3
|
import type { DeduplicateStrategy } from '../../library/webpack/plugins/DedupePlugin';
|
|
4
|
-
|
|
4
|
+
type ServeNotifications = {
|
|
5
5
|
/**
|
|
6
6
|
* @title Defines when success notifications are shown
|
|
7
7
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ConfigEntry } from './configEntry/common';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export type ProjectType = 'application' | 'module' | 'package' | 'child-app';
|
|
3
|
+
export type BuildType = 'server' | 'client';
|
|
4
|
+
export type SyncJsonFile = ({ path, newContent, }: {
|
|
5
5
|
path: string;
|
|
6
6
|
newContent: any;
|
|
7
7
|
}) => Promise<void>;
|
|
8
|
-
export
|
|
8
|
+
export type Config = {
|
|
9
9
|
projectsConfig?: any;
|
|
10
10
|
$schema?: string;
|
|
11
11
|
projects: {
|
package/lib/typings/public.d.ts
CHANGED
package/lib/typings/target.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Target = 'modern' | 'node' | 'defaults';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from '../../models/context';
|
|
2
|
-
export
|
|
2
|
+
export type Validator = (context: Context, parameters: any) => Promise<{
|
|
3
3
|
name: string;
|
|
4
4
|
status: 'ok' | 'warning' | 'error';
|
|
5
5
|
message?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.45.0",
|
|
4
4
|
"description": "Cli инструмент для сборки и запуска приложений",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@tinkoff/request-plugin-protocol-http": "^0.11.6",
|
|
70
70
|
"@tinkoff/utils": "^2.1.3",
|
|
71
71
|
"@tramvai/build": "3.0.6",
|
|
72
|
-
"@tramvai/react": "2.
|
|
72
|
+
"@tramvai/react": "2.45.0",
|
|
73
73
|
"@tramvai/tools-check-versions": "0.4.5",
|
|
74
74
|
"@tramvai/tools-migrate": "0.6.6",
|
|
75
75
|
"ajv": "^6.12.6",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"v8-compile-cache": "^2.3.0",
|
|
149
149
|
"validate-npm-package-name": "^3.0.0",
|
|
150
150
|
"wait-on": "^5.3.0",
|
|
151
|
-
"webpack": "5.
|
|
151
|
+
"webpack": "5.75.0",
|
|
152
152
|
"webpack-build-notifier": "^2.3.0",
|
|
153
153
|
"webpack-bundle-analyzer": "^4.6.1",
|
|
154
154
|
"webpack-chain": "^6.5.1",
|
|
@@ -159,6 +159,7 @@
|
|
|
159
159
|
"wrap-ansi": "^7.0.0"
|
|
160
160
|
},
|
|
161
161
|
"devDependencies": {
|
|
162
|
+
"@swc/core": "^1.3.16",
|
|
162
163
|
"@tramvai/tools-generate-schema": "0.1.3",
|
|
163
164
|
"@types/compression": "^1.7.2",
|
|
164
165
|
"@types/express": "^4.17.13",
|
|
@@ -180,10 +181,7 @@
|
|
|
180
181
|
"react": "18.2.0"
|
|
181
182
|
},
|
|
182
183
|
"hiddenDependencies": {
|
|
183
|
-
"
|
|
184
|
-
"@swc/helpers": "^0.3.2",
|
|
185
|
-
"image-webpack-loader": "^6.0.0",
|
|
186
|
-
"swc-loader": "^0.1.15"
|
|
184
|
+
"image-webpack-loader": "^6.0.0"
|
|
187
185
|
},
|
|
188
186
|
"license": "Apache-2.0",
|
|
189
187
|
"engines": {
|
package/src/external/pages.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { LazyComponentWrapper, PageComponent } from '@tramvai/react';
|
|
1
|
+
import type { LazyComponentWrapper, NestedLayoutComponent, PageComponent } from '@tramvai/react';
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line import/no-default-export
|
|
4
4
|
export default {
|
|
5
5
|
routes: {},
|
|
6
6
|
pages: {},
|
|
7
|
+
layouts: {},
|
|
7
8
|
} as {
|
|
8
9
|
routes: Record<string, LazyComponentWrapper<PageComponent>>;
|
|
9
10
|
pages: Record<string, LazyComponentWrapper<PageComponent>>;
|
|
11
|
+
layouts: Record<string, LazyComponentWrapper<NestedLayoutComponent>>;
|
|
10
12
|
};
|
|
@@ -27,7 +27,7 @@ interface BabelConfig {
|
|
|
27
27
|
generateDataQaTag?: boolean;
|
|
28
28
|
enableFillActionNamePlugin?: boolean;
|
|
29
29
|
typescript?: boolean;
|
|
30
|
-
modules?: string |
|
|
30
|
+
modules?: string | false;
|
|
31
31
|
loader?: boolean;
|
|
32
32
|
useESModules?: boolean;
|
|
33
33
|
removeTypeofWindow?: boolean;
|
package/src/library/swc/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import browserslist from 'browserslist';
|
|
2
2
|
import envTargets from '@tinkoff/browserslist-config';
|
|
3
3
|
import { sync as resolve } from 'resolve';
|
|
4
|
+
import findCacheDir from 'find-cache-dir';
|
|
5
|
+
import type { Config } from '@swc/core';
|
|
4
6
|
import type { Env } from '../../typings/Env';
|
|
5
7
|
import type { Target } from '../../typings/target';
|
|
6
8
|
|
|
@@ -10,7 +12,7 @@ interface SWCConfig {
|
|
|
10
12
|
modern?: boolean;
|
|
11
13
|
isServer?: boolean;
|
|
12
14
|
typescript?: boolean;
|
|
13
|
-
modules?:
|
|
15
|
+
modules?: Config['module']['type'] | false;
|
|
14
16
|
removeTypeofWindow?: boolean;
|
|
15
17
|
alias?: Record<string, any>;
|
|
16
18
|
bugfixes?: boolean; // https://babeljs.io/docs/en/babel-preset-env#bugfixes
|
|
@@ -19,14 +21,8 @@ interface SWCConfig {
|
|
|
19
21
|
rootDir?: string;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
resolve('react/jsx-runtime', { basedir: process.cwd() });
|
|
25
|
-
return true;
|
|
26
|
-
} catch (e) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
24
|
+
const TRAMVAI_SWC_TARGET_PATH = '@tramvai/swc-integration/target/wasm32-wasi';
|
|
25
|
+
|
|
30
26
|
export const getSwcOptions = ({
|
|
31
27
|
env = 'development',
|
|
32
28
|
target,
|
|
@@ -36,7 +32,35 @@ export const getSwcOptions = ({
|
|
|
36
32
|
typescript = false,
|
|
37
33
|
hot = false,
|
|
38
34
|
rootDir = process.cwd(),
|
|
39
|
-
}: SWCConfig) => {
|
|
35
|
+
}: SWCConfig): Config => {
|
|
36
|
+
const resolveWasmFile = (pluginName: string, type: 'debug' | 'release') => {
|
|
37
|
+
return resolve(`${TRAMVAI_SWC_TARGET_PATH}/${type}/${pluginName}.wasm`, {
|
|
38
|
+
basedir: rootDir,
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const resolveTramvaiSwcPlugin = (pluginName: string) => {
|
|
43
|
+
try {
|
|
44
|
+
return resolveWasmFile(pluginName, 'debug');
|
|
45
|
+
} catch (_) {
|
|
46
|
+
try {
|
|
47
|
+
return resolveWasmFile(pluginName, 'release');
|
|
48
|
+
} catch (__) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Cannot find tramvai swc-plugin "${pluginName}" related to the "${rootDir}" directory`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function hasJsxRuntime() {
|
|
56
|
+
try {
|
|
57
|
+
resolve('react/jsx-runtime', { basedir: rootDir });
|
|
58
|
+
return true;
|
|
59
|
+
} catch (e) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
40
64
|
let resultTarget = target;
|
|
41
65
|
|
|
42
66
|
if (!target) {
|
|
@@ -61,7 +85,7 @@ export const getSwcOptions = ({
|
|
|
61
85
|
return {
|
|
62
86
|
env: {
|
|
63
87
|
targets,
|
|
64
|
-
|
|
88
|
+
coreJs: '3',
|
|
65
89
|
loose: true,
|
|
66
90
|
mode: 'entry',
|
|
67
91
|
},
|
|
@@ -79,18 +103,26 @@ export const getSwcOptions = ({
|
|
|
79
103
|
legacyDecorator: true,
|
|
80
104
|
react: {
|
|
81
105
|
runtime: hasJsxRuntime() ? 'automatic' : 'classic',
|
|
82
|
-
useSpread: true,
|
|
83
106
|
development: env === 'development',
|
|
84
107
|
refresh: hot && !isServer,
|
|
85
108
|
},
|
|
86
109
|
optimizer: {
|
|
87
110
|
globals: {
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
// TODO: there is not typings for typeofs, but the field is mentioned in docs
|
|
88
113
|
typeofs: {
|
|
89
114
|
window: isServer ? 'undefined' : 'object',
|
|
90
115
|
},
|
|
91
116
|
},
|
|
92
117
|
},
|
|
93
118
|
},
|
|
119
|
+
experimental: {
|
|
120
|
+
cacheRoot: findCacheDir({ cwd: rootDir, name: 'swc' }),
|
|
121
|
+
plugins: [
|
|
122
|
+
[resolveTramvaiSwcPlugin('create_token_pure'), {}],
|
|
123
|
+
[resolveTramvaiSwcPlugin('lazy_component'), {}],
|
|
124
|
+
],
|
|
125
|
+
},
|
|
94
126
|
},
|
|
95
127
|
};
|
|
96
128
|
};
|
|
@@ -16,7 +16,7 @@ export default (configManager: ConfigManager) => (config: Config) => {
|
|
|
16
16
|
.when(process.platform !== 'win32', (cfg) =>
|
|
17
17
|
cfg.use('thread').loader('thread-loader').options(createWorkerPoolBabel(configManager)).end()
|
|
18
18
|
)
|
|
19
|
-
.use('
|
|
19
|
+
.use('transpiler');
|
|
20
20
|
|
|
21
21
|
return addTranspilerLoader(configManager, cfg, transpilerConfig);
|
|
22
22
|
};
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import readDir from 'fs-readdir-recursive';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
|
|
5
|
+
const LAYOUT_FILENAME = '_layout.tsx';
|
|
3
6
|
|
|
4
7
|
export default function () {
|
|
5
8
|
const { fileSystemPages, rootDir, root, extensions } = this.getOptions();
|
|
9
|
+
const fsLayouts = [];
|
|
6
10
|
|
|
7
11
|
this.cacheable(false);
|
|
8
12
|
|
|
9
|
-
const filesToPages = ({
|
|
13
|
+
const filesToPages = ({
|
|
14
|
+
pagesRootDirectory,
|
|
15
|
+
isRoutes = false,
|
|
16
|
+
}: {
|
|
17
|
+
pagesRootDirectory: string;
|
|
18
|
+
isRoutes?: boolean;
|
|
19
|
+
}) => {
|
|
10
20
|
const pagesDir = path.resolve(rootDir, root, pagesRootDirectory);
|
|
11
21
|
|
|
12
22
|
this.addContextDependency(pagesDir);
|
|
@@ -28,6 +38,20 @@ export default function () {
|
|
|
28
38
|
fsPages.push(
|
|
29
39
|
`'${pageComponentName}': lazy(() => import(/* webpackChunkName: "${pageComponentChunkName}" */ '${pageComponentPath}'))`
|
|
30
40
|
);
|
|
41
|
+
|
|
42
|
+
if (isRoutes) {
|
|
43
|
+
const layoutPath = path.join(path.dirname(pageComponentPath), LAYOUT_FILENAME);
|
|
44
|
+
|
|
45
|
+
if (fs.existsSync(layoutPath)) {
|
|
46
|
+
// @example '@/pages/MainPage': lazy(() => import(/* webpackChunkName: "@_pages_MainPage_layout" */ '/tramvai-app/src/pages/MainPage_layout'))
|
|
47
|
+
fsLayouts.push(
|
|
48
|
+
`'${pageComponentName}': lazy(() => import(/* webpackChunkName: "${pageComponentChunkName}__layout" */ '${layoutPath.replace(
|
|
49
|
+
'.tsx',
|
|
50
|
+
''
|
|
51
|
+
)}'))`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
31
55
|
}
|
|
32
56
|
}
|
|
33
57
|
|
|
@@ -37,6 +61,7 @@ export default function () {
|
|
|
37
61
|
const fsRoutes = fileSystemPages.routesDir
|
|
38
62
|
? filesToPages({
|
|
39
63
|
pagesRootDirectory: fileSystemPages.routesDir,
|
|
64
|
+
isRoutes: true,
|
|
40
65
|
})
|
|
41
66
|
: [];
|
|
42
67
|
const fsPages = fileSystemPages.pagesDir
|
|
@@ -54,6 +79,9 @@ export default {
|
|
|
54
79
|
pages: {
|
|
55
80
|
${fsPages.join(',\n')}
|
|
56
81
|
},
|
|
82
|
+
layouts: {
|
|
83
|
+
${fsLayouts.join(',\n')}
|
|
84
|
+
},
|
|
57
85
|
}`;
|
|
58
86
|
|
|
59
87
|
return code;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type Config from 'webpack-chain';
|
|
2
|
+
import { sync as resolve } from 'resolve';
|
|
2
3
|
import type { ConfigManager } from '../../../config/configManager';
|
|
3
4
|
import { getSwcOptions } from '../../swc';
|
|
4
5
|
import babelConfig from '../../babel';
|
|
@@ -11,6 +12,14 @@ export const addTranspilerLoader = (
|
|
|
11
12
|
const { loader } = configManager.experiments.transpilation;
|
|
12
13
|
|
|
13
14
|
if (loader === 'swc') {
|
|
15
|
+
try {
|
|
16
|
+
resolve('@tramvai/swc-integration/package.json', { basedir: configManager.rootDir });
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw new Error(`You are using swc loader for the transpilation, but required module is not installed.
|
|
19
|
+
Please run "tramvai add --dev @tramvai/swc-integration" to fix the problem
|
|
20
|
+
`);
|
|
21
|
+
}
|
|
22
|
+
|
|
14
23
|
return rule.loader('swc-loader').options(getSwcOptions(transpilerConfig)).end();
|
|
15
24
|
}
|
|
16
25
|
|