@gravity-ui/app-builder 0.30.0 → 0.30.2
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/README.md +1 -0
- 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 +6 -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 +143 -89
- 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,7 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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.ControllableScript = void 0;
|
|
27
|
+
const utils_1 = require("./utils");
|
|
28
|
+
const fs = __importStar(require("fs-extra"));
|
|
29
|
+
const utils_2 = require("../utils");
|
|
30
|
+
class ControllableScript {
|
|
5
31
|
isRunning = false;
|
|
6
32
|
process;
|
|
7
33
|
script = '';
|
|
@@ -12,7 +38,7 @@ export class ControllableScript {
|
|
|
12
38
|
}
|
|
13
39
|
async start() {
|
|
14
40
|
const args = [];
|
|
15
|
-
const tmpFileName = tmpNameSync(await getCacheDir());
|
|
41
|
+
const tmpFileName = (0, utils_1.tmpNameSync)(await (0, utils_2.getCacheDir)());
|
|
16
42
|
fs.outputFileSync(tmpFileName, this.script);
|
|
17
43
|
this.isRunning = true;
|
|
18
44
|
// Passing --inspect isn't necessary for the child process to launch a port, but it allows some editors to automatically attach
|
|
@@ -97,3 +123,4 @@ export class ControllableScript {
|
|
|
97
123
|
this.process.send(msg);
|
|
98
124
|
}
|
|
99
125
|
}
|
|
126
|
+
exports.ControllableScript = ControllableScript;
|
|
@@ -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.tmpNameSync = tmpNameSync;
|
|
27
|
+
const crypto = __importStar(require("node:crypto"));
|
|
28
|
+
const path = __importStar(require("node:path"));
|
|
29
|
+
const fs = __importStar(require("fs-extra"));
|
|
4
30
|
const RANDOM_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
5
31
|
function randomChars(howMany) {
|
|
6
32
|
const value = [];
|
|
@@ -22,7 +48,7 @@ function generateTmpName(tmpDir) {
|
|
|
22
48
|
const name = ['tmp', '-', process.pid, '-', randomChars(12)].join('');
|
|
23
49
|
return path.join(tmpDir, name);
|
|
24
50
|
}
|
|
25
|
-
|
|
51
|
+
function tmpNameSync(tmpDir, retries = 3) {
|
|
26
52
|
let tries = retries;
|
|
27
53
|
do {
|
|
28
54
|
const name = generateTmpName(tmpDir);
|
package/dist/common/command.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/common/config.js
CHANGED
|
@@ -1,10 +1,40 @@
|
|
|
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.getProjectConfig = getProjectConfig;
|
|
30
|
+
exports.normalizeConfig = normalizeConfig;
|
|
31
|
+
const path = __importStar(require("node:path"));
|
|
32
|
+
const cosmiconfig_1 = require("cosmiconfig");
|
|
33
|
+
const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader");
|
|
34
|
+
const common_tags_1 = require("common-tags");
|
|
35
|
+
const models_1 = require("./models");
|
|
36
|
+
const utils_1 = require("./utils");
|
|
37
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
8
38
|
function splitPaths(paths) {
|
|
9
39
|
return (Array.isArray(paths) ? paths : [paths]).flatMap((p) => p.split(','));
|
|
10
40
|
}
|
|
@@ -22,7 +52,7 @@ function omitUndefined(obj) {
|
|
|
22
52
|
}
|
|
23
53
|
function getModuleLoader({ storybook } = {}) {
|
|
24
54
|
if (!storybook) {
|
|
25
|
-
return
|
|
55
|
+
return (0, cosmiconfig_typescript_loader_1.TypeScriptLoader)();
|
|
26
56
|
}
|
|
27
57
|
// storybook 7 uses esbuild-register to compile ts to cjs
|
|
28
58
|
// https://github.com/storybookjs/storybook/blob/c1ec290b3a74ce05b23f74250539ae571bffaa66/code/lib/core-common/src/utils/interpret-require.ts#L11
|
|
@@ -36,10 +66,10 @@ function getModuleLoader({ storybook } = {}) {
|
|
|
36
66
|
};
|
|
37
67
|
}
|
|
38
68
|
else {
|
|
39
|
-
return
|
|
69
|
+
return (0, cosmiconfig_typescript_loader_1.TypeScriptLoader)();
|
|
40
70
|
}
|
|
41
71
|
}
|
|
42
|
-
|
|
72
|
+
async function getProjectConfig(command, { env, storybook, ...argv }) {
|
|
43
73
|
function getLoader(loader) {
|
|
44
74
|
return async (pathname, content) => {
|
|
45
75
|
const config = loader(pathname, content);
|
|
@@ -51,7 +81,7 @@ export async function getProjectConfig(command, { env, storybook, ...argv }) {
|
|
|
51
81
|
}
|
|
52
82
|
const tsLoader = getLoader(getModuleLoader({ storybook }));
|
|
53
83
|
const moduleName = 'app-builder';
|
|
54
|
-
const explorer = cosmiconfigSync(moduleName, {
|
|
84
|
+
const explorer = (0, cosmiconfig_1.cosmiconfigSync)(moduleName, {
|
|
55
85
|
cache: false,
|
|
56
86
|
stopDir: process.cwd(),
|
|
57
87
|
searchPlaces: [
|
|
@@ -81,7 +111,7 @@ export async function getProjectConfig(command, { env, storybook, ...argv }) {
|
|
|
81
111
|
cfg = explorer.search();
|
|
82
112
|
}
|
|
83
113
|
const config = { verbose: false, ...(await cfg?.config) };
|
|
84
|
-
if (isLibraryConfig(config)) {
|
|
114
|
+
if ((0, models_1.isLibraryConfig)(config)) {
|
|
85
115
|
return normalizeConfig({
|
|
86
116
|
...config,
|
|
87
117
|
...omitUndefined({ verbose: argv.verbose }),
|
|
@@ -116,8 +146,8 @@ export async function getProjectConfig(command, { env, storybook, ...argv }) {
|
|
|
116
146
|
};
|
|
117
147
|
return normalizeConfig(projectConfig, command);
|
|
118
148
|
}
|
|
119
|
-
|
|
120
|
-
if (isServiceConfig(userConfig)) {
|
|
149
|
+
async function normalizeConfig(userConfig, mode) {
|
|
150
|
+
if ((0, models_1.isServiceConfig)(userConfig)) {
|
|
121
151
|
const clientConfig = typeof userConfig.client === 'object' ? userConfig.client : {};
|
|
122
152
|
const client = await normalizeClientConfig(clientConfig, mode);
|
|
123
153
|
client.verbose = userConfig.verbose;
|
|
@@ -133,7 +163,7 @@ export async function normalizeConfig(userConfig, mode) {
|
|
|
133
163
|
};
|
|
134
164
|
if (mode === 'dev') {
|
|
135
165
|
if (serverConfig.port === true) {
|
|
136
|
-
server.port = await getPort({ port: 3000 });
|
|
166
|
+
server.port = await (0, utils_1.getPort)({ port: 3000 });
|
|
137
167
|
}
|
|
138
168
|
else {
|
|
139
169
|
server.port = serverConfig.port;
|
|
@@ -165,7 +195,7 @@ async function normalizeClientConfig(client, mode) {
|
|
|
165
195
|
let transformCssWithLightningCss = Boolean(client.transformCssWithLightningCss);
|
|
166
196
|
if (client.moduleFederation?.isolateStyles && transformCssWithLightningCss) {
|
|
167
197
|
transformCssWithLightningCss = false;
|
|
168
|
-
|
|
198
|
+
logger_1.default.warning((0, common_tags_1.stripIndent) `
|
|
169
199
|
transformCssWithLightningCss option is disabled because moduleFederation.isolateStyles is enabled.
|
|
170
200
|
postcss loader will be used instead.
|
|
171
201
|
`);
|
|
@@ -202,20 +232,20 @@ async function normalizeClientConfig(client, mode) {
|
|
|
202
232
|
if (client.lazyCompilation) {
|
|
203
233
|
if (client.lazyCompilation === true) {
|
|
204
234
|
normalizedConfig.lazyCompilation = {
|
|
205
|
-
port: await getPort({ port: 6000 }),
|
|
235
|
+
port: await (0, utils_1.getPort)({ port: 6000 }),
|
|
206
236
|
};
|
|
207
237
|
}
|
|
208
238
|
else {
|
|
209
239
|
normalizedConfig.lazyCompilation = client.lazyCompilation;
|
|
210
240
|
}
|
|
211
241
|
if (!normalizedConfig.lazyCompilation.port) {
|
|
212
|
-
normalizedConfig.lazyCompilation.port = await getPort({ port: 6000 });
|
|
242
|
+
normalizedConfig.lazyCompilation.port = await (0, utils_1.getPort)({ port: 6000 });
|
|
213
243
|
}
|
|
214
244
|
}
|
|
215
245
|
const devServer = client.devServer?.port
|
|
216
246
|
? {
|
|
217
247
|
port: client.devServer.port === true
|
|
218
|
-
? await getPort({ port: 8000 })
|
|
248
|
+
? await (0, utils_1.getPort)({ port: 8000 })
|
|
219
249
|
: client.devServer.port,
|
|
220
250
|
ipc: undefined,
|
|
221
251
|
}
|
package/dist/common/env.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_path_1 = require("node:path");
|
|
4
|
+
const dotenv_1 = require("dotenv");
|
|
5
|
+
(0, dotenv_1.config)({ path: (0, node_path_1.resolve)(process.cwd(), '.env') });
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
3
|
/* eslint-disable no-param-reassign */
|
|
2
|
-
|
|
4
|
+
const helper_plugin_utils_1 = require("@babel/helper-plugin-utils");
|
|
3
5
|
const svgPathRe = /^\.\.\/(.*)\/assets\/(.*)\.svg$/;
|
|
4
|
-
|
|
6
|
+
exports.default = (0, helper_plugin_utils_1.declare)(function (api) {
|
|
5
7
|
return {
|
|
6
8
|
visitor: {
|
|
7
9
|
ImportDeclaration(path) {
|
|
@@ -1,18 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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.buildLibrary = buildLibrary;
|
|
30
|
+
const path = __importStar(require("node:path"));
|
|
31
|
+
const fs = __importStar(require("node:fs"));
|
|
32
|
+
const childProcess = __importStar(require("node:child_process"));
|
|
33
|
+
const node_url_1 = require("node:url");
|
|
34
|
+
const babel = __importStar(require("@babel/core"));
|
|
35
|
+
const fast_glob_1 = require("fast-glob");
|
|
36
|
+
const rimraf_1 = require("rimraf");
|
|
37
|
+
const sass_1 = __importDefault(require("sass"));
|
|
38
|
+
const postcss_1 = __importDefault(require("postcss"));
|
|
39
|
+
const postcss_preset_env_1 = __importDefault(require("postcss-preset-env"));
|
|
40
|
+
const core_1 = require("@svgr/core");
|
|
41
|
+
const paths_1 = __importDefault(require("../../common/paths"));
|
|
42
|
+
const logger_1 = __importDefault(require("../../common/logger"));
|
|
43
|
+
const babel_1 = require("../babel");
|
|
44
|
+
function getFilePath(filePath, { ext, dir } = { dir: paths_1.default.src }) {
|
|
16
45
|
let filePathWithExt = filePath;
|
|
17
46
|
if (ext) {
|
|
18
47
|
filePathWithExt = filePath.replace(path.extname(filePath), `.${ext}`);
|
|
@@ -23,21 +52,21 @@ function errorHandlerFactory(msg) {
|
|
|
23
52
|
return (err) => {
|
|
24
53
|
if (err) {
|
|
25
54
|
if (msg) {
|
|
26
|
-
|
|
55
|
+
logger_1.default.error(msg);
|
|
27
56
|
}
|
|
28
|
-
|
|
57
|
+
logger_1.default.error(err.toString());
|
|
29
58
|
throw err;
|
|
30
59
|
}
|
|
31
60
|
};
|
|
32
61
|
}
|
|
33
|
-
function copyToCjs(file, inputDir =
|
|
62
|
+
function copyToCjs(file, inputDir = paths_1.default.libBuildEsm) {
|
|
34
63
|
const esmFile = getFilePath(file, { dir: inputDir });
|
|
35
|
-
const cjsFile = getFilePath(file, { dir:
|
|
64
|
+
const cjsFile = getFilePath(file, { dir: paths_1.default.libBuildCjs });
|
|
36
65
|
const cjsDir = path.dirname(cjsFile);
|
|
37
66
|
fs.mkdirSync(cjsDir, { recursive: true });
|
|
38
67
|
fs.copyFile(esmFile, cjsFile, errorHandlerFactory(`Failed to copy file to cjs ${esmFile}`));
|
|
39
68
|
}
|
|
40
|
-
function compileToCjs(code, file, inputSourceMap, sourceDir =
|
|
69
|
+
function compileToCjs(code, file, inputSourceMap, sourceDir = paths_1.default.src, compiledDir = paths_1.default.libBuildCjs) {
|
|
41
70
|
const sourceFile = getFilePath(file, { dir: sourceDir });
|
|
42
71
|
const compiledCjsFile = getFilePath(file, { dir: compiledDir, ext: 'js' });
|
|
43
72
|
const compiledCjsDir = path.dirname(compiledCjsFile);
|
|
@@ -56,8 +85,8 @@ function compileToCjs(code, file, inputSourceMap, sourceDir = paths.src, compile
|
|
|
56
85
|
inputSourceMap,
|
|
57
86
|
}, (err, transformedCjs) => {
|
|
58
87
|
if (err) {
|
|
59
|
-
|
|
60
|
-
|
|
88
|
+
logger_1.default.error(`Source compilation errors for ${sourceFile}`);
|
|
89
|
+
logger_1.default.error(err.toString());
|
|
61
90
|
throw err;
|
|
62
91
|
}
|
|
63
92
|
else if (transformedCjs) {
|
|
@@ -71,7 +100,7 @@ function compileToCjs(code, file, inputSourceMap, sourceDir = paths.src, compile
|
|
|
71
100
|
});
|
|
72
101
|
}
|
|
73
102
|
function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
|
|
74
|
-
const origStylesStream = globStream(['**/*.{sass,scss,css}', ...additionalGlobs], {
|
|
103
|
+
const origStylesStream = (0, fast_glob_1.globStream)(['**/*.{sass,scss,css}', ...additionalGlobs], {
|
|
75
104
|
cwd: inputDir,
|
|
76
105
|
});
|
|
77
106
|
origStylesStream.on('data', (file) => {
|
|
@@ -87,24 +116,24 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
|
|
|
87
116
|
}
|
|
88
117
|
});
|
|
89
118
|
origStylesStream.on('finish', () => {
|
|
90
|
-
const globs = outputDir ===
|
|
119
|
+
const globs = outputDir === paths_1.default.libBuildEsm
|
|
91
120
|
? ['**/*.{sass,scss,css}', '!cjs/**/*']
|
|
92
121
|
: ['**/*.{sass,scss,css}'];
|
|
93
|
-
const stylesStream = globStream(globs, { cwd: outputDir });
|
|
122
|
+
const stylesStream = (0, fast_glob_1.globStream)(globs, { cwd: outputDir });
|
|
94
123
|
stylesStream.on('data', async (file) => {
|
|
95
124
|
const origScssFile = getFilePath(file, { dir: inputDir });
|
|
96
125
|
const scssFile = getFilePath(file, { dir: outputDir });
|
|
97
126
|
const cssFile = getFilePath(file, { dir: outputDir, ext: 'css' });
|
|
98
127
|
const sourceMapFile = getFilePath(file, { dir: outputDir, ext: 'css.map' });
|
|
99
128
|
try {
|
|
100
|
-
const sassTransformed =
|
|
129
|
+
const sassTransformed = sass_1.default.compile(scssFile, {
|
|
101
130
|
sourceMap: true,
|
|
102
131
|
sourceMapIncludeSources: true,
|
|
103
132
|
importers: [
|
|
104
133
|
{
|
|
105
134
|
findFileUrl(url) {
|
|
106
135
|
if (url.startsWith('~')) {
|
|
107
|
-
return pathToFileURL(getFilePath(url.substring(1), { dir:
|
|
136
|
+
return (0, node_url_1.pathToFileURL)(getFilePath(url.substring(1), { dir: paths_1.default.appNodeModules }));
|
|
108
137
|
}
|
|
109
138
|
throw new Error(`Unrecognized import ${url} in ${origScssFile}`);
|
|
110
139
|
},
|
|
@@ -115,11 +144,11 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
|
|
|
115
144
|
const sourceMap = sassTransformed.sourceMap;
|
|
116
145
|
if (sourceMap) {
|
|
117
146
|
sourceMap.sources = sourceMap.sources.map((url) => {
|
|
118
|
-
return path.relative(path.dirname(scssFile), fileURLToPath(url));
|
|
147
|
+
return path.relative(path.dirname(scssFile), (0, node_url_1.fileURLToPath)(url));
|
|
119
148
|
});
|
|
120
149
|
}
|
|
121
|
-
const postcssTransformed = await
|
|
122
|
-
|
|
150
|
+
const postcssTransformed = await (0, postcss_1.default)([
|
|
151
|
+
(0, postcss_preset_env_1.default)({ enableClientSidePolyfills: false }),
|
|
123
152
|
]).process(sassTransformed.css, {
|
|
124
153
|
to: path.basename(cssFile),
|
|
125
154
|
from: path.basename(scssFile),
|
|
@@ -136,7 +165,7 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
|
|
|
136
165
|
}
|
|
137
166
|
}
|
|
138
167
|
catch (sassErr) {
|
|
139
|
-
|
|
168
|
+
logger_1.default.error(`Style compilation errors for ${scssFile}`);
|
|
140
169
|
throw sassErr;
|
|
141
170
|
}
|
|
142
171
|
});
|
|
@@ -149,19 +178,19 @@ const svgoPreset = {
|
|
|
149
178
|
name: 'preset-default',
|
|
150
179
|
params: { overrides: { removeViewBox: false } },
|
|
151
180
|
};
|
|
152
|
-
|
|
181
|
+
function buildLibrary(config) {
|
|
153
182
|
const internalGlobs = config.lib?.internalDirs?.map((dir) => `!${dir}/**/*`) ?? [];
|
|
154
|
-
rimraf.sync(
|
|
155
|
-
const tsConfigFilePath = path.resolve(
|
|
183
|
+
rimraf_1.rimraf.sync(paths_1.default.libBuild);
|
|
184
|
+
const tsConfigFilePath = path.resolve(paths_1.default.app, 'tsconfig.publish.json');
|
|
156
185
|
// sources compilation
|
|
157
|
-
const sourceStream = globStream(['**/*.{js,jsx,ts,tsx}', '!**/*.d.ts', ...internalGlobs], {
|
|
158
|
-
cwd:
|
|
186
|
+
const sourceStream = (0, fast_glob_1.globStream)(['**/*.{js,jsx,ts,tsx}', '!**/*.d.ts', ...internalGlobs], {
|
|
187
|
+
cwd: paths_1.default.src,
|
|
159
188
|
});
|
|
160
189
|
sourceStream.on('data', (file) => {
|
|
161
190
|
const sourceFile = getFilePath(file);
|
|
162
|
-
const compiledFile = getFilePath(file, { dir:
|
|
191
|
+
const compiledFile = getFilePath(file, { dir: paths_1.default.libBuildEsm, ext: 'js' });
|
|
163
192
|
const compiledDir = path.dirname(compiledFile);
|
|
164
|
-
const sourcemapFile = getFilePath(file, { dir:
|
|
193
|
+
const sourcemapFile = getFilePath(file, { dir: paths_1.default.libBuildEsm, ext: 'js.map' });
|
|
165
194
|
const sourcemapUrl = `// #sourceMappingURL=${path.basename(sourcemapFile)}`;
|
|
166
195
|
const source = fs.readFileSync(sourceFile, 'utf-8');
|
|
167
196
|
fs.mkdirSync(compiledDir, { recursive: true });
|
|
@@ -169,7 +198,7 @@ export function buildLibrary(config) {
|
|
|
169
198
|
babelrc: false,
|
|
170
199
|
configFile: false,
|
|
171
200
|
filename: sourceFile,
|
|
172
|
-
presets: [babelPreset(config.lib)],
|
|
201
|
+
presets: [(0, babel_1.babelPreset)(config.lib)],
|
|
173
202
|
plugins: [
|
|
174
203
|
[
|
|
175
204
|
require.resolve('babel-plugin-inline-react-svg'),
|
|
@@ -199,8 +228,8 @@ export function buildLibrary(config) {
|
|
|
199
228
|
sourceMaps: true,
|
|
200
229
|
}, (err, transformed) => {
|
|
201
230
|
if (err) {
|
|
202
|
-
|
|
203
|
-
|
|
231
|
+
logger_1.default.error(`Source compilation errors for ${sourceFile}`);
|
|
232
|
+
logger_1.default.error(err.toString());
|
|
204
233
|
throw err;
|
|
205
234
|
}
|
|
206
235
|
else if (transformed) {
|
|
@@ -215,28 +244,28 @@ export function buildLibrary(config) {
|
|
|
215
244
|
});
|
|
216
245
|
});
|
|
217
246
|
// type definitions compilation and type checking
|
|
218
|
-
const tscExec = path.resolve(
|
|
247
|
+
const tscExec = path.resolve(paths_1.default.appNodeModules, 'typescript/bin/tsc');
|
|
219
248
|
// eslint-disable-next-line security/detect-child-process
|
|
220
249
|
childProcess.exec(`${tscExec} -p ${tsConfigFilePath} --declaration --emitDeclarationOnly --outDir build/esm`, (error, stdout, stderr) => {
|
|
221
|
-
|
|
222
|
-
|
|
250
|
+
logger_1.default.message(stdout);
|
|
251
|
+
logger_1.default.error(stderr);
|
|
223
252
|
if (!error && !stderr) {
|
|
224
|
-
|
|
225
|
-
const typingsStream = globStream(['**/*.d.ts', '!cjs/**/*'], {
|
|
226
|
-
cwd:
|
|
253
|
+
logger_1.default.message('Typechecking successfully completed');
|
|
254
|
+
const typingsStream = (0, fast_glob_1.globStream)(['**/*.d.ts', '!cjs/**/*'], {
|
|
255
|
+
cwd: paths_1.default.libBuildEsm,
|
|
227
256
|
});
|
|
228
257
|
typingsStream.on('data', copyToCjs);
|
|
229
258
|
}
|
|
230
259
|
else {
|
|
231
|
-
|
|
260
|
+
logger_1.default.error('Errors during library typechecking. Aborting...');
|
|
232
261
|
process.exit(1);
|
|
233
262
|
}
|
|
234
263
|
});
|
|
235
264
|
// css compilation
|
|
236
|
-
compileStyles(
|
|
237
|
-
compileStyles(
|
|
238
|
-
const stylesStream = globStream(['**/*.{css,css.map}'], {
|
|
239
|
-
cwd:
|
|
265
|
+
compileStyles(paths_1.default.libGlobalStyles, paths_1.default.libCompiledGlobalStyles, () => {
|
|
266
|
+
compileStyles(paths_1.default.src, paths_1.default.libBuildEsm, () => {
|
|
267
|
+
const stylesStream = (0, fast_glob_1.globStream)(['**/*.{css,css.map}'], {
|
|
268
|
+
cwd: paths_1.default.libBuildEsm,
|
|
240
269
|
});
|
|
241
270
|
stylesStream.on('data', copyToCjs);
|
|
242
271
|
}, internalGlobs);
|
|
@@ -252,15 +281,15 @@ export function buildLibrary(config) {
|
|
|
252
281
|
export default icon;
|
|
253
282
|
`;
|
|
254
283
|
const svgoRegEx = /assets\/icons/;
|
|
255
|
-
const iconsStream = globStream(['**/*.svg', ...internalGlobs], { cwd:
|
|
284
|
+
const iconsStream = (0, fast_glob_1.globStream)(['**/*.svg', ...internalGlobs], { cwd: paths_1.default.libAssets });
|
|
256
285
|
iconsStream.on('data', async (file) => {
|
|
257
|
-
const iconFile = getFilePath(file, { dir:
|
|
258
|
-
const componentFile = getFilePath(file, { dir:
|
|
286
|
+
const iconFile = getFilePath(file, { dir: paths_1.default.libAssets });
|
|
287
|
+
const componentFile = getFilePath(file, { dir: paths_1.default.libCompiledAssetsEsm, ext: 'js' });
|
|
259
288
|
const componentDir = path.dirname(componentFile);
|
|
260
|
-
const componentDefFile = getFilePath(file, { dir:
|
|
289
|
+
const componentDefFile = getFilePath(file, { dir: paths_1.default.libCompiledAssetsEsm, ext: 'd.ts' });
|
|
261
290
|
if (svgoRegEx.test(iconFile)) {
|
|
262
291
|
try {
|
|
263
|
-
const component = await transform(fs.readFileSync(iconFile, 'utf-8'), {
|
|
292
|
+
const component = await (0, core_1.transform)(fs.readFileSync(iconFile, 'utf-8'), {
|
|
264
293
|
jsxRuntime: config.lib.newJsxTransform ? 'automatic' : 'classic',
|
|
265
294
|
plugins: [require.resolve('@svgr/plugin-jsx')],
|
|
266
295
|
});
|
|
@@ -268,12 +297,12 @@ export function buildLibrary(config) {
|
|
|
268
297
|
babelrc: false,
|
|
269
298
|
configFile: false,
|
|
270
299
|
filename: iconFile,
|
|
271
|
-
presets: [babelPreset(config.lib)],
|
|
300
|
+
presets: [(0, babel_1.babelPreset)(config.lib)],
|
|
272
301
|
sourceMaps: true,
|
|
273
302
|
}, (err, transformed) => {
|
|
274
303
|
if (err) {
|
|
275
|
-
|
|
276
|
-
|
|
304
|
+
logger_1.default.error(`Icons compilation errors for ${iconFile}`);
|
|
305
|
+
logger_1.default.error(err.toString());
|
|
277
306
|
throw err;
|
|
278
307
|
}
|
|
279
308
|
else if (transformed) {
|
|
@@ -281,13 +310,13 @@ export function buildLibrary(config) {
|
|
|
281
310
|
fs.mkdirSync(componentDir, { recursive: true });
|
|
282
311
|
fs.writeFile(componentFile, transformed.code, errorHandlerFactory(`Icons compilation has failed on writing ${componentFile}`));
|
|
283
312
|
fs.writeFile(componentDefFile, iconBaseDefinition, errorHandlerFactory(`Icons compilations has failed on writing ${componentFile}`));
|
|
284
|
-
compileToCjs(transformed.code, file, transformed.map,
|
|
313
|
+
compileToCjs(transformed.code, file, transformed.map, paths_1.default.libAssets, paths_1.default.libCompiledAssetsCjs);
|
|
285
314
|
}
|
|
286
315
|
}
|
|
287
316
|
});
|
|
288
317
|
}
|
|
289
318
|
catch (err) {
|
|
290
|
-
|
|
319
|
+
logger_1.default.error(`Svgo compilation errors for ${iconFile}`);
|
|
291
320
|
throw err;
|
|
292
321
|
}
|
|
293
322
|
}
|
|
@@ -297,17 +326,17 @@ export function buildLibrary(config) {
|
|
|
297
326
|
fs.mkdirSync(componentDir, { recursive: true });
|
|
298
327
|
fs.writeFile(componentFile, code, errorHandlerFactory(`Icons compilation has failed on writing ${componentFile}`));
|
|
299
328
|
fs.writeFile(componentDefFile, iconSvgoDefinition, errorHandlerFactory(`Icons compilations has failed on writing ${componentFile}`));
|
|
300
|
-
compileToCjs(code, file, undefined,
|
|
329
|
+
compileToCjs(code, file, undefined, paths_1.default.libAssets, paths_1.default.libCompiledAssetsCjs);
|
|
301
330
|
}
|
|
302
331
|
});
|
|
303
332
|
// file assets copying
|
|
304
|
-
const assetsStream = globStream(['**/*.json', '!**/tsconfig.json', '**/*.d.ts', ...internalGlobs], { cwd:
|
|
333
|
+
const assetsStream = (0, fast_glob_1.globStream)(['**/*.json', '!**/tsconfig.json', '**/*.d.ts', ...internalGlobs], { cwd: paths_1.default.src });
|
|
305
334
|
assetsStream.on('data', (file) => {
|
|
306
335
|
const assetFile = getFilePath(file);
|
|
307
|
-
const copiedAssetFile = getFilePath(file, { dir:
|
|
336
|
+
const copiedAssetFile = getFilePath(file, { dir: paths_1.default.libBuildEsm });
|
|
308
337
|
const assetDir = path.dirname(copiedAssetFile);
|
|
309
338
|
fs.mkdirSync(assetDir, { recursive: true });
|
|
310
339
|
fs.copyFile(assetFile, copiedAssetFile, errorHandlerFactory(`Failed to copy file ${assetFile}`));
|
|
311
|
-
copyToCjs(file,
|
|
340
|
+
copyToCjs(file, paths_1.default.src);
|
|
312
341
|
});
|
|
313
342
|
}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.colors = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
exports.colors = chalk_1.default;
|