@gravity-ui/app-builder 0.9.3 → 0.9.5
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/dist/commands/build/build-service/server.js +9 -1
- package/dist/commands/dev/server.js +10 -2
- package/dist/common/webpack/config.d.ts +4 -1
- package/dist/common/webpack/config.js +8 -7
- package/dist/common/webpack/storybook.d.ts +5 -1
- package/dist/common/webpack/storybook.js +15 -4
- package/package.json +1 -1
|
@@ -12,7 +12,15 @@ function buildServer(config) {
|
|
|
12
12
|
(0, utils_1.createRunFolder)();
|
|
13
13
|
return new Promise((resolve, reject) => {
|
|
14
14
|
const build = new controllable_script_1.ControllableScript(`
|
|
15
|
-
|
|
15
|
+
let ts;
|
|
16
|
+
try {
|
|
17
|
+
ts = require('typescript');
|
|
18
|
+
} catch (e) {
|
|
19
|
+
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
ts = require(${JSON.stringify(require.resolve('typescript'))});
|
|
23
|
+
}
|
|
16
24
|
const {Logger} = require(${JSON.stringify(require.resolve('../../../common/logger'))});
|
|
17
25
|
const {compile} = require(${JSON.stringify(require.resolve('../../../common/typescript/compile'))});
|
|
18
26
|
|
|
@@ -37,7 +37,15 @@ function watchServerCompilation(config) {
|
|
|
37
37
|
rimraf_1.rimraf.sync(serverPath);
|
|
38
38
|
(0, utils_1.createRunFolder)();
|
|
39
39
|
const build = new controllable_script_1.ControllableScript(`
|
|
40
|
-
|
|
40
|
+
let ts;
|
|
41
|
+
try {
|
|
42
|
+
ts = require('typescript');
|
|
43
|
+
} catch (e) {
|
|
44
|
+
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
ts = require(${JSON.stringify(require.resolve('typescript'))});
|
|
48
|
+
}
|
|
41
49
|
const {Logger} = require(${JSON.stringify(require.resolve('../../common/logger'))});
|
|
42
50
|
const {watch} = require(${JSON.stringify(require.resolve('../../common/typescript/watch'))});
|
|
43
51
|
|
|
@@ -50,7 +58,7 @@ function watchServerCompilation(config) {
|
|
|
50
58
|
onAfterFilesEmitted: () => {
|
|
51
59
|
process.send({type: 'Emitted'});
|
|
52
60
|
},
|
|
53
|
-
enableSourceMap:
|
|
61
|
+
enableSourceMap: true
|
|
54
62
|
}
|
|
55
63
|
);
|
|
56
64
|
`, null);
|
|
@@ -20,5 +20,8 @@ export declare const enum WebpackMode {
|
|
|
20
20
|
export declare function webpackConfigFactory(webpackMode: WebpackMode, config: NormalizedClientConfig, { logger }?: {
|
|
21
21
|
logger?: Logger;
|
|
22
22
|
}): Promise<webpack.Configuration>;
|
|
23
|
-
export declare function configureModuleRules(helperOptions: HelperOptions): webpack.RuleSetRule[];
|
|
23
|
+
export declare function configureModuleRules(helperOptions: HelperOptions, additionalRules?: NonNullable<webpack.RuleSetRule['oneOf']>): webpack.RuleSetRule[];
|
|
24
24
|
export declare function configureResolve({ isEnvProduction, config, tsLinkedPackages, }: HelperOptions): webpack.ResolveOptions;
|
|
25
|
+
type Optimization = NonNullable<webpack.Configuration['optimization']>;
|
|
26
|
+
export declare function configureOptimization({ config }: HelperOptions): Optimization;
|
|
27
|
+
export {};
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.configureResolve = exports.configureModuleRules = exports.webpackConfigFactory = void 0;
|
|
29
|
+
exports.configureOptimization = exports.configureResolve = exports.configureModuleRules = exports.webpackConfigFactory = void 0;
|
|
30
30
|
/* eslint-disable complexity */
|
|
31
31
|
const path = __importStar(require("node:path"));
|
|
32
32
|
const fs = __importStar(require("node:fs"));
|
|
@@ -100,7 +100,7 @@ async function webpackConfigFactory(webpackMode, config, { logger } = {}) {
|
|
|
100
100
|
return webpackConfig;
|
|
101
101
|
}
|
|
102
102
|
exports.webpackConfigFactory = webpackConfigFactory;
|
|
103
|
-
function configureModuleRules(helperOptions) {
|
|
103
|
+
function configureModuleRules(helperOptions, additionalRules = []) {
|
|
104
104
|
const jsLoader = createJavaScriptLoader(helperOptions);
|
|
105
105
|
return [
|
|
106
106
|
...createSourceMapRules(!helperOptions.config.disableSourceMapGeneration),
|
|
@@ -113,6 +113,7 @@ function configureModuleRules(helperOptions) {
|
|
|
113
113
|
createIconsRule(helperOptions), // workaround for https://github.com/webpack/webpack/issues/9309
|
|
114
114
|
createIconsRule(helperOptions, jsLoader),
|
|
115
115
|
...createAssetsRules(helperOptions),
|
|
116
|
+
...additionalRules,
|
|
116
117
|
...createFallbackRules(helperOptions),
|
|
117
118
|
],
|
|
118
119
|
},
|
|
@@ -197,11 +198,10 @@ function configureExperiments({ config, isEnvProduction, }) {
|
|
|
197
198
|
};
|
|
198
199
|
}
|
|
199
200
|
function configureResolve({ isEnvProduction, config, tsLinkedPackages, }) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}, {});
|
|
201
|
+
const alias = { ...config.alias };
|
|
202
|
+
for (const [key, value] of Object.entries(alias)) {
|
|
203
|
+
alias[key] = path.resolve(paths_1.default.app, value);
|
|
204
|
+
}
|
|
205
205
|
if (isEnvProduction && config.reactProfiling) {
|
|
206
206
|
alias['react-dom$'] = 'react-dom/profiling';
|
|
207
207
|
alias['scheduler/tracing'] = 'scheduler/tracing-profiling';
|
|
@@ -812,3 +812,4 @@ function configureOptimization({ config }) {
|
|
|
812
812
|
};
|
|
813
813
|
return optimization;
|
|
814
814
|
}
|
|
815
|
+
exports.configureOptimization = configureOptimization;
|
|
@@ -3,11 +3,15 @@ import type { ClientConfig } from '../models';
|
|
|
3
3
|
import type * as Webpack from 'webpack';
|
|
4
4
|
type Mode = `${WebpackMode}`;
|
|
5
5
|
export declare function configureServiceWebpackConfig(mode: Mode, storybookConfig: Webpack.Configuration): Promise<Webpack.Configuration>;
|
|
6
|
-
|
|
6
|
+
type ModuleRule = NonNullable<NonNullable<Webpack.Configuration['module']>['rules']>[number];
|
|
7
|
+
export declare function configureWebpackConfigForStorybook(mode: Mode, userConfig?: ClientConfig, storybookModuleRules?: ModuleRule[]): Promise<{
|
|
7
8
|
module: {
|
|
8
9
|
rules: Webpack.RuleSetRule[];
|
|
9
10
|
};
|
|
10
11
|
resolve: Webpack.ResolveOptions;
|
|
11
12
|
plugins: (false | "" | 0 | ((this: Webpack.Compiler, compiler: Webpack.Compiler) => void) | Webpack.WebpackPluginInstance | null | undefined)[];
|
|
13
|
+
optimization: {
|
|
14
|
+
minimizer: (false | "" | 0 | "..." | Webpack.WebpackPluginInstance | ((this: Webpack.Compiler, compiler: Webpack.Compiler) => void) | null | undefined)[] | undefined;
|
|
15
|
+
};
|
|
12
16
|
}>;
|
|
13
17
|
export {};
|
|
@@ -48,7 +48,7 @@ async function configureServiceWebpackConfig(mode, storybookConfig) {
|
|
|
48
48
|
else {
|
|
49
49
|
options = serviceConfig.client;
|
|
50
50
|
}
|
|
51
|
-
const webpackConfig = await configureWebpackConfigForStorybook(mode, options);
|
|
51
|
+
const webpackConfig = await configureWebpackConfigForStorybook(mode, options, storybookConfig.module?.rules);
|
|
52
52
|
return {
|
|
53
53
|
...storybookConfig,
|
|
54
54
|
plugins: [...(storybookConfig.plugins ?? []), ...webpackConfig.plugins],
|
|
@@ -67,15 +67,23 @@ async function configureServiceWebpackConfig(mode, storybookConfig) {
|
|
|
67
67
|
...(storybookConfig.resolve?.extensions ?? []),
|
|
68
68
|
...(webpackConfig.resolve.extensions || []),
|
|
69
69
|
],
|
|
70
|
+
fallback: {
|
|
71
|
+
...storybookConfig.resolve?.fallback,
|
|
72
|
+
...webpackConfig.resolve.fallback,
|
|
73
|
+
},
|
|
70
74
|
},
|
|
71
75
|
module: {
|
|
72
76
|
...storybookConfig.module,
|
|
73
77
|
rules: webpackConfig.module.rules,
|
|
74
78
|
},
|
|
79
|
+
optimization: {
|
|
80
|
+
...storybookConfig.optimization,
|
|
81
|
+
...webpackConfig.optimization,
|
|
82
|
+
},
|
|
75
83
|
};
|
|
76
84
|
}
|
|
77
85
|
exports.configureServiceWebpackConfig = configureServiceWebpackConfig;
|
|
78
|
-
async function configureWebpackConfigForStorybook(mode, userConfig = {}) {
|
|
86
|
+
async function configureWebpackConfigForStorybook(mode, userConfig = {}, storybookModuleRules = []) {
|
|
79
87
|
const isEnvDevelopment = mode === "development" /* WebpackMode.Dev */;
|
|
80
88
|
const isEnvProduction = mode === "production" /* WebpackMode.Prod */;
|
|
81
89
|
const config = await (0, config_2.normalizeConfig)({
|
|
@@ -92,10 +100,13 @@ async function configureWebpackConfigForStorybook(mode, userConfig = {}) {
|
|
|
92
100
|
};
|
|
93
101
|
return {
|
|
94
102
|
module: {
|
|
95
|
-
rules: (0, config_1.configureModuleRules)(helperOptions),
|
|
103
|
+
rules: (0, config_1.configureModuleRules)(helperOptions, storybookModuleRules.filter((rule) => rule !== '...')),
|
|
96
104
|
},
|
|
97
105
|
resolve: (0, config_1.configureResolve)(helperOptions),
|
|
98
106
|
plugins: configurePlugins(helperOptions),
|
|
107
|
+
optimization: {
|
|
108
|
+
minimizer: (0, config_1.configureOptimization)(helperOptions).minimizer,
|
|
109
|
+
},
|
|
99
110
|
};
|
|
100
111
|
}
|
|
101
112
|
exports.configureWebpackConfigForStorybook = configureWebpackConfigForStorybook;
|
|
@@ -116,7 +127,7 @@ function configurePlugins({ isEnvDevelopment, isEnvProduction, config }) {
|
|
|
116
127
|
publicPath: '/',
|
|
117
128
|
}));
|
|
118
129
|
}
|
|
119
|
-
if (isEnvDevelopment) {
|
|
130
|
+
if (isEnvDevelopment && !config.disableReactRefresh) {
|
|
120
131
|
plugins.push(new react_refresh_webpack_plugin_1.default());
|
|
121
132
|
}
|
|
122
133
|
if (isEnvProduction) {
|