@gravity-ui/app-builder 0.30.0 → 0.30.1
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/cli.js +20 -15
- package/dist/commands/build/build-lib.js +8 -5
- package/dist/commands/build/build-service/client.js +6 -3
- package/dist/commands/build/build-service/index.js +7 -4
- package/dist/commands/build/build-service/server.js +17 -11
- package/dist/commands/build/index.js +6 -3
- package/dist/commands/dev/client.js +63 -34
- package/dist/commands/dev/index.js +50 -21
- package/dist/commands/dev/server.js +42 -13
- package/dist/common/babel/index.js +4 -1
- package/dist/common/babel/ui-preset.d.ts +1 -1
- package/dist/common/babel/ui-preset.js +1 -0
- package/dist/common/child-process/controllable-script.js +32 -5
- package/dist/common/child-process/utils.js +30 -4
- package/dist/common/command.js +2 -1
- package/dist/common/config.js +49 -19
- package/dist/common/env.js +5 -3
- package/dist/common/library/babel-plugin-replace-paths.js +4 -2
- package/dist/common/library/index.js +95 -66
- package/dist/common/logger/colors.js +8 -2
- package/dist/common/logger/index.js +24 -17
- package/dist/common/logger/log-config.js +6 -3
- package/dist/common/logger/pretty-time.js +6 -2
- package/dist/common/models/index.d.ts +1 -1
- package/dist/common/models/index.js +8 -3
- package/dist/common/paths.js +28 -3
- package/dist/common/s3-upload/compress.js +12 -8
- package/dist/common/s3-upload/create-plugin.js +30 -4
- package/dist/common/s3-upload/index.js +9 -3
- package/dist/common/s3-upload/s3-client.js +37 -11
- package/dist/common/s3-upload/upload.js +38 -9
- package/dist/common/s3-upload/webpack-plugin.js +9 -5
- package/dist/common/swc/compile.js +12 -9
- package/dist/common/swc/index.js +7 -2
- package/dist/common/swc/utils.js +13 -6
- package/dist/common/swc/watch.js +9 -6
- package/dist/common/typescript/compile.js +14 -11
- package/dist/common/typescript/diagnostic.js +37 -11
- package/dist/common/typescript/transformers.js +29 -3
- package/dist/common/typescript/utils.js +18 -8
- package/dist/common/typescript/watch.js +13 -10
- package/dist/common/utils.js +25 -14
- package/dist/common/webpack/compile.js +22 -16
- package/dist/common/webpack/config.js +113 -80
- package/dist/common/webpack/node-externals.js +34 -5
- package/dist/common/webpack/progress-plugin.js +6 -3
- package/dist/common/webpack/public-path.d.ts +1 -0
- package/dist/common/webpack/public-path.js +1 -0
- package/dist/common/webpack/rspack.js +5 -1
- package/dist/common/webpack/runtime-versioning-plugin.js +3 -1
- package/dist/common/webpack/storybook.js +51 -21
- package/dist/common/webpack/utils.js +36 -9
- package/dist/common/webpack/worker/public-path.worker.d.ts +1 -0
- package/dist/common/webpack/worker/public-path.worker.js +1 -0
- package/dist/common/webpack/worker/worker-loader.js +34 -4
- package/dist/create-cli.js +48 -19
- package/dist/index.js +27 -5
- package/package.json +1 -2
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.elapsedTime = elapsedTime;
|
|
4
|
+
exports.prettyTime = prettyTime;
|
|
1
5
|
const scale = {
|
|
2
6
|
w: BigInt(6048e11),
|
|
3
7
|
d: BigInt(864e11),
|
|
@@ -8,11 +12,11 @@ const scale = {
|
|
|
8
12
|
μs: BigInt(1e3),
|
|
9
13
|
ns: BigInt(1),
|
|
10
14
|
};
|
|
11
|
-
|
|
15
|
+
function elapsedTime(time, smallest = 'ms') {
|
|
12
16
|
const elapsed = process.hrtime.bigint() - time;
|
|
13
17
|
return prettyTime(elapsed, smallest);
|
|
14
18
|
}
|
|
15
|
-
|
|
19
|
+
function prettyTime(time, smallest = 'ms') {
|
|
16
20
|
let elapsed = time;
|
|
17
21
|
let res = '';
|
|
18
22
|
let count = 0;
|
|
@@ -16,7 +16,7 @@ import type { WebpackMode } from '../webpack/config';
|
|
|
16
16
|
import type { UploadOptions } from '../s3-upload/upload';
|
|
17
17
|
import type { TerserOptions } from 'terser-webpack-plugin';
|
|
18
18
|
import type { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
|
|
19
|
-
import type { moduleFederationPlugin } from '@module-federation/
|
|
19
|
+
import type { moduleFederationPlugin } from '@module-federation/enhanced';
|
|
20
20
|
type Bundler = 'webpack' | 'rspack';
|
|
21
21
|
type JavaScriptLoader = 'babel' | 'swc';
|
|
22
22
|
type ServerCompiler = 'typescript' | 'swc';
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isServiceConfig = isServiceConfig;
|
|
4
|
+
exports.isLibraryConfig = isLibraryConfig;
|
|
5
|
+
exports.defineConfig = defineConfig;
|
|
6
|
+
function isServiceConfig(config) {
|
|
2
7
|
return !('lib' in config);
|
|
3
8
|
}
|
|
4
|
-
|
|
9
|
+
function isLibraryConfig(config) {
|
|
5
10
|
return 'lib' in config;
|
|
6
11
|
}
|
|
7
|
-
|
|
12
|
+
function defineConfig(config) {
|
|
8
13
|
return config;
|
|
9
14
|
}
|
package/dist/common/paths.js
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const fs = __importStar(require("node:fs"));
|
|
27
|
+
const path = __importStar(require("node:path"));
|
|
3
28
|
const appDirectory = fs.realpathSync(process.cwd());
|
|
4
29
|
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
|
|
5
|
-
|
|
30
|
+
exports.default = {
|
|
6
31
|
app: resolveApp('.'),
|
|
7
32
|
appNodeModules: resolveApp('node_modules'),
|
|
8
33
|
appClient: resolveApp('src/ui'),
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gzip = gzip;
|
|
4
|
+
exports.brotli = brotli;
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const zlib_1 = require("zlib");
|
|
3
7
|
function compressor(sourcePath, destinationPath, transformer) {
|
|
4
8
|
return new Promise((resolve, reject) => {
|
|
5
|
-
const sourceStream = createReadStream(sourcePath);
|
|
9
|
+
const sourceStream = (0, node_fs_1.createReadStream)(sourcePath);
|
|
6
10
|
sourceStream.on('error', reject);
|
|
7
|
-
const destinationStream = createWriteStream(destinationPath);
|
|
11
|
+
const destinationStream = (0, node_fs_1.createWriteStream)(destinationPath);
|
|
8
12
|
destinationStream.on('finish', () => resolve(destinationPath));
|
|
9
13
|
destinationStream.on('error', reject);
|
|
10
14
|
sourceStream.pipe(transformer).pipe(destinationStream);
|
|
11
15
|
});
|
|
12
16
|
}
|
|
13
|
-
|
|
14
|
-
return compressor(sourcePath, `${sourcePath}.gz`, createGzip({}));
|
|
17
|
+
function gzip(sourcePath) {
|
|
18
|
+
return compressor(sourcePath, `${sourcePath}.gz`, (0, zlib_1.createGzip)({}));
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
return compressor(sourcePath, `${sourcePath}.br`, createBrotliCompress());
|
|
20
|
+
function brotli(sourcePath) {
|
|
21
|
+
return compressor(sourcePath, `${sourcePath}.br`, (0, zlib_1.createBrotliCompress)());
|
|
18
22
|
}
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.createS3UploadPlugins = createS3UploadPlugins;
|
|
27
|
+
const path = __importStar(require("node:path"));
|
|
28
|
+
const webpack_plugin_1 = require("./webpack-plugin");
|
|
29
|
+
function createS3UploadPlugins(config, logger) {
|
|
4
30
|
const plugins = [];
|
|
5
31
|
let credentialsGlobal;
|
|
6
32
|
if (process.env.FRONTEND_S3_ACCESS_KEY_ID && process.env.FRONTEND_S3_SECRET_ACCESS_KEY) {
|
|
@@ -28,7 +54,7 @@ export function createS3UploadPlugins(config, logger) {
|
|
|
28
54
|
if (config.moduleFederation && targetPath !== undefined) {
|
|
29
55
|
targetPath = path.join(targetPath, config.moduleFederation.name);
|
|
30
56
|
}
|
|
31
|
-
plugins.push(new S3UploadPlugin({
|
|
57
|
+
plugins.push(new webpack_plugin_1.S3UploadPlugin({
|
|
32
58
|
exclude: config.hiddenSourceMap ? /\.map$/ : undefined,
|
|
33
59
|
compress: cdn.compress,
|
|
34
60
|
s3ClientOptions: {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createS3UploadPlugins = exports.uploadFiles = exports.S3UploadPlugin = void 0;
|
|
4
|
+
var webpack_plugin_1 = require("./webpack-plugin");
|
|
5
|
+
Object.defineProperty(exports, "S3UploadPlugin", { enumerable: true, get: function () { return webpack_plugin_1.S3UploadPlugin; } });
|
|
6
|
+
var upload_1 = require("./upload");
|
|
7
|
+
Object.defineProperty(exports, "uploadFiles", { enumerable: true, get: function () { return upload_1.uploadFiles; } });
|
|
8
|
+
var create_plugin_1 = require("./create-plugin");
|
|
9
|
+
Object.defineProperty(exports, "createS3UploadPlugins", { enumerable: true, get: function () { return create_plugin_1.createS3UploadPlugins; } });
|
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getS3Client = getS3Client;
|
|
27
|
+
const fs = __importStar(require("fs/promises"));
|
|
28
|
+
const path = __importStar(require("node:path"));
|
|
29
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
30
|
+
const mime = __importStar(require("mime-types"));
|
|
31
|
+
const fast_glob_1 = require("fast-glob");
|
|
32
|
+
function getS3Client(options) {
|
|
33
|
+
const s3Client = new client_s3_1.S3Client(options);
|
|
8
34
|
return {
|
|
9
35
|
headObject(bucket, key) {
|
|
10
|
-
return s3Client.send(new HeadObjectCommand({ Bucket: bucket, Key: key }));
|
|
36
|
+
return s3Client.send(new client_s3_1.HeadObjectCommand({ Bucket: bucket, Key: key }));
|
|
11
37
|
},
|
|
12
38
|
async uploadFile(bucket, localFileOrPath, key, opts = {}) {
|
|
13
39
|
const isBuffer = Buffer.isBuffer(localFileOrPath);
|
|
@@ -36,10 +62,10 @@ export function getS3Client(options) {
|
|
|
36
62
|
if (opts.cacheControl) {
|
|
37
63
|
params.CacheControl = opts.cacheControl;
|
|
38
64
|
}
|
|
39
|
-
return s3Client.send(new PutObjectCommand(params));
|
|
65
|
+
return s3Client.send(new client_s3_1.PutObjectCommand(params));
|
|
40
66
|
},
|
|
41
67
|
async uploadDir(bucket, dirPath, keyPrefix = '', { concurrency = 512, ...opts } = {}) {
|
|
42
|
-
const files = globSync('**', { cwd: dirPath });
|
|
68
|
+
const files = (0, fast_glob_1.globSync)('**', { cwd: dirPath });
|
|
43
69
|
const { default: pMap } = await import('p-map');
|
|
44
70
|
return pMap(files, (filePath) => {
|
|
45
71
|
const sourcePath = path.join(dirPath, filePath);
|
|
@@ -47,7 +73,7 @@ export function getS3Client(options) {
|
|
|
47
73
|
}, { concurrency });
|
|
48
74
|
},
|
|
49
75
|
deleteObject(bucket, key) {
|
|
50
|
-
return s3Client.send(new DeleteObjectCommand({ Bucket: bucket, Key: key }));
|
|
76
|
+
return s3Client.send(new client_s3_1.DeleteObjectCommand({ Bucket: bucket, Key: key }));
|
|
51
77
|
},
|
|
52
78
|
};
|
|
53
79
|
}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.uploadFiles = uploadFiles;
|
|
30
|
+
const path = __importStar(require("node:path"));
|
|
31
|
+
const index_js_1 = __importDefault(require("../logger/index.js"));
|
|
32
|
+
const s3_client_js_1 = require("./s3-client.js");
|
|
33
|
+
const compress_js_1 = require("./compress.js");
|
|
34
|
+
async function uploadFiles(files, config) {
|
|
35
|
+
const s3Client = (0, s3_client_js_1.getS3Client)(config.s3);
|
|
36
|
+
const log = config.logger ?? index_js_1.default;
|
|
8
37
|
const { default: PQueue } = await import('p-queue');
|
|
9
38
|
const queue = new PQueue({
|
|
10
39
|
concurrency: config.concurrency ?? 512,
|
|
@@ -68,8 +97,8 @@ export async function uploadFiles(files, config) {
|
|
|
68
97
|
function compress(sourcePath) {
|
|
69
98
|
// throwOnTimeout is only used to get the correct type and does not change behavior since we are not setting a timeout.
|
|
70
99
|
return [
|
|
71
|
-
queue.add(() => gzip(sourcePath), { throwOnTimeout: true }),
|
|
72
|
-
queue.add(() => brotli(sourcePath), { throwOnTimeout: true }),
|
|
100
|
+
queue.add(() => (0, compress_js_1.gzip)(sourcePath), { throwOnTimeout: true }),
|
|
101
|
+
queue.add(() => (0, compress_js_1.brotli)(sourcePath), { throwOnTimeout: true }),
|
|
73
102
|
];
|
|
74
103
|
}
|
|
75
104
|
function fileProcessor(options) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S3UploadPlugin = void 0;
|
|
4
|
+
const fast_glob_1 = require("fast-glob");
|
|
5
|
+
const upload_js_1 = require("./upload.js");
|
|
6
|
+
class S3UploadPlugin {
|
|
4
7
|
options;
|
|
5
8
|
constructor(options) {
|
|
6
9
|
this.options = options;
|
|
@@ -13,7 +16,7 @@ export class S3UploadPlugin {
|
|
|
13
16
|
}
|
|
14
17
|
let fileNames = Object.keys(stats.compilation.assets);
|
|
15
18
|
if (this.options.additionalPattern) {
|
|
16
|
-
const additionalFiles = globSync(this.options.additionalPattern, {
|
|
19
|
+
const additionalFiles = (0, fast_glob_1.globSync)(this.options.additionalPattern, {
|
|
17
20
|
cwd: stats.compilation.outputOptions.path,
|
|
18
21
|
});
|
|
19
22
|
fileNames = fileNames.concat(additionalFiles);
|
|
@@ -23,7 +26,7 @@ export class S3UploadPlugin {
|
|
|
23
26
|
return this.isIncludeAndNotExclude(fullPath);
|
|
24
27
|
});
|
|
25
28
|
try {
|
|
26
|
-
await uploadFiles(fileNames, {
|
|
29
|
+
await (0, upload_js_1.uploadFiles)(fileNames, {
|
|
27
30
|
s3: this.options.s3ClientOptions,
|
|
28
31
|
compress: this.options.compress,
|
|
29
32
|
options: {
|
|
@@ -47,6 +50,7 @@ export class S3UploadPlugin {
|
|
|
47
50
|
return isInclude && !isExclude;
|
|
48
51
|
}
|
|
49
52
|
}
|
|
53
|
+
exports.S3UploadPlugin = S3UploadPlugin;
|
|
50
54
|
function testRule(rule, source) {
|
|
51
55
|
if (rule instanceof RegExp) {
|
|
52
56
|
return rule.test(source);
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compile = compile;
|
|
4
|
+
const pretty_time_1 = require("../logger/pretty-time");
|
|
2
5
|
// @ts-ignore @swc/cli is not typed
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
const cli_1 = require("@swc/cli");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
async function compile({ projectPath, outputPath, logger }) {
|
|
6
9
|
const start = process.hrtime.bigint();
|
|
7
10
|
logger.message('Start compilation');
|
|
8
|
-
const { swcOptions, directoriesToCompile } = getSwcOptionsFromTsconfig(projectPath);
|
|
11
|
+
const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
|
|
9
12
|
const cliOptions = {
|
|
10
13
|
filenames: directoriesToCompile,
|
|
11
14
|
outDir: outputPath,
|
|
12
15
|
watch: false,
|
|
13
|
-
extensions: EXTENSIONS_TO_COMPILE,
|
|
16
|
+
extensions: utils_1.EXTENSIONS_TO_COMPILE,
|
|
14
17
|
stripLeadingPaths: true,
|
|
15
18
|
sync: false,
|
|
16
19
|
};
|
|
17
20
|
return new Promise((resolve, reject) => {
|
|
18
21
|
const callbacks = {
|
|
19
22
|
onSuccess: (_result) => {
|
|
20
|
-
logger.success(`Compiled successfully in ${elapsedTime(start)}`);
|
|
23
|
+
logger.success(`Compiled successfully in ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
21
24
|
resolve();
|
|
22
25
|
},
|
|
23
26
|
onFail: (result) => {
|
|
@@ -27,12 +30,12 @@ export async function compile({ projectPath, outputPath, logger }) {
|
|
|
27
30
|
logger.error(`${filename}: ${error}`);
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
|
-
logger.error(`Error compile, elapsed time ${elapsedTime(start)}`);
|
|
33
|
+
logger.error(`Error compile, elapsed time ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
31
34
|
reject(new Error('Compilation failed'));
|
|
32
35
|
},
|
|
33
36
|
};
|
|
34
37
|
try {
|
|
35
|
-
swcDir({
|
|
38
|
+
(0, cli_1.swcDir)({
|
|
36
39
|
cliOptions,
|
|
37
40
|
swcOptions,
|
|
38
41
|
callbacks,
|
package/dist/common/swc/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.watch = exports.compile = void 0;
|
|
4
|
+
var compile_1 = require("./compile");
|
|
5
|
+
Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compile_1.compile; } });
|
|
6
|
+
var watch_1 = require("./watch");
|
|
7
|
+
Object.defineProperty(exports, "watch", { enumerable: true, get: function () { return watch_1.watch; } });
|
package/dist/common/swc/utils.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EXTENSIONS_TO_COMPILE = void 0;
|
|
7
|
+
exports.getSwcOptionsFromTsconfig = getSwcOptionsFromTsconfig;
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const tsconfig_to_swcconfig_1 = require("tsconfig-to-swcconfig");
|
|
10
|
+
exports.EXTENSIONS_TO_COMPILE = ['.js', '.ts', '.mts', '.mjs', '.cjs'];
|
|
4
11
|
function resolvePaths(paths, baseUrl) {
|
|
5
12
|
const entries = [];
|
|
6
13
|
for (const targets of Object.values(paths)) {
|
|
7
14
|
for (const target of targets) {
|
|
8
|
-
const resolvedPath =
|
|
15
|
+
const resolvedPath = path_1.default.resolve(baseUrl, target.replace(/\*$/, ''));
|
|
9
16
|
entries.push(resolvedPath);
|
|
10
17
|
}
|
|
11
18
|
}
|
|
12
19
|
return entries;
|
|
13
20
|
}
|
|
14
|
-
|
|
15
|
-
const swcOptions = convert(filename, projectPath);
|
|
21
|
+
function getSwcOptionsFromTsconfig(projectPath, filename = 'tsconfig.json') {
|
|
22
|
+
const swcOptions = (0, tsconfig_to_swcconfig_1.convert)(filename, projectPath);
|
|
16
23
|
swcOptions.jsc = {
|
|
17
24
|
...swcOptions.jsc,
|
|
18
25
|
// SWC requires absolute path as baseUrl
|
package/dist/common/swc/watch.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.watch = watch;
|
|
1
4
|
// @ts-ignore @swc/cli is not typed
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
const cli_1 = require("@swc/cli");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
async function watch(projectPath, { outputPath, logger, onAfterFilesEmitted }) {
|
|
5
8
|
logger.message('Start compilation in watch mode');
|
|
6
|
-
const { swcOptions, directoriesToCompile } = getSwcOptionsFromTsconfig(projectPath);
|
|
9
|
+
const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
|
|
7
10
|
const cliOptions = {
|
|
8
11
|
filenames: directoriesToCompile,
|
|
9
12
|
outDir: outputPath,
|
|
10
13
|
watch: true,
|
|
11
|
-
extensions: EXTENSIONS_TO_COMPILE,
|
|
14
|
+
extensions: utils_1.EXTENSIONS_TO_COMPILE,
|
|
12
15
|
stripLeadingPaths: true,
|
|
13
16
|
sync: false,
|
|
14
17
|
logWatchCompilation: true,
|
|
@@ -35,7 +38,7 @@ export async function watch(projectPath, { outputPath, logger, onAfterFilesEmitt
|
|
|
35
38
|
logger.message('Watching for file changes');
|
|
36
39
|
},
|
|
37
40
|
};
|
|
38
|
-
swcDir({
|
|
41
|
+
(0, cli_1.swcDir)({
|
|
39
42
|
cliOptions,
|
|
40
43
|
swcOptions,
|
|
41
44
|
callbacks,
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compile = compile;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const transformers_1 = require("./transformers");
|
|
6
|
+
const pretty_time_1 = require("../logger/pretty-time");
|
|
7
|
+
const diagnostic_1 = require("./diagnostic");
|
|
8
|
+
function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToExtend, logger }) {
|
|
6
9
|
const start = process.hrtime.bigint();
|
|
7
10
|
logger.message('Start compilation');
|
|
8
11
|
logger.message(`Typescript v${ts.version}`);
|
|
9
12
|
logger.verbose(`Searching for the ${configFileName} in ${projectPath}`);
|
|
10
|
-
const parsedConfig = getTsProjectConfig(ts, projectPath, configFileName, {
|
|
13
|
+
const parsedConfig = (0, utils_1.getTsProjectConfig)(ts, projectPath, configFileName, {
|
|
11
14
|
noEmit: false,
|
|
12
15
|
noEmitOnError: true,
|
|
13
16
|
...optionsToExtend,
|
|
@@ -15,7 +18,7 @@ export function compile(ts, { projectPath, configFileName = 'tsconfig.json', opt
|
|
|
15
18
|
logger.verbose('Config found and parsed');
|
|
16
19
|
logger.verbose("We're about to create the program");
|
|
17
20
|
const compilerHost = ts.createCompilerHost(parsedConfig.options);
|
|
18
|
-
compilerHost.readFile = displayFilename(compilerHost.readFile, 'Reading', logger);
|
|
21
|
+
compilerHost.readFile = (0, utils_1.displayFilename)(compilerHost.readFile, 'Reading', logger);
|
|
19
22
|
// @ts-expect-error
|
|
20
23
|
compilerHost.readFile.enableDisplay();
|
|
21
24
|
const program = ts.createProgram(parsedConfig.fileNames, parsedConfig.options, compilerHost);
|
|
@@ -25,7 +28,7 @@ export function compile(ts, { projectPath, configFileName = 'tsconfig.json', opt
|
|
|
25
28
|
logger.verbose(`Program created, read ${filesCount} files`);
|
|
26
29
|
if (!hasErrors(allDiagnostics)) {
|
|
27
30
|
logger.verbose('We finished making the program! Emitting...');
|
|
28
|
-
const transformPathsToLocalModules = createTransformPathsToLocalModules(ts);
|
|
31
|
+
const transformPathsToLocalModules = (0, transformers_1.createTransformPathsToLocalModules)(ts);
|
|
29
32
|
const emitResult = program.emit(undefined, undefined, undefined, undefined, {
|
|
30
33
|
after: [transformPathsToLocalModules],
|
|
31
34
|
afterDeclarations: [transformPathsToLocalModules],
|
|
@@ -35,11 +38,11 @@ export function compile(ts, { projectPath, configFileName = 'tsconfig.json', opt
|
|
|
35
38
|
}
|
|
36
39
|
allDiagnostics.forEach(reportDiagnostic);
|
|
37
40
|
if (hasErrors(allDiagnostics)) {
|
|
38
|
-
logger.error(`Error compile, elapsed time ${elapsedTime(start)}`);
|
|
41
|
+
logger.error(`Error compile, elapsed time ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
39
42
|
process.exit(1);
|
|
40
43
|
}
|
|
41
44
|
else {
|
|
42
|
-
logger.success(`Compiled successfully in ${elapsedTime(start)}`);
|
|
45
|
+
logger.success(`Compiled successfully in ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
43
46
|
}
|
|
44
47
|
function reportDiagnostic(diagnostic) {
|
|
45
48
|
const formatHost = {
|
|
@@ -51,7 +54,7 @@ export function compile(ts, { projectPath, configFileName = 'tsconfig.json', opt
|
|
|
51
54
|
logger.message(ts.formatDiagnosticsWithColorAndContext([diagnostic], formatHost));
|
|
52
55
|
}
|
|
53
56
|
else {
|
|
54
|
-
logger.message(formatDiagnosticBrief(ts, diagnostic, formatHost));
|
|
57
|
+
logger.message((0, diagnostic_1.formatDiagnosticBrief)(ts, diagnostic, formatHost));
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
function hasErrors(diagnostics) {
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.formatDiagnosticBrief = formatDiagnosticBrief;
|
|
27
|
+
const path = __importStar(require("node:path"));
|
|
28
|
+
const colors_1 = require("../logger/colors");
|
|
29
|
+
function formatDiagnosticBrief(ts, diagnostic, host) {
|
|
4
30
|
let output = '';
|
|
5
31
|
if (diagnostic.file) {
|
|
6
32
|
const { file, start } = diagnostic;
|
|
@@ -8,31 +34,31 @@ export function formatDiagnosticBrief(ts, diagnostic, host) {
|
|
|
8
34
|
output += ' - ';
|
|
9
35
|
}
|
|
10
36
|
output += categoryColor(diagnostic.category)(ts.DiagnosticCategory[diagnostic.category]);
|
|
11
|
-
output += colors.grey(` TS${diagnostic.code}: `);
|
|
37
|
+
output += colors_1.colors.grey(` TS${diagnostic.code}: `);
|
|
12
38
|
output += ts.flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
|
|
13
39
|
return output;
|
|
14
40
|
function formatLocation(file, start) {
|
|
15
41
|
const { line, character } = ts.getLineAndCharacterOfPosition(file, start);
|
|
16
42
|
const filePath = path.relative(process.cwd(), file.fileName);
|
|
17
|
-
return (colors.cyanBright(filePath) +
|
|
43
|
+
return (colors_1.colors.cyanBright(filePath) +
|
|
18
44
|
':' +
|
|
19
|
-
colors.yellowBright(line + 1) +
|
|
45
|
+
colors_1.colors.yellowBright(line + 1) +
|
|
20
46
|
':' +
|
|
21
|
-
colors.yellowBright(character + 1));
|
|
47
|
+
colors_1.colors.yellowBright(character + 1));
|
|
22
48
|
}
|
|
23
49
|
function categoryColor(category) {
|
|
24
50
|
switch (category) {
|
|
25
51
|
case ts.DiagnosticCategory.Error: {
|
|
26
|
-
return colors.redBright;
|
|
52
|
+
return colors_1.colors.redBright;
|
|
27
53
|
}
|
|
28
54
|
case ts.DiagnosticCategory.Warning: {
|
|
29
|
-
return colors.yellowBright;
|
|
55
|
+
return colors_1.colors.yellowBright;
|
|
30
56
|
}
|
|
31
57
|
case ts.DiagnosticCategory.Suggestion: {
|
|
32
|
-
return colors.magentaBright;
|
|
58
|
+
return colors_1.colors.magentaBright;
|
|
33
59
|
}
|
|
34
60
|
default: {
|
|
35
|
-
return colors;
|
|
61
|
+
return colors_1.colors;
|
|
36
62
|
}
|
|
37
63
|
}
|
|
38
64
|
}
|