@gravity-ui/app-builder 0.14.1 → 0.15.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/dist/commands/build/build-service/client.js +1 -1
- package/dist/commands/dev/client.js +8 -5
- package/dist/common/config.js +8 -7
- package/dist/common/s3-upload/webpack-plugin.d.ts +2 -2
- package/dist/common/s3-upload/webpack-plugin.js +2 -3
- package/dist/common/typescript/compile.js +7 -7
- package/dist/common/typescript/watch.js +6 -6
- package/dist/common/webpack/compile.d.ts +1 -1
- package/dist/common/webpack/compile.js +5 -5
- package/dist/common/webpack/config.js +0 -1
- package/dist/common/webpack/node-externals.d.ts +4 -2
- package/dist/common/webpack/node-externals.js +5 -5
- package/dist/common/webpack/progress-plugin.d.ts +3 -2
- package/dist/common/webpack/progress-plugin.js +10 -25
- package/dist/common/webpack/utils.d.ts +2 -2
- package/dist/common/webpack/utils.js +4 -2
- package/dist/common/webpack/worker/worker-loader.d.ts +2 -2
- package/dist/common/webpack/worker/worker-loader.js +17 -17
- package/package.json +1 -3
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildClient = buildClient;
|
|
4
4
|
const compile_1 = require("../../../common/webpack/compile");
|
|
5
5
|
function buildClient(config) {
|
|
6
|
-
return (0, compile_1.
|
|
6
|
+
return (0, compile_1.clientCompile)(config.client);
|
|
7
7
|
}
|
|
@@ -38,13 +38,13 @@ const paths_1 = __importDefault(require("../../common/paths"));
|
|
|
38
38
|
const logger_1 = require("../../common/logger");
|
|
39
39
|
const config_1 = require("../../common/webpack/config");
|
|
40
40
|
async function watchClientCompilation(config, onManifestReady) {
|
|
41
|
-
const clientCompilation = await
|
|
41
|
+
const clientCompilation = await buildDevServer(config);
|
|
42
42
|
const compiler = clientCompilation.compiler;
|
|
43
43
|
subscribeToManifestReadyEvent(compiler, onManifestReady);
|
|
44
44
|
return clientCompilation;
|
|
45
45
|
}
|
|
46
|
-
async function
|
|
47
|
-
const logger = new logger_1.Logger('
|
|
46
|
+
async function buildDevServer(config) {
|
|
47
|
+
const logger = new logger_1.Logger('client', config.verbose);
|
|
48
48
|
const { webSocketPath = path.normalize(`/${config.client.publicPathPrefix}/build/sockjs-node`), writeToDisk, ...devServer } = config.client.devServer || {};
|
|
49
49
|
const normalizedConfig = { ...config.client, devServer: { ...devServer, webSocketPath } };
|
|
50
50
|
const webpackConfigs = [
|
|
@@ -52,8 +52,11 @@ async function buildWebpackServer(config) {
|
|
|
52
52
|
];
|
|
53
53
|
const isSsr = Boolean(normalizedConfig.ssr);
|
|
54
54
|
if (isSsr) {
|
|
55
|
-
const
|
|
56
|
-
webpackConfigs.push(await (0, config_1.webpackConfigFactory)("development" /* WebpackMode.Dev */, normalizedConfig, {
|
|
55
|
+
const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
|
|
56
|
+
webpackConfigs.push(await (0, config_1.webpackConfigFactory)("development" /* WebpackMode.Dev */, normalizedConfig, {
|
|
57
|
+
logger: ssrLogger,
|
|
58
|
+
isSsr,
|
|
59
|
+
}));
|
|
57
60
|
}
|
|
58
61
|
const publicPath = path.normalize(config.client.publicPathPrefix + '/build/');
|
|
59
62
|
const staticFolder = path.resolve(paths_1.default.appDist, 'public');
|
package/dist/common/config.js
CHANGED
|
@@ -22,15 +22,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.getProjectConfig = getProjectConfig;
|
|
30
27
|
exports.normalizeConfig = normalizeConfig;
|
|
31
|
-
/* eslint-disable complexity */
|
|
32
28
|
const path = __importStar(require("node:path"));
|
|
33
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
34
29
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
35
30
|
const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader");
|
|
36
31
|
const models_1 = require("./models");
|
|
@@ -42,7 +37,13 @@ function remapPaths(paths) {
|
|
|
42
37
|
return splitPaths(paths).map((p) => path.resolve(process.cwd(), p));
|
|
43
38
|
}
|
|
44
39
|
function omitUndefined(obj) {
|
|
45
|
-
|
|
40
|
+
const newObj = {};
|
|
41
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
42
|
+
if (value !== undefined) {
|
|
43
|
+
newObj[key] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return newObj;
|
|
46
47
|
}
|
|
47
48
|
function getModuleLoader({ storybook } = {}) {
|
|
48
49
|
if (!storybook) {
|
|
@@ -176,7 +177,7 @@ async function normalizeConfig(userConfig, mode) {
|
|
|
176
177
|
};
|
|
177
178
|
return config;
|
|
178
179
|
}
|
|
179
|
-
const config =
|
|
180
|
+
const config = structuredClone(userConfig);
|
|
180
181
|
config.lib.newJsxTransform = config.lib.newJsxTransform ?? true;
|
|
181
182
|
return config;
|
|
182
183
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as Webpack from 'webpack';
|
|
2
2
|
import type { Logger } from '../logger/index.js';
|
|
3
3
|
import type { UploadOptions } from './upload.js';
|
|
4
4
|
import type { S3ClientOptions } from './s3-client.js';
|
|
@@ -14,7 +14,7 @@ interface S3UploadPluginOptions {
|
|
|
14
14
|
export declare class S3UploadPlugin {
|
|
15
15
|
private options;
|
|
16
16
|
constructor(options: S3UploadPluginOptions);
|
|
17
|
-
apply(compiler: Compiler): void;
|
|
17
|
+
apply(compiler: Webpack.Compiler): void;
|
|
18
18
|
private isIncludeAndNotExclude;
|
|
19
19
|
}
|
|
20
20
|
type Rule = RegExp | string | ((s: string) => boolean);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.S3UploadPlugin = void 0;
|
|
4
|
-
const webpack_1 = require("webpack");
|
|
5
4
|
const fast_glob_1 = require("fast-glob");
|
|
6
5
|
const upload_js_1 = require("./upload.js");
|
|
7
6
|
class S3UploadPlugin {
|
|
@@ -12,7 +11,7 @@ class S3UploadPlugin {
|
|
|
12
11
|
apply(compiler) {
|
|
13
12
|
compiler.hooks.done.tapPromise('s3-upload-plugin', async (stats) => {
|
|
14
13
|
if (stats.hasErrors()) {
|
|
15
|
-
stats.compilation.warnings.push(new
|
|
14
|
+
stats.compilation.warnings.push(new compiler.webpack.WebpackError('s3-upload-plugin: skipped upload to s3 due to compilation errors'));
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
18
17
|
let fileNames = Object.keys(stats.compilation.assets);
|
|
@@ -39,7 +38,7 @@ class S3UploadPlugin {
|
|
|
39
38
|
this.options.logger?.success(`Files successfully uploaded to bucket ${this.options.s3UploadOptions.bucket}`);
|
|
40
39
|
}
|
|
41
40
|
catch (e) {
|
|
42
|
-
const error = new
|
|
41
|
+
const error = new compiler.webpack.WebpackError(`s3-upload-plugin: ${e instanceof Error ? e.message : e}`);
|
|
43
42
|
stats.compilation.errors.push(error);
|
|
44
43
|
}
|
|
45
44
|
});
|
|
@@ -24,7 +24,7 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
|
|
|
24
24
|
const program = ts.createProgram(parsedConfig.fileNames, parsedConfig.options, compilerHost);
|
|
25
25
|
// @ts-expect-error
|
|
26
26
|
const filesCount = compilerHost.readFile.disableDisplay();
|
|
27
|
-
|
|
27
|
+
let allDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
28
28
|
logger.verbose(`Program created, read ${filesCount} files`);
|
|
29
29
|
if (!hasErrors(allDiagnostics)) {
|
|
30
30
|
logger.verbose('We finished making the program! Emitting...');
|
|
@@ -34,7 +34,7 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
|
|
|
34
34
|
afterDeclarations: [transformPathsToLocalModules],
|
|
35
35
|
});
|
|
36
36
|
logger.verbose('Emit complete!');
|
|
37
|
-
allDiagnostics.
|
|
37
|
+
allDiagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics.concat(emitResult.diagnostics));
|
|
38
38
|
}
|
|
39
39
|
allDiagnostics.forEach(reportDiagnostic);
|
|
40
40
|
if (hasErrors(allDiagnostics)) {
|
|
@@ -44,12 +44,12 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
|
|
|
44
44
|
else {
|
|
45
45
|
logger.success(`Compiled successfully in ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
46
46
|
}
|
|
47
|
-
const formatHost = {
|
|
48
|
-
getCanonicalFileName: (path) => path,
|
|
49
|
-
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
50
|
-
getNewLine: () => ts.sys.newLine,
|
|
51
|
-
};
|
|
52
47
|
function reportDiagnostic(diagnostic) {
|
|
48
|
+
const formatHost = {
|
|
49
|
+
getCanonicalFileName: (path) => path,
|
|
50
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
51
|
+
getNewLine: () => ts.sys.newLine,
|
|
52
|
+
};
|
|
53
53
|
if (logger.isVerbose) {
|
|
54
54
|
logger.message(ts.formatDiagnosticsWithColorAndContext([diagnostic], formatHost));
|
|
55
55
|
}
|
|
@@ -9,11 +9,6 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
|
|
|
9
9
|
logger.message(`Typescript v${ts.version}`);
|
|
10
10
|
const configPath = (0, utils_1.getTsProjectConfigPath)(ts, projectPath);
|
|
11
11
|
const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
|
|
12
|
-
const formatHost = {
|
|
13
|
-
getCanonicalFileName: (path) => path,
|
|
14
|
-
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
15
|
-
getNewLine: () => ts.sys.newLine,
|
|
16
|
-
};
|
|
17
12
|
const host = ts.createWatchCompilerHost(configPath, {
|
|
18
13
|
noEmit: false,
|
|
19
14
|
noEmitOnError: false,
|
|
@@ -46,6 +41,11 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
|
|
|
46
41
|
// the program over time.
|
|
47
42
|
ts.createWatchProgram(host);
|
|
48
43
|
function reportDiagnostic(diagnostic) {
|
|
44
|
+
const formatHost = {
|
|
45
|
+
getCanonicalFileName: (path) => path,
|
|
46
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
47
|
+
getNewLine: () => ts.sys.newLine,
|
|
48
|
+
};
|
|
49
49
|
if (logger.isVerbose) {
|
|
50
50
|
logger.message(ts.formatDiagnosticsWithColorAndContext([diagnostic], formatHost));
|
|
51
51
|
}
|
|
@@ -59,7 +59,7 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
|
|
|
59
59
|
*/
|
|
60
60
|
function reportWatchStatusChanged(diagnostic) {
|
|
61
61
|
if (diagnostic.messageText) {
|
|
62
|
-
logger.message(ts.flattenDiagnosticMessageText(diagnostic.messageText,
|
|
62
|
+
logger.message(ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine));
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { NormalizedClientConfig } from '../models';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function clientCompile(config: NormalizedClientConfig): Promise<void>;
|
|
@@ -3,18 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.clientCompile = clientCompile;
|
|
7
7
|
const webpack_1 = __importDefault(require("webpack"));
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const config_1 = require("./config");
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
|
-
async function
|
|
12
|
-
const logger = new logger_1.Logger('
|
|
11
|
+
async function clientCompile(config) {
|
|
12
|
+
const logger = new logger_1.Logger('client', config.verbose);
|
|
13
13
|
const webpackConfigs = [await (0, config_1.webpackConfigFactory)("production" /* WebpackMode.Prod */, config, { logger })];
|
|
14
14
|
const isSsr = Boolean(config.ssr);
|
|
15
15
|
if (isSsr) {
|
|
16
|
-
const
|
|
17
|
-
webpackConfigs.push(await (0, config_1.webpackConfigFactory)("production" /* WebpackMode.Prod */, config, { logger, isSsr }));
|
|
16
|
+
const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
|
|
17
|
+
webpackConfigs.push(await (0, config_1.webpackConfigFactory)("production" /* WebpackMode.Prod */, config, { logger: ssrLogger, isSsr }));
|
|
18
18
|
}
|
|
19
19
|
logger.verbose('Config created');
|
|
20
20
|
return new Promise((resolve) => {
|
|
@@ -30,7 +30,6 @@ exports.webpackConfigFactory = webpackConfigFactory;
|
|
|
30
30
|
exports.configureModuleRules = configureModuleRules;
|
|
31
31
|
exports.configureResolve = configureResolve;
|
|
32
32
|
exports.configureOptimization = configureOptimization;
|
|
33
|
-
/* eslint-disable complexity */
|
|
34
33
|
const path = __importStar(require("node:path"));
|
|
35
34
|
const fs = __importStar(require("node:fs"));
|
|
36
35
|
const webpack = __importStar(require("webpack"));
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type * as webpack from 'webpack';
|
|
2
1
|
type Pattern = RegExp | ((v: string) => boolean) | string;
|
|
3
2
|
export interface NodeExternalsOptions {
|
|
4
3
|
noExternal?: Pattern | Pattern[];
|
|
5
4
|
module?: boolean;
|
|
6
5
|
}
|
|
7
|
-
export declare function nodeExternals({ noExternal, module }: NodeExternalsOptions): (data:
|
|
6
|
+
export declare function nodeExternals({ noExternal, module }: NodeExternalsOptions): (data: {
|
|
7
|
+
request?: string;
|
|
8
|
+
dependencyType?: string;
|
|
9
|
+
}) => Promise<string | undefined>;
|
|
8
10
|
export {};
|
|
@@ -35,7 +35,7 @@ function nodeExternals({ noExternal = [], module }) {
|
|
|
35
35
|
const noExternals = Array().concat(webpackInternal).concat(noExternal);
|
|
36
36
|
const nodeModules = readPackagesNames(paths_1.default.appNodeModules);
|
|
37
37
|
return async (data) => {
|
|
38
|
-
const { request } = data;
|
|
38
|
+
const { request, dependencyType } = data;
|
|
39
39
|
if (!request) {
|
|
40
40
|
return undefined;
|
|
41
41
|
}
|
|
@@ -46,14 +46,14 @@ function nodeExternals({ noExternal = [], module }) {
|
|
|
46
46
|
return undefined;
|
|
47
47
|
}
|
|
48
48
|
if (!module) {
|
|
49
|
-
return `commonjs ${
|
|
49
|
+
return `commonjs ${request}`;
|
|
50
50
|
}
|
|
51
|
-
if (
|
|
51
|
+
if (dependencyType === 'commonjs' ||
|
|
52
52
|
// lodash/something without extension can't be imported so always require it
|
|
53
53
|
(moduleName === 'lodash' && request.match(/^lodash\/[\w_]+($|\/[\w_]+$)/))) {
|
|
54
|
-
return `node-commonjs ${
|
|
54
|
+
return `node-commonjs ${request}`;
|
|
55
55
|
}
|
|
56
|
-
return `module-import ${
|
|
56
|
+
return `module-import ${request}`;
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
function readPackagesNames(dirName) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import type * as Webpack from 'webpack';
|
|
2
3
|
import type { Logger } from '../logger';
|
|
3
4
|
export declare class ProgressPlugin extends webpack.ProgressPlugin {
|
|
4
5
|
private _logger;
|
|
@@ -7,5 +8,5 @@ export declare class ProgressPlugin extends webpack.ProgressPlugin {
|
|
|
7
8
|
logger: Logger;
|
|
8
9
|
});
|
|
9
10
|
handler: (percent: number, message: string, ...details: string[]) => void;
|
|
10
|
-
apply(compiler:
|
|
11
|
+
apply(compiler: Webpack.Compiler): void;
|
|
11
12
|
}
|
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.ProgressPlugin = void 0;
|
|
27
|
-
const
|
|
7
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
28
8
|
const pretty_time_1 = require("../logger/pretty-time");
|
|
29
|
-
class ProgressPlugin extends
|
|
9
|
+
class ProgressPlugin extends webpack_1.default.ProgressPlugin {
|
|
30
10
|
_logger;
|
|
31
11
|
_state = {};
|
|
32
12
|
constructor({ logger }) {
|
|
@@ -41,7 +21,12 @@ class ProgressPlugin extends webpack.ProgressPlugin {
|
|
|
41
21
|
super.apply(compiler);
|
|
42
22
|
hook(compiler, 'compile', () => {
|
|
43
23
|
this._logger.message('Start compilation');
|
|
44
|
-
|
|
24
|
+
if ('rspackVersion' in compiler.webpack) {
|
|
25
|
+
this._logger.message(`Rspack v${compiler.webpack.rspackVersion}`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this._logger.message(`Webpack v${compiler.webpack.version}`);
|
|
29
|
+
}
|
|
45
30
|
this._state.start = process.hrtime.bigint();
|
|
46
31
|
});
|
|
47
32
|
hook(compiler, 'invalid', (fileName, changeTime) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as Webpack from 'webpack';
|
|
2
2
|
import type { Logger } from '../logger';
|
|
3
|
-
export declare function webpackCompilerHandlerFactory(logger: Logger, onCompilationEnd?: () => void): (err?: Error | null, stats?:
|
|
3
|
+
export declare function webpackCompilerHandlerFactory(logger: Logger, onCompilationEnd?: () => void): (err?: Error | null, stats?: Webpack.MultiStats) => Promise<void>;
|
|
4
4
|
export declare function resolveTsConfigPathsToAlias(projectPath: string, filename?: string): {
|
|
5
5
|
aliases?: undefined;
|
|
6
6
|
modules?: undefined;
|
|
@@ -53,11 +53,13 @@ function webpackCompilerHandlerFactory(logger, onCompilationEnd) {
|
|
|
53
53
|
}
|
|
54
54
|
const [clientStats, ssrStats] = stats?.stats ?? [];
|
|
55
55
|
if (clientStats) {
|
|
56
|
-
const
|
|
56
|
+
const { startTime = 0, endTime = 0 } = clientStats;
|
|
57
|
+
const time = endTime - startTime;
|
|
57
58
|
logger.success(`Client was successfully compiled in ${(0, pretty_time_1.prettyTime)(BigInt(time) * BigInt(1_000_000))}`);
|
|
58
59
|
}
|
|
59
60
|
if (ssrStats) {
|
|
60
|
-
const
|
|
61
|
+
const { startTime = 0, endTime = 0 } = ssrStats;
|
|
62
|
+
const time = endTime - startTime;
|
|
61
63
|
logger.success(`SSR: Client was successfully compiled in ${(0, pretty_time_1.prettyTime)(BigInt(time) * BigInt(1_000_000))}`);
|
|
62
64
|
}
|
|
63
65
|
if (!clientStats && !ssrStats) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const pitch:
|
|
1
|
+
import type * as Webpack from 'webpack';
|
|
2
|
+
export declare const pitch: Webpack.PitchLoaderDefinitionFunction;
|
|
@@ -28,11 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.pitch = void 0;
|
|
30
30
|
const path = __importStar(require("node:path"));
|
|
31
|
-
const webpack_1 = __importDefault(require("webpack"));
|
|
32
|
-
const NodeTargetPlugin_1 = __importDefault(require("webpack/lib/node/NodeTargetPlugin"));
|
|
33
|
-
const WebWorkerTemplatePlugin_1 = __importDefault(require("webpack/lib/webworker/WebWorkerTemplatePlugin"));
|
|
34
|
-
const FetchCompileWasmPlugin_1 = __importDefault(require("webpack/lib/web/FetchCompileWasmPlugin"));
|
|
35
|
-
const FetchCompileAsyncWasmPlugin_1 = __importDefault(require("webpack/lib/web/FetchCompileAsyncWasmPlugin"));
|
|
36
31
|
const paths_1 = __importDefault(require("../../paths"));
|
|
37
32
|
const pluginId = 'APP_BUILDER_WORKER_LOADER';
|
|
38
33
|
const publicPath = path.resolve(__dirname, 'public-path.worker.js');
|
|
@@ -41,7 +36,7 @@ const pitch = function (request) {
|
|
|
41
36
|
if (!this._compiler || !this._compilation) {
|
|
42
37
|
throw new Error('Something went wrong');
|
|
43
38
|
}
|
|
44
|
-
const compilerOptions = this._compiler
|
|
39
|
+
const { options: compilerOptions, webpack } = this._compiler;
|
|
45
40
|
const logger = this.getLogger(pluginId);
|
|
46
41
|
if (compilerOptions.output.globalObject === 'window') {
|
|
47
42
|
logger.warn('Warning (app-builder-worker-loader): output.globalObject is set to "window". It should be set to "self" or "this" to support HMR in Workers.');
|
|
@@ -59,17 +54,22 @@ const pitch = function (request) {
|
|
|
59
54
|
devtoolNamespace: path.resolve('/', path.relative(paths_1.default.app, this.resource)),
|
|
60
55
|
};
|
|
61
56
|
const workerCompiler = this._compilation.createChildCompiler(`worker ${request}`, workerOptions);
|
|
62
|
-
|
|
57
|
+
const { EntryPlugin, node: { NodeTargetPlugin }, web: { FetchCompileWasmPlugin, FetchCompileAsyncWasmPlugin }, webworker: { WebWorkerTemplatePlugin }, } = webpack;
|
|
58
|
+
new WebWorkerTemplatePlugin().apply(workerCompiler);
|
|
63
59
|
if (this.target !== 'webworker' && this.target !== 'web') {
|
|
64
|
-
new
|
|
60
|
+
new NodeTargetPlugin().apply(workerCompiler);
|
|
61
|
+
}
|
|
62
|
+
if (FetchCompileWasmPlugin) {
|
|
63
|
+
new FetchCompileWasmPlugin({
|
|
64
|
+
mangleImports: this._compiler.options.optimization.mangleWasmImports,
|
|
65
|
+
}).apply(workerCompiler);
|
|
66
|
+
}
|
|
67
|
+
if (FetchCompileAsyncWasmPlugin) {
|
|
68
|
+
new FetchCompileAsyncWasmPlugin().apply(workerCompiler);
|
|
65
69
|
}
|
|
66
|
-
new FetchCompileWasmPlugin_1.default({
|
|
67
|
-
mangleImports: this._compiler.options.optimization.mangleWasmImports,
|
|
68
|
-
}).apply(workerCompiler);
|
|
69
|
-
new FetchCompileAsyncWasmPlugin_1.default().apply(workerCompiler);
|
|
70
70
|
const bundleName = path.parse(this.resourcePath).name;
|
|
71
|
-
new
|
|
72
|
-
new
|
|
71
|
+
new EntryPlugin(this.context, `!!${publicPath}`, bundleName).apply(workerCompiler);
|
|
72
|
+
new EntryPlugin(this.context, `!!${request}`, bundleName).apply(workerCompiler);
|
|
73
73
|
configureSourceMap(workerCompiler);
|
|
74
74
|
const cb = this.async();
|
|
75
75
|
workerCompiler.compile((err, compilation) => {
|
|
@@ -130,10 +130,10 @@ const pitch = function (request) {
|
|
|
130
130
|
if ([filename, mapFile, licenseFile].includes(assetName)) {
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
|
-
if (parentCompilation.
|
|
133
|
+
if (parentCompilation.getAsset(assetName)) {
|
|
134
134
|
continue;
|
|
135
135
|
}
|
|
136
|
-
parentCompilation.emitAsset(assetName, asset, compilation.
|
|
136
|
+
parentCompilation.emitAsset(assetName, asset, compilation.getAsset(assetName)?.info);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
return cache.store(cacheIdent, cacheETag, { content, map: map?.toString() }, (storeCacheError) => {
|
|
@@ -163,7 +163,7 @@ function configureSourceMap(compiler) {
|
|
|
163
163
|
const inline = devtool.includes('inline');
|
|
164
164
|
const cheap = devtool.includes('cheap');
|
|
165
165
|
const moduleMaps = devtool.includes('module');
|
|
166
|
-
new
|
|
166
|
+
new compiler.webpack.SourceMapDevToolPlugin({
|
|
167
167
|
filename: inline ? null : compiler.options.output.sourceMapFilename,
|
|
168
168
|
moduleFilenameTemplate: compiler.options.output.devtoolModuleFilenameTemplate,
|
|
169
169
|
fallbackModuleFilenameTemplate: compiler.options.output.devtoolFallbackModuleFilenameTemplate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/app-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Develop and build your React client-server projects, powered by typescript and webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -95,7 +95,6 @@
|
|
|
95
95
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
96
96
|
"fs-extra": "^11.2.0",
|
|
97
97
|
"get-port": "^7.1.0",
|
|
98
|
-
"lodash": "^4.17.21",
|
|
99
98
|
"mime-types": "^2.1.35",
|
|
100
99
|
"mini-css-extract-plugin": "^2.9.1",
|
|
101
100
|
"moment-timezone-data-webpack-plugin": "^1.5.1",
|
|
@@ -143,7 +142,6 @@
|
|
|
143
142
|
"@types/common-tags": "^1.8.4",
|
|
144
143
|
"@types/fs-extra": "^11.0.4",
|
|
145
144
|
"@types/jest": "^29.5.2",
|
|
146
|
-
"@types/lodash": "^4.17.10",
|
|
147
145
|
"@types/mime-types": "^2.1.4",
|
|
148
146
|
"@types/node": "^18",
|
|
149
147
|
"@types/nodemon": "^1.19.6",
|