@gravity-ui/app-builder 0.6.10 → 0.7.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/README.md +29 -27
- package/dist/commands/build/build-service/server.js +1 -1
- package/dist/commands/build/index.js +1 -1
- package/dist/commands/dev/client.js +33 -10
- package/dist/commands/dev/index.js +25 -2
- package/dist/commands/dev/server.js +25 -2
- package/dist/common/babel/ui-preset.js +7 -0
- package/dist/common/child-process/controllable-script.js +4 -2
- package/dist/common/child-process/utils.js +5 -8
- package/dist/common/config.d.ts +1 -1
- package/dist/common/config.js +26 -3
- package/dist/common/env.js +2 -2
- package/dist/common/library/index.js +77 -55
- package/dist/common/links/link.js +42 -19
- package/dist/common/links/unlink.js +26 -3
- package/dist/common/logger/index.js +79 -79
- package/dist/common/models/index.d.ts +3 -3
- package/dist/common/package.js +30 -10
- package/dist/common/paths.js +26 -6
- package/dist/common/s3-upload/compress.js +3 -3
- package/dist/common/s3-upload/s3-client.d.ts +1 -1
- package/dist/common/s3-upload/s3-client.js +1 -1
- package/dist/common/s3-upload/upload.js +1 -1
- package/dist/common/s3-upload/webpack-plugin.js +1 -0
- package/dist/common/tempData.js +31 -7
- package/dist/common/typescript/compile.d.ts +7 -2
- package/dist/common/typescript/compile.js +5 -5
- package/dist/common/typescript/diagnostic.js +24 -4
- package/dist/common/typescript/transformers.js +1 -1
- package/dist/common/typescript/utils.d.ts +1 -1
- package/dist/common/typescript/utils.js +3 -3
- package/dist/common/utils.js +5 -5
- package/dist/common/webpack/config.js +33 -23
- package/dist/common/webpack/progress-plugin.js +6 -5
- package/dist/common/webpack/storybook.js +25 -3
- package/dist/common/webpack/utils.js +29 -9
- package/dist/common/webpack/worker/worker-loader.js +27 -4
- package/dist/create-cli.js +25 -2
- package/package.json +14 -11
- package/CHANGELOG.md +0 -257
- package/dist/common/library/babel-plugin-remove-css-imports.d.ts +0 -6
- package/dist/common/library/babel-plugin-remove-css-imports.js +0 -15
|
@@ -27,9 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.buildLibrary = void 0;
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
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");
|
|
33
34
|
const babel = __importStar(require("@babel/core"));
|
|
34
35
|
const fast_glob_1 = require("fast-glob");
|
|
35
36
|
const rimraf_1 = require("rimraf");
|
|
@@ -43,9 +44,9 @@ const babel_1 = require("../babel");
|
|
|
43
44
|
function getFilePath(filePath, { ext, dir } = { dir: paths_1.default.src }) {
|
|
44
45
|
let filePathWithExt = filePath;
|
|
45
46
|
if (ext) {
|
|
46
|
-
filePathWithExt = filePath.replace(
|
|
47
|
+
filePathWithExt = filePath.replace(path.extname(filePath), `.${ext}`);
|
|
47
48
|
}
|
|
48
|
-
return dir ?
|
|
49
|
+
return dir ? path.resolve(dir, filePathWithExt) : filePathWithExt;
|
|
49
50
|
}
|
|
50
51
|
function errorHandlerFactory(msg) {
|
|
51
52
|
return (err) => {
|
|
@@ -61,21 +62,21 @@ function errorHandlerFactory(msg) {
|
|
|
61
62
|
function copyToCjs(file, inputDir = paths_1.default.libBuildEsm) {
|
|
62
63
|
const esmFile = getFilePath(file, { dir: inputDir });
|
|
63
64
|
const cjsFile = getFilePath(file, { dir: paths_1.default.libBuildCjs });
|
|
64
|
-
const cjsDir =
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
const cjsDir = path.dirname(cjsFile);
|
|
66
|
+
fs.mkdirSync(cjsDir, { recursive: true });
|
|
67
|
+
fs.copyFile(esmFile, cjsFile, errorHandlerFactory(`Failed to copy file to cjs ${esmFile}`));
|
|
67
68
|
}
|
|
68
69
|
function compileToCjs(code, file, inputSourceMap, sourceDir = paths_1.default.src, compiledDir = paths_1.default.libBuildCjs) {
|
|
69
70
|
const sourceFile = getFilePath(file, { dir: sourceDir });
|
|
70
71
|
const compiledCjsFile = getFilePath(file, { dir: compiledDir, ext: 'js' });
|
|
71
|
-
const compiledCjsDir =
|
|
72
|
+
const compiledCjsDir = path.dirname(compiledCjsFile);
|
|
72
73
|
const sourcemapCjsFile = getFilePath(file, { dir: compiledDir, ext: 'js.map' });
|
|
73
|
-
const sourcemapCjsUrl = `// #sourceMappingURL=${
|
|
74
|
-
|
|
74
|
+
const sourcemapCjsUrl = `// #sourceMappingURL=${path.basename(sourcemapCjsFile)}`;
|
|
75
|
+
fs.mkdirSync(compiledCjsDir, { recursive: true });
|
|
75
76
|
babel.transform(code, {
|
|
77
|
+
babelrc: false,
|
|
76
78
|
filename: sourceFile,
|
|
77
79
|
plugins: [
|
|
78
|
-
require.resolve('./babel-plugin-remove-css-imports'),
|
|
79
80
|
require.resolve('@babel/plugin-transform-modules-commonjs'),
|
|
80
81
|
require.resolve('@babel/plugin-transform-dynamic-import'),
|
|
81
82
|
],
|
|
@@ -90,9 +91,9 @@ function compileToCjs(code, file, inputSourceMap, sourceDir = paths_1.default.sr
|
|
|
90
91
|
else if (transformedCjs) {
|
|
91
92
|
let cjsCode = transformedCjs.code ?? '';
|
|
92
93
|
cjsCode += (cjsCode.length ? '\n' : '') + sourcemapCjsUrl;
|
|
93
|
-
|
|
94
|
+
fs.writeFile(compiledCjsFile, cjsCode, errorHandlerFactory(`Source compilation has failed on writing ${compiledCjsFile}`));
|
|
94
95
|
if (transformedCjs.map) {
|
|
95
|
-
|
|
96
|
+
fs.writeFile(sourcemapCjsFile, JSON.stringify(transformedCjs.map), errorHandlerFactory(`Source compilation has failed on writing ${sourcemapCjsFile}`));
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
});
|
|
@@ -104,13 +105,13 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
|
|
|
104
105
|
origStylesStream.on('data', (file) => {
|
|
105
106
|
const origScssFile = getFilePath(file, { dir: inputDir });
|
|
106
107
|
const scssFile = getFilePath(file, { dir: outputDir });
|
|
107
|
-
const scssDir =
|
|
108
|
-
|
|
108
|
+
const scssDir = path.dirname(scssFile);
|
|
109
|
+
fs.mkdirSync(scssDir, { recursive: true });
|
|
109
110
|
if (origScssFile !== scssFile) {
|
|
110
|
-
const content =
|
|
111
|
+
const content = fs
|
|
111
112
|
.readFileSync(origScssFile, 'utf-8')
|
|
112
113
|
.replace(/url\(([.]*)..\/assets\//g, 'url($1../../assets/');
|
|
113
|
-
|
|
114
|
+
fs.writeFileSync(scssFile, content);
|
|
114
115
|
}
|
|
115
116
|
});
|
|
116
117
|
origStylesStream.on('finish', () => {
|
|
@@ -124,29 +125,42 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
|
|
|
124
125
|
const cssFile = getFilePath(file, { dir: outputDir, ext: 'css' });
|
|
125
126
|
const sourceMapFile = getFilePath(file, { dir: outputDir, ext: 'css.map' });
|
|
126
127
|
try {
|
|
127
|
-
const sassTransformed = sass_1.default.
|
|
128
|
-
file: scssFile,
|
|
128
|
+
const sassTransformed = sass_1.default.compile(scssFile, {
|
|
129
129
|
sourceMap: true,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
sourceMapIncludeSources: true,
|
|
131
|
+
importers: [
|
|
132
|
+
{
|
|
133
|
+
findFileUrl(url) {
|
|
134
|
+
if (url.startsWith('~')) {
|
|
135
|
+
return (0, node_url_1.pathToFileURL)(getFilePath(url.substring(1), { dir: paths_1.default.appNodeModules }));
|
|
136
|
+
}
|
|
137
|
+
throw new Error(`Unrecognized import ${url} in ${origScssFile}`);
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
],
|
|
138
141
|
});
|
|
139
|
-
if (sassTransformed
|
|
142
|
+
if (sassTransformed.css) {
|
|
143
|
+
const sourceMap = sassTransformed.sourceMap;
|
|
144
|
+
if (sourceMap) {
|
|
145
|
+
sourceMap.sources = sourceMap.sources.map((url) => {
|
|
146
|
+
return path.relative(path.dirname(scssFile), (0, node_url_1.fileURLToPath)(url));
|
|
147
|
+
});
|
|
148
|
+
}
|
|
140
149
|
const postcssTransformed = await (0, postcss_1.default)([
|
|
141
150
|
(0, postcss_preset_env_1.default)({ enableClientSidePolyfills: false }),
|
|
142
151
|
]).process(sassTransformed.css, {
|
|
143
|
-
to:
|
|
144
|
-
|
|
152
|
+
to: path.basename(cssFile),
|
|
153
|
+
from: path.basename(scssFile),
|
|
154
|
+
map: { prev: sourceMap, inline: false },
|
|
145
155
|
});
|
|
146
|
-
|
|
156
|
+
let css = postcssTransformed.css;
|
|
147
157
|
if (postcssTransformed.map) {
|
|
148
|
-
|
|
158
|
+
const finalSourceMap = postcssTransformed.map.toJSON();
|
|
159
|
+
finalSourceMap.sourceRoot = '';
|
|
160
|
+
fs.writeFileSync(sourceMapFile, JSON.stringify(finalSourceMap));
|
|
161
|
+
css += `\n/*# sourceMappingURL=${path.basename(sourceMapFile)} */`;
|
|
149
162
|
}
|
|
163
|
+
fs.writeFileSync(cssFile, css);
|
|
150
164
|
}
|
|
151
165
|
}
|
|
152
166
|
catch (sassErr) {
|
|
@@ -173,12 +187,13 @@ function buildLibrary(config) {
|
|
|
173
187
|
sourceStream.on('data', (file) => {
|
|
174
188
|
const sourceFile = getFilePath(file);
|
|
175
189
|
const compiledFile = getFilePath(file, { dir: paths_1.default.libBuildEsm, ext: 'js' });
|
|
176
|
-
const compiledDir =
|
|
190
|
+
const compiledDir = path.dirname(compiledFile);
|
|
177
191
|
const sourcemapFile = getFilePath(file, { dir: paths_1.default.libBuildEsm, ext: 'js.map' });
|
|
178
|
-
const sourcemapUrl = `// #sourceMappingURL=${
|
|
179
|
-
const source =
|
|
180
|
-
|
|
192
|
+
const sourcemapUrl = `// #sourceMappingURL=${path.basename(sourcemapFile)}`;
|
|
193
|
+
const source = fs.readFileSync(sourceFile, 'utf-8');
|
|
194
|
+
fs.mkdirSync(compiledDir, { recursive: true });
|
|
181
195
|
babel.transform(source, {
|
|
196
|
+
babelrc: false,
|
|
182
197
|
filename: sourceFile,
|
|
183
198
|
presets: [(0, babel_1.babelPreset)(config.lib)],
|
|
184
199
|
plugins: [
|
|
@@ -211,18 +226,19 @@ function buildLibrary(config) {
|
|
|
211
226
|
else if (transformed) {
|
|
212
227
|
const code = transformed.code ?? '';
|
|
213
228
|
const esmCode = code + (code.length ? '\n' : '') + sourcemapUrl;
|
|
214
|
-
|
|
229
|
+
fs.writeFile(compiledFile, esmCode, errorHandlerFactory(`Source compilation has failed on writing ${compiledFile}`));
|
|
215
230
|
if (transformed.map) {
|
|
216
|
-
|
|
231
|
+
fs.writeFile(sourcemapFile, JSON.stringify(transformed.map), errorHandlerFactory(`Source compilation has failed on writing ${sourcemapFile}`));
|
|
217
232
|
}
|
|
218
233
|
compileToCjs(code, file, transformed.map);
|
|
219
234
|
}
|
|
220
235
|
});
|
|
221
236
|
});
|
|
222
237
|
// type definitions compilation and type checking
|
|
223
|
-
const projectFilePath =
|
|
224
|
-
const tscExec =
|
|
225
|
-
|
|
238
|
+
const projectFilePath = path.resolve(paths_1.default.app, 'tsconfig.publish.json');
|
|
239
|
+
const tscExec = path.resolve(paths_1.default.appNodeModules, 'typescript/bin/tsc');
|
|
240
|
+
// eslint-disable-next-line security/detect-child-process
|
|
241
|
+
childProcess.exec(`${tscExec} -p ${projectFilePath} --declaration --emitDeclarationOnly --outDir build/esm`, (error, stdout, stderr) => {
|
|
226
242
|
logger_1.default.message(stdout);
|
|
227
243
|
logger_1.default.error(stderr);
|
|
228
244
|
if (!error && !stderr) {
|
|
@@ -239,7 +255,12 @@ function buildLibrary(config) {
|
|
|
239
255
|
});
|
|
240
256
|
// css compilation
|
|
241
257
|
compileStyles(paths_1.default.libGlobalStyles, paths_1.default.libCompiledGlobalStyles, () => {
|
|
242
|
-
compileStyles(paths_1.default.src, paths_1.default.libBuildEsm,
|
|
258
|
+
compileStyles(paths_1.default.src, paths_1.default.libBuildEsm, () => {
|
|
259
|
+
const stylesStream = (0, fast_glob_1.globStream)(['**/*.{css,css.map}'], {
|
|
260
|
+
cwd: paths_1.default.libBuildEsm,
|
|
261
|
+
});
|
|
262
|
+
stylesStream.on('data', copyToCjs);
|
|
263
|
+
}, internalGlobs);
|
|
243
264
|
});
|
|
244
265
|
// icons compilation to js
|
|
245
266
|
const iconSvgoDefinition = `
|
|
@@ -256,15 +277,16 @@ function buildLibrary(config) {
|
|
|
256
277
|
iconsStream.on('data', async (file) => {
|
|
257
278
|
const iconFile = getFilePath(file, { dir: paths_1.default.libAssets });
|
|
258
279
|
const componentFile = getFilePath(file, { dir: paths_1.default.libCompiledAssetsEsm, ext: 'js' });
|
|
259
|
-
const componentDir =
|
|
280
|
+
const componentDir = path.dirname(componentFile);
|
|
260
281
|
const componentDefFile = getFilePath(file, { dir: paths_1.default.libCompiledAssetsEsm, ext: 'd.ts' });
|
|
261
282
|
if (svgoRegEx.test(iconFile)) {
|
|
262
283
|
try {
|
|
263
|
-
const component = await (0, core_1.transform)(
|
|
284
|
+
const component = await (0, core_1.transform)(fs.readFileSync(iconFile, 'utf-8'), {
|
|
264
285
|
jsxRuntime: config.lib.newJsxTransform ? 'automatic' : 'classic',
|
|
265
286
|
plugins: [require.resolve('@svgr/plugin-jsx')],
|
|
266
287
|
});
|
|
267
288
|
babel.transform(component, {
|
|
289
|
+
babelrc: false,
|
|
268
290
|
filename: iconFile,
|
|
269
291
|
presets: [(0, babel_1.babelPreset)(config.lib)],
|
|
270
292
|
sourceMaps: true,
|
|
@@ -276,9 +298,9 @@ function buildLibrary(config) {
|
|
|
276
298
|
}
|
|
277
299
|
else if (transformed) {
|
|
278
300
|
if (transformed.code) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
301
|
+
fs.mkdirSync(componentDir, { recursive: true });
|
|
302
|
+
fs.writeFile(componentFile, transformed.code, errorHandlerFactory(`Icons compilation has failed on writing ${componentFile}`));
|
|
303
|
+
fs.writeFile(componentDefFile, iconBaseDefinition, errorHandlerFactory(`Icons compilations has failed on writing ${componentFile}`));
|
|
282
304
|
compileToCjs(transformed.code, file, transformed.map, paths_1.default.libAssets, paths_1.default.libCompiledAssetsCjs);
|
|
283
305
|
}
|
|
284
306
|
}
|
|
@@ -290,11 +312,11 @@ function buildLibrary(config) {
|
|
|
290
312
|
}
|
|
291
313
|
}
|
|
292
314
|
else {
|
|
293
|
-
const encoded = Buffer.from(
|
|
315
|
+
const encoded = Buffer.from(fs.readFileSync(iconFile, 'utf-8')).toString('base64');
|
|
294
316
|
const code = `export default 'data:image/svg+xml;base64,${encoded}'`;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
317
|
+
fs.mkdirSync(componentDir, { recursive: true });
|
|
318
|
+
fs.writeFile(componentFile, code, errorHandlerFactory(`Icons compilation has failed on writing ${componentFile}`));
|
|
319
|
+
fs.writeFile(componentDefFile, iconSvgoDefinition, errorHandlerFactory(`Icons compilations has failed on writing ${componentFile}`));
|
|
298
320
|
compileToCjs(code, file, undefined, paths_1.default.libAssets, paths_1.default.libCompiledAssetsCjs);
|
|
299
321
|
}
|
|
300
322
|
});
|
|
@@ -303,9 +325,9 @@ function buildLibrary(config) {
|
|
|
303
325
|
assetsStream.on('data', (file) => {
|
|
304
326
|
const assetFile = getFilePath(file);
|
|
305
327
|
const copiedAssetFile = getFilePath(file, { dir: paths_1.default.libBuildEsm });
|
|
306
|
-
const assetDir =
|
|
307
|
-
|
|
308
|
-
|
|
328
|
+
const assetDir = path.dirname(copiedAssetFile);
|
|
329
|
+
fs.mkdirSync(assetDir, { recursive: true });
|
|
330
|
+
fs.copyFile(assetFile, copiedAssetFile, errorHandlerFactory(`Failed to copy file ${assetFile}`));
|
|
309
331
|
copyToCjs(file, paths_1.default.src);
|
|
310
332
|
});
|
|
311
333
|
}
|
|
@@ -1,10 +1,33 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
29
|
+
const fs = __importStar(require("fs-extra"));
|
|
30
|
+
const path = __importStar(require("node:path"));
|
|
8
31
|
const semver_1 = __importDefault(require("semver"));
|
|
9
32
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
33
|
const logger_1 = __importDefault(require("../logger"));
|
|
@@ -13,27 +36,27 @@ const paths_1 = __importDefault(require("../paths"));
|
|
|
13
36
|
const tempData_1 = __importDefault(require("../tempData"));
|
|
14
37
|
const unlink_1 = require("./unlink");
|
|
15
38
|
function createRecursive(modulePath) {
|
|
16
|
-
const { dir } =
|
|
17
|
-
if (!
|
|
18
|
-
|
|
39
|
+
const { dir } = path.parse(modulePath);
|
|
40
|
+
if (!fs.existsSync(dir)) {
|
|
41
|
+
fs.mkdirpSync(dir);
|
|
19
42
|
}
|
|
20
43
|
}
|
|
21
44
|
let unlinkTried = false;
|
|
22
45
|
function link(packageLocation) {
|
|
23
46
|
const linkedPackageLocation = packageLocation.startsWith('/')
|
|
24
47
|
? packageLocation
|
|
25
|
-
:
|
|
48
|
+
: path.resolve(paths_1.default.app, packageLocation);
|
|
26
49
|
if (linkedPackageLocation) {
|
|
27
50
|
const packageInfo = (0, package_1.readPackage)(linkedPackageLocation);
|
|
28
|
-
const packNodeModulesDir =
|
|
29
|
-
const hiddenNodeModuleDir =
|
|
51
|
+
const packNodeModulesDir = path.resolve(packageInfo.location, 'node_modules');
|
|
52
|
+
const hiddenNodeModuleDir = path.resolve(packageInfo.location, '.node_modules');
|
|
30
53
|
const linkedPackage = {
|
|
31
54
|
name: packageInfo.name,
|
|
32
55
|
location: packageInfo.location,
|
|
33
56
|
nodeModules: [],
|
|
34
57
|
};
|
|
35
58
|
try {
|
|
36
|
-
|
|
59
|
+
fs.moveSync(packNodeModulesDir, hiddenNodeModuleDir);
|
|
37
60
|
const packNodeModulesInfo = (0, package_1.readNodeModules)(hiddenNodeModuleDir);
|
|
38
61
|
const appNodeModulesInfo = (0, package_1.readNodeModules)(paths_1.default.appNodeModules);
|
|
39
62
|
if (packageInfo.peerDependencies) {
|
|
@@ -57,29 +80,29 @@ function link(packageLocation) {
|
|
|
57
80
|
const nodeModule = packNodeModulesInfo.data[key];
|
|
58
81
|
if (appNodeModulesInfo.keys.includes(key)) {
|
|
59
82
|
if (!semver_1.default.satisfies(appNodeModulesInfo.data[key].version, nodeModule.version)) {
|
|
60
|
-
const newPath =
|
|
83
|
+
const newPath = path.resolve(packNodeModulesDir, nodeModule.name);
|
|
61
84
|
createRecursive(newPath);
|
|
62
|
-
|
|
85
|
+
fs.symlinkSync(nodeModule.location, newPath);
|
|
63
86
|
linkedPackage.nodeModules.push(newPath);
|
|
64
87
|
}
|
|
65
88
|
}
|
|
66
89
|
else {
|
|
67
|
-
const newPath =
|
|
90
|
+
const newPath = path.resolve(paths_1.default.appNodeModules, nodeModule.name);
|
|
68
91
|
createRecursive(newPath);
|
|
69
|
-
|
|
92
|
+
fs.symlinkSync(nodeModule.location, path.resolve(paths_1.default.appNodeModules, nodeModule.name));
|
|
70
93
|
linkedPackage.package = newPath;
|
|
71
94
|
linkedPackage.nodeModules.push(newPath);
|
|
72
95
|
}
|
|
73
96
|
});
|
|
74
|
-
const newPath =
|
|
75
|
-
if (
|
|
76
|
-
const hiddenPackage =
|
|
77
|
-
|
|
97
|
+
const newPath = path.resolve(paths_1.default.appNodeModules, packageInfo.name);
|
|
98
|
+
if (fs.existsSync(newPath)) {
|
|
99
|
+
const hiddenPackage = path.resolve(paths_1.default.appNodeModules, `.${packageInfo.name}`);
|
|
100
|
+
fs.moveSync(newPath, hiddenPackage);
|
|
78
101
|
linkedPackage.restorePackageFrom = hiddenPackage;
|
|
79
102
|
}
|
|
80
|
-
|
|
103
|
+
fs.symlinkSync(packageInfo.location, newPath);
|
|
81
104
|
linkedPackage.package = newPath;
|
|
82
|
-
if (
|
|
105
|
+
if (fs.existsSync(path.resolve(linkedPackage.location, 'tsconfig.json'))) {
|
|
83
106
|
linkedPackage.typescript = true;
|
|
84
107
|
}
|
|
85
108
|
let { linkedPackages } = tempData_1.default.getSettings();
|
|
@@ -1,4 +1,27 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
@@ -6,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
29
|
exports.unlinkPackage = void 0;
|
|
7
30
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
31
|
const rimraf_1 = require("rimraf");
|
|
9
|
-
const
|
|
32
|
+
const path = __importStar(require("node:path"));
|
|
10
33
|
const logger_1 = __importDefault(require("../logger"));
|
|
11
34
|
const tempData_1 = __importDefault(require("../tempData"));
|
|
12
35
|
// import paths from '../paths';
|
|
@@ -19,8 +42,8 @@ function unlinkPackage(linkedPackage) {
|
|
|
19
42
|
if (linkedPackage.package && linkedPackage.restorePackageFrom) {
|
|
20
43
|
fs_extra_1.default.moveSync(linkedPackage.restorePackageFrom, linkedPackage.package);
|
|
21
44
|
}
|
|
22
|
-
const packNodeModulesDir =
|
|
23
|
-
const hiddenNodeModuleDir =
|
|
45
|
+
const packNodeModulesDir = path.resolve(linkedPackage.location, 'node_modules');
|
|
46
|
+
const hiddenNodeModuleDir = path.resolve(linkedPackage.location, '.node_modules');
|
|
24
47
|
rimraf_1.rimraf.sync(packNodeModulesDir);
|
|
25
48
|
fs_extra_1.default.moveSync(hiddenNodeModuleDir, packNodeModulesDir);
|
|
26
49
|
const { linkedPackages } = tempData_1.default.getSettings();
|
|
@@ -26,94 +26,94 @@ function selectColor(namespace) {
|
|
|
26
26
|
return allColors[Math.abs(hash) % allColors.length] ?? colors_1.colors.green.bold;
|
|
27
27
|
}
|
|
28
28
|
class Logger {
|
|
29
|
+
colors = colors_1.colors;
|
|
30
|
+
_verbose = false;
|
|
31
|
+
_namespace = '';
|
|
32
|
+
_timestamp = BigInt(0);
|
|
33
|
+
_color = colors_1.colors.black;
|
|
29
34
|
constructor(namespace = '', verbose = false) {
|
|
30
|
-
this.colors = colors_1.colors;
|
|
31
|
-
this._verbose = false;
|
|
32
|
-
this._namespace = '';
|
|
33
|
-
this._timestamp = BigInt(0);
|
|
34
|
-
this._color = colors_1.colors.black;
|
|
35
|
-
this.print = (message, { verbose = false, wrap = false } = {}) => {
|
|
36
|
-
if (verbose && !this._verbose) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const prefix = this._namespace ? this._color(`[${this._namespace}]`) + ' ' : '';
|
|
40
|
-
const postfix = this._timestamp > 0 ? ' ' + this._color(`+${(0, pretty_time_1.elapsedTime)(this._timestamp)}`) : '';
|
|
41
|
-
let output = prefix + message + postfix;
|
|
42
|
-
if (wrap) {
|
|
43
|
-
const width = process.stdout.columns || (process.stdout.isTTY ? 80 : 200);
|
|
44
|
-
if ((0, strip_ansi_1.default)(output).length > width) {
|
|
45
|
-
output =
|
|
46
|
-
prefix + message.slice(0, width - (0, strip_ansi_1.default)(prefix + postfix).length) + postfix;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
process.stdout.write(output);
|
|
50
|
-
};
|
|
51
|
-
this.printLn = (message, { verbose = false } = {}) => {
|
|
52
|
-
if (verbose && !this._verbose) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
this.clearLine();
|
|
56
|
-
this.print(message);
|
|
57
|
-
process.stdout.write('\n');
|
|
58
|
-
this._timestamp = process.hrtime.bigint();
|
|
59
|
-
};
|
|
60
|
-
this.clearLine = () => {
|
|
61
|
-
if (process.stdout.isTTY) {
|
|
62
|
-
process.stdout.clearLine(0);
|
|
63
|
-
process.stdout.cursorTo(0);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
this.status = (msg) => {
|
|
67
|
-
if (process.stdout.isTTY) {
|
|
68
|
-
this.clearLine();
|
|
69
|
-
this.print(msg, { wrap: true });
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
this.message = (...args) => {
|
|
73
|
-
this.printLn(args.join(' '));
|
|
74
|
-
};
|
|
75
|
-
this.success = (...args) => {
|
|
76
|
-
this.printLn(this.colors.green(...args));
|
|
77
|
-
};
|
|
78
|
-
this.warning = (...args) => {
|
|
79
|
-
this.printLn(this.colors.yellow(...args));
|
|
80
|
-
};
|
|
81
|
-
this.error = (...args) => {
|
|
82
|
-
this.printLn(this.colors.red(...args));
|
|
83
|
-
};
|
|
84
|
-
this.logError = (errorMeta, error) => {
|
|
85
|
-
this.error(errorMeta);
|
|
86
|
-
if (error) {
|
|
87
|
-
const { name, message, stack } = error;
|
|
88
|
-
this.error(name);
|
|
89
|
-
this.error(message);
|
|
90
|
-
if (stack) {
|
|
91
|
-
this.error(stack);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
this.panic = (errorMeta, error) => {
|
|
96
|
-
this.logError(errorMeta, error);
|
|
97
|
-
process.exit(1);
|
|
98
|
-
};
|
|
99
|
-
this.setVerbose = (verbose) => {
|
|
100
|
-
this._verbose = verbose;
|
|
101
|
-
};
|
|
102
|
-
this.verbose = (...args) => {
|
|
103
|
-
this.printLn(this.colors.dim(...args), { verbose: true });
|
|
104
|
-
};
|
|
105
|
-
this.setNamespace = (namespace) => {
|
|
106
|
-
this._namespace = namespace;
|
|
107
|
-
this._color = selectColor(namespace);
|
|
108
|
-
};
|
|
109
35
|
this._verbose = verbose;
|
|
110
36
|
if (namespace) {
|
|
111
37
|
this.setNamespace(namespace);
|
|
112
38
|
}
|
|
113
39
|
}
|
|
40
|
+
print = (message, { verbose = false, wrap = false } = {}) => {
|
|
41
|
+
if (verbose && !this._verbose) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const prefix = this._namespace ? this._color(`[${this._namespace}]`) + ' ' : '';
|
|
45
|
+
const postfix = this._timestamp > 0 ? ' ' + this._color(`+${(0, pretty_time_1.elapsedTime)(this._timestamp)}`) : '';
|
|
46
|
+
let output = prefix + message + postfix;
|
|
47
|
+
if (wrap) {
|
|
48
|
+
const width = process.stdout.columns || (process.stdout.isTTY ? 80 : 200);
|
|
49
|
+
if ((0, strip_ansi_1.default)(output).length > width) {
|
|
50
|
+
output =
|
|
51
|
+
prefix + message.slice(0, width - (0, strip_ansi_1.default)(prefix + postfix).length) + postfix;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
process.stdout.write(output);
|
|
55
|
+
};
|
|
56
|
+
printLn = (message, { verbose = false } = {}) => {
|
|
57
|
+
if (verbose && !this._verbose) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.clearLine();
|
|
61
|
+
this.print(message);
|
|
62
|
+
process.stdout.write('\n');
|
|
63
|
+
this._timestamp = process.hrtime.bigint();
|
|
64
|
+
};
|
|
65
|
+
clearLine = () => {
|
|
66
|
+
if (process.stdout.isTTY) {
|
|
67
|
+
process.stdout.clearLine(0);
|
|
68
|
+
process.stdout.cursorTo(0);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
status = (msg) => {
|
|
72
|
+
if (process.stdout.isTTY) {
|
|
73
|
+
this.clearLine();
|
|
74
|
+
this.print(msg, { wrap: true });
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
message = (...args) => {
|
|
78
|
+
this.printLn(args.join(' '));
|
|
79
|
+
};
|
|
80
|
+
success = (...args) => {
|
|
81
|
+
this.printLn(this.colors.green(...args));
|
|
82
|
+
};
|
|
83
|
+
warning = (...args) => {
|
|
84
|
+
this.printLn(this.colors.yellow(...args));
|
|
85
|
+
};
|
|
86
|
+
error = (...args) => {
|
|
87
|
+
this.printLn(this.colors.red(...args));
|
|
88
|
+
};
|
|
89
|
+
logError = (errorMeta, error) => {
|
|
90
|
+
this.error(errorMeta);
|
|
91
|
+
if (error) {
|
|
92
|
+
const { name, message, stack } = error;
|
|
93
|
+
this.error(name);
|
|
94
|
+
this.error(message);
|
|
95
|
+
if (stack) {
|
|
96
|
+
this.error(stack);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
panic = (errorMeta, error) => {
|
|
101
|
+
this.logError(errorMeta, error);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
};
|
|
104
|
+
setVerbose = (verbose) => {
|
|
105
|
+
this._verbose = verbose;
|
|
106
|
+
};
|
|
114
107
|
get isVerbose() {
|
|
115
108
|
return this._verbose;
|
|
116
109
|
}
|
|
110
|
+
verbose = (...args) => {
|
|
111
|
+
this.printLn(this.colors.dim(...args), { verbose: true });
|
|
112
|
+
};
|
|
113
|
+
setNamespace = (namespace) => {
|
|
114
|
+
this._namespace = namespace;
|
|
115
|
+
this._color = selectColor(namespace);
|
|
116
|
+
};
|
|
117
117
|
}
|
|
118
118
|
exports.Logger = Logger;
|
|
119
119
|
exports.default = new Logger();
|
|
@@ -2,7 +2,7 @@ import type { EditorLanguage } from 'monaco-editor-webpack-plugin/out/languages'
|
|
|
2
2
|
import type { EditorFeature } from 'monaco-editor-webpack-plugin/out/features';
|
|
3
3
|
import type { IFeatureDefinition } from 'monaco-editor-webpack-plugin/out/types';
|
|
4
4
|
import type { Options as MomentTzOptions } from 'moment-timezone-data-webpack-plugin';
|
|
5
|
-
import type { Configuration,
|
|
5
|
+
import type { Configuration, DefinePlugin, FileCacheOptions, MemoryCacheOptions, ResolveOptions } from 'webpack';
|
|
6
6
|
import type { ServerConfiguration } from 'webpack-dev-server';
|
|
7
7
|
import type { Options as CircularDependenciesOptions } from 'circular-dependency-plugin';
|
|
8
8
|
import type { Config as SvgrConfig } from '@svgr/core';
|
|
@@ -93,9 +93,9 @@ export interface ClientConfig {
|
|
|
93
93
|
*/
|
|
94
94
|
hiddenSourceMap?: boolean;
|
|
95
95
|
/**
|
|
96
|
-
* additional libraries for vendor chunk
|
|
96
|
+
* additional libraries or a function returning libraries for a vendor chunk
|
|
97
97
|
*/
|
|
98
|
-
vendors?: string[];
|
|
98
|
+
vendors?: string[] | ((defaultVendors: string[]) => string[]);
|
|
99
99
|
/**
|
|
100
100
|
* [settings](https://www.npmjs.com/package/moment-timezone-data-webpack-plugin) for moment-timezone (by default data is truncated)
|
|
101
101
|
*/
|