arui-scripts 0.0.0-beta-20260824133302
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/.eslintignore +2 -0
- package/.eslintrc.js +17 -0
- package/.prettierignore +2 -0
- package/.turbo/turbo-build.log +0 -0
- package/.turbo/turbo-test.log +23 -0
- package/CHANGELOG.md +1976 -0
- package/README.md +59 -0
- package/bin/build.sh +2 -0
- package/build/bin/index.d.ts +2 -0
- package/build/bin/index.js +26 -0
- package/build/commands/archive-build/index.d.ts +1 -0
- package/build/commands/archive-build/index.js +15 -0
- package/build/commands/build/build-wrapper.d.ts +8 -0
- package/build/commands/build/build-wrapper.js +40 -0
- package/build/commands/build/client.d.ts +1 -0
- package/build/commands/build/client.js +54 -0
- package/build/commands/build/index.d.ts +1 -0
- package/build/commands/build/index.js +11 -0
- package/build/commands/build/server.d.ts +1 -0
- package/build/commands/build/server.js +29 -0
- package/build/commands/bundle-analyze/index.d.ts +1 -0
- package/build/commands/bundle-analyze/index.js +62 -0
- package/build/commands/changelog/index.d.ts +5 -0
- package/build/commands/changelog/index.js +141 -0
- package/build/commands/docker-build/index.d.ts +1 -0
- package/build/commands/docker-build/index.js +15 -0
- package/build/commands/docker-build-compiled/index.d.ts +1 -0
- package/build/commands/docker-build-compiled/index.js +15 -0
- package/build/commands/ensure-yarn/index.d.ts +1 -0
- package/build/commands/ensure-yarn/index.js +8 -0
- package/build/commands/start/client.d.ts +1 -0
- package/build/commands/start/client.js +7 -0
- package/build/commands/start/index.d.ts +1 -0
- package/build/commands/start/index.js +13 -0
- package/build/commands/start/print-compiler-output.d.ts +2 -0
- package/build/commands/start/print-compiler-output.js +16 -0
- package/build/commands/start/server.d.ts +1 -0
- package/build/commands/start/server.js +7 -0
- package/build/commands/start-prod/client.d.ts +1 -0
- package/build/commands/start-prod/client.js +7 -0
- package/build/commands/start-prod/index.d.ts +1 -0
- package/build/commands/start-prod/index.js +13 -0
- package/build/commands/start-prod/server.d.ts +1 -0
- package/build/commands/start-prod/server.js +7 -0
- package/build/commands/test/get-config.d.ts +1 -0
- package/build/commands/test/get-config.js +83 -0
- package/build/commands/test/index.d.ts +1 -0
- package/build/commands/test/index.js +68 -0
- package/build/commands/test-vitest/index.d.ts +1 -0
- package/build/commands/test-vitest/index.js +15 -0
- package/build/commands/util/artifacts-config.d.ts +25 -0
- package/build/commands/util/artifacts-config.js +119 -0
- package/build/commands/util/artifacts-deprecations.d.ts +9 -0
- package/build/commands/util/artifacts-deprecations.js +65 -0
- package/build/commands/util/arui-scripts-artifacts.d.ts +16 -0
- package/build/commands/util/arui-scripts-artifacts.js +29 -0
- package/build/commands/util/client-assets-sizes.d.ts +2 -0
- package/build/commands/util/client-assets-sizes.js +71 -0
- package/build/commands/util/docker-build.d.ts +35 -0
- package/build/commands/util/docker-build.js +76 -0
- package/build/commands/util/exec.d.ts +1 -0
- package/build/commands/util/exec.js +6 -0
- package/build/commands/util/format-webpack-messages.d.ts +5 -0
- package/build/commands/util/format-webpack-messages.js +95 -0
- package/build/commands/util/get-local-ident.d.ts +6 -0
- package/build/commands/util/get-local-ident.js +29 -0
- package/build/commands/util/load-browserslist.d.ts +1 -0
- package/build/commands/util/load-browserslist.js +15 -0
- package/build/commands/util/make-tmp-dir.d.ts +5 -0
- package/build/commands/util/make-tmp-dir.js +29 -0
- package/build/commands/util/print-build-error.d.ts +1 -0
- package/build/commands/util/print-build-error.js +32 -0
- package/build/commands/util/run-artifacts-cli.d.ts +7 -0
- package/build/commands/util/run-artifacts-cli.js +60 -0
- package/build/commands/util/run-client-dev-server.d.ts +2 -0
- package/build/commands/util/run-client-dev-server.js +47 -0
- package/build/commands/util/run-compilers.d.ts +1 -0
- package/build/commands/util/run-compilers.js +37 -0
- package/build/commands/util/run-server-watch-compiler.d.ts +2 -0
- package/build/commands/util/run-server-watch-compiler.js +17 -0
- package/build/commands/util/run-vitest.d.ts +7 -0
- package/build/commands/util/run-vitest.js +41 -0
- package/build/commands/util/tsc.d.ts +1 -0
- package/build/commands/util/tsc.js +13 -0
- package/build/commands/util/yarn.d.ts +10 -0
- package/build/commands/util/yarn.js +25 -0
- package/build/configs/app-configs/calculate-dependent-config.d.ts +9 -0
- package/build/configs/app-configs/calculate-dependent-config.js +55 -0
- package/build/configs/app-configs/get-defaults.d.ts +5 -0
- package/build/configs/app-configs/get-defaults.js +151 -0
- package/build/configs/app-configs/index.d.ts +5 -0
- package/build/configs/app-configs/index.js +25 -0
- package/build/configs/app-configs/read-config-file.d.ts +2 -0
- package/build/configs/app-configs/read-config-file.js +28 -0
- package/build/configs/app-configs/types.d.ts +146 -0
- package/build/configs/app-configs/types.js +2 -0
- package/build/configs/app-configs/update-with-config-file.d.ts +2 -0
- package/build/configs/app-configs/update-with-config-file.js +17 -0
- package/build/configs/app-configs/update-with-env.d.ts +2 -0
- package/build/configs/app-configs/update-with-env.js +23 -0
- package/build/configs/app-configs/update-with-package.d.ts +2 -0
- package/build/configs/app-configs/update-with-package.js +13 -0
- package/build/configs/app-configs/update-with-presets.d.ts +3 -0
- package/build/configs/app-configs/update-with-presets.js +41 -0
- package/build/configs/app-configs/validate-config.d.ts +2 -0
- package/build/configs/app-configs/validate-config.js +8 -0
- package/build/configs/app-configs/validate-settings-keys.d.ts +7 -0
- package/build/configs/app-configs/validate-settings-keys.js +16 -0
- package/build/configs/app-configs/warn-about-deprecations.d.ts +2 -0
- package/build/configs/app-configs/warn-about-deprecations.js +22 -0
- package/build/configs/babel-client.d.ts +31 -0
- package/build/configs/babel-client.js +69 -0
- package/build/configs/babel-dependencies.d.ts +14 -0
- package/build/configs/babel-dependencies.js +36 -0
- package/build/configs/babel-server.d.ts +26 -0
- package/build/configs/babel-server.js +45 -0
- package/build/configs/client-env-config/add-env-to-html-template.d.ts +1 -0
- package/build/configs/client-env-config/add-env-to-html-template.js +7 -0
- package/build/configs/client-env-config/client-config-plugin.d.ts +5 -0
- package/build/configs/client-env-config/client-config-plugin.js +26 -0
- package/build/configs/client-env-config/constants.d.ts +1 -0
- package/build/configs/client-env-config/constants.js +4 -0
- package/build/configs/client-env-config/get-env-config.d.ts +2 -0
- package/build/configs/client-env-config/get-env-config.js +28 -0
- package/build/configs/client-env-config/index.d.ts +3 -0
- package/build/configs/client-env-config/index.js +9 -0
- package/build/configs/config-extras/minimizers/imagemin/imagemin.d.ts +28 -0
- package/build/configs/config-extras/minimizers/imagemin/imagemin.js +65 -0
- package/build/configs/config-extras/minimizers/imagemin/index.d.ts +1 -0
- package/build/configs/config-extras/minimizers/imagemin/index.js +17 -0
- package/build/configs/config-extras/minimizers/index.d.ts +1 -0
- package/build/configs/config-extras/minimizers/index.js +17 -0
- package/build/configs/dev-server.d.ts +2 -0
- package/build/configs/dev-server.js +78 -0
- package/build/configs/jest/babel-transform.d.ts +2 -0
- package/build/configs/jest/babel-transform.js +6 -0
- package/build/configs/jest/css-mock.d.ts +1 -0
- package/build/configs/jest/css-mock.js +2 -0
- package/build/configs/jest/file-transform.d.ts +3 -0
- package/build/configs/jest/file-transform.js +11 -0
- package/build/configs/jest/settings.d.ts +21 -0
- package/build/configs/jest/settings.js +58 -0
- package/build/configs/modules.d.ts +17 -0
- package/build/configs/modules.js +181 -0
- package/build/configs/mq.css +22 -0
- package/build/configs/postcss.config.d.ts +35 -0
- package/build/configs/postcss.config.js +65 -0
- package/build/configs/postcss.d.ts +6 -0
- package/build/configs/postcss.js +21 -0
- package/build/configs/process-assets-plugin-output.d.ts +2 -0
- package/build/configs/process-assets-plugin-output.js +45 -0
- package/build/configs/server-externals-exemptions.d.ts +1 -0
- package/build/configs/server-externals-exemptions.js +18 -0
- package/build/configs/stats-options.d.ts +2 -0
- package/build/configs/stats-options.js +46 -0
- package/build/configs/supporting-browsers.d.ts +1 -0
- package/build/configs/supporting-browsers.js +5 -0
- package/build/configs/supporting-node.d.ts +1 -0
- package/build/configs/supporting-node.js +5 -0
- package/build/configs/swc.d.ts +4 -0
- package/build/configs/swc.js +30 -0
- package/build/configs/util/apply-overrides.d.ts +87 -0
- package/build/configs/util/apply-overrides.js +56 -0
- package/build/configs/util/check-node-version.d.ts +1 -0
- package/build/configs/util/check-node-version.js +7 -0
- package/build/configs/util/compress-with-dcb.d.ts +2 -0
- package/build/configs/util/compress-with-dcb.js +28 -0
- package/build/configs/util/compression-plugins-for-dictionaries.d.ts +2 -0
- package/build/configs/util/compression-plugins-for-dictionaries.js +78 -0
- package/build/configs/util/create-watch-ignore-regex.d.ts +1 -0
- package/build/configs/util/create-watch-ignore-regex.js +16 -0
- package/build/configs/util/dcb-compression-plugin.d.ts +21 -0
- package/build/configs/util/dcb-compression-plugin.js +130 -0
- package/build/configs/util/find-loader.d.ts +2 -0
- package/build/configs/util/find-loader.js +24 -0
- package/build/configs/util/find-plugin.d.ts +78 -0
- package/build/configs/util/find-plugin.js +21 -0
- package/build/configs/util/get-entry.d.ts +8 -0
- package/build/configs/util/get-entry.js +22 -0
- package/build/configs/util/get-polyfills.d.ts +2 -0
- package/build/configs/util/get-polyfills.js +13 -0
- package/build/configs/util/get-webpack-cache-dependencies.d.ts +1 -0
- package/build/configs/util/get-webpack-cache-dependencies.js +15 -0
- package/build/configs/util/install-sourcemap-support.d.ts +1 -0
- package/build/configs/util/install-sourcemap-support.js +10 -0
- package/build/configs/util/node-assets-ignore.d.ts +1 -0
- package/build/configs/util/node-assets-ignore.js +34 -0
- package/build/configs/util/noop.d.ts +1 -0
- package/build/configs/util/noop.js +2 -0
- package/build/configs/util/register-ts-node.d.ts +1 -0
- package/build/configs/util/register-ts-node.js +18 -0
- package/build/configs/util/resolve.d.ts +14 -0
- package/build/configs/util/resolve.js +29 -0
- package/build/configs/vitest/config.d.ts +2 -0
- package/build/configs/vitest/config.js +5 -0
- package/build/configs/vitest/settings.d.ts +30 -0
- package/build/configs/vitest/settings.js +77 -0
- package/build/configs/webpack.client.d.ts +10 -0
- package/build/configs/webpack.client.dev.d.ts +1 -0
- package/build/configs/webpack.client.dev.js +12 -0
- package/build/configs/webpack.client.js +508 -0
- package/build/configs/webpack.client.prod.d.ts +1 -0
- package/build/configs/webpack.client.prod.js +12 -0
- package/build/configs/webpack.server.d.ts +2 -0
- package/build/configs/webpack.server.dev.d.ts +1 -0
- package/build/configs/webpack.server.dev.js +8 -0
- package/build/configs/webpack.server.js +283 -0
- package/build/configs/webpack.server.prod.d.ts +1 -0
- package/build/configs/webpack.server.prod.js +8 -0
- package/build/index.d.ts +19 -0
- package/build/index.js +35 -0
- package/build/plugins/arui-runtime/arui-runtime-module.d.ts +7 -0
- package/build/plugins/arui-runtime/arui-runtime-module.js +20 -0
- package/build/plugins/arui-runtime/index.d.ts +11 -0
- package/build/plugins/arui-runtime/index.js +47 -0
- package/build/plugins/postcss-global-variables/postcss-global-variables.d.ts +6 -0
- package/build/plugins/postcss-global-variables/postcss-global-variables.js +38 -0
- package/build/plugins/postcss-global-variables/utils/utils.d.ts +7 -0
- package/build/plugins/postcss-global-variables/utils/utils.js +91 -0
- package/build/plugins/postcss-prefix-selector.d.ts +6 -0
- package/build/plugins/postcss-prefix-selector.js +65 -0
- package/build/plugins/reload-server-plugin.d.ts +10 -0
- package/build/plugins/reload-server-plugin.js +46 -0
- package/build/plugins/turn-off-split-remote-entry.d.ts +11 -0
- package/build/plugins/turn-off-split-remote-entry.js +71 -0
- package/build/plugins/watch-missing-node-modules-plugin.d.ts +6 -0
- package/build/plugins/watch-missing-node-modules-plugin.js +20 -0
- package/build/templates/html.template.d.ts +1 -0
- package/build/templates/html.template.js +22 -0
- package/docs/artifact.md +62 -0
- package/docs/caveats.md +41 -0
- package/docs/client-only.md +77 -0
- package/docs/commands.md +159 -0
- package/docs/compilers.md +18 -0
- package/docs/compression-dictionary.md +130 -0
- package/docs/examples.md +100 -0
- package/docs/modules.md +834 -0
- package/docs/overrides.md +175 -0
- package/docs/presets.md +65 -0
- package/docs/settings.md +336 -0
- package/jest-preset.js +5 -0
- package/package.json +215 -0
- package/stylelint.config.js +11 -0
- package/tsconfig-local.json +17 -0
- package/tsconfig-local.tsbuildinfo +1 -0
- package/tsconfig.eslint.json +5 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function checkNodeVersion(majorVersion: number): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkNodeVersion = checkNodeVersion;
|
|
4
|
+
function checkNodeVersion(majorVersion) {
|
|
5
|
+
const actualVersion = process.versions.node.split('.');
|
|
6
|
+
return parseInt(actualVersion[0], 10) >= majorVersion;
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.compressWithDcb = compressWithDcb;
|
|
16
|
+
const buffer_1 = require("buffer");
|
|
17
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
18
|
+
const brotli_dict_1 = require("brotli-dict");
|
|
19
|
+
function compressWithDcb(inputFile, dictionaryData) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const magicNumberHeader = buffer_1.Buffer.from([0xff, 0x44, 0x43, 0x42]);
|
|
22
|
+
const dictionaryHash = crypto_1.default.createHash('sha256').update(dictionaryData).digest();
|
|
23
|
+
const compressedData = yield (0, brotli_dict_1.compress)(inputFile, {
|
|
24
|
+
dictionary: dictionaryData,
|
|
25
|
+
});
|
|
26
|
+
return buffer_1.Buffer.concat([magicNumberHeader, dictionaryHash, buffer_1.Buffer.from(compressedData)]);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.compressionPluginsForDictionaries = compressionPluginsForDictionaries;
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const app_configs_1 = require("../app-configs");
|
|
19
|
+
const compress_with_dcb_1 = require("./compress-with-dcb");
|
|
20
|
+
const dcb_compression_plugin_1 = require("./dcb-compression-plugin");
|
|
21
|
+
function compressionPluginsForDictionaries() {
|
|
22
|
+
const predefinedPlugins = app_configs_1.configs.compressionPredefinedDictionaryPath.map((dictionaryPath) => {
|
|
23
|
+
const dictionaryName = path_1.default.parse(dictionaryPath).name;
|
|
24
|
+
const dictionaryContent = fs_1.default.readFileSync(dictionaryPath, null);
|
|
25
|
+
return new dcb_compression_plugin_1.CustomCompressionPlugin({
|
|
26
|
+
test: /\.js$|\.css$/,
|
|
27
|
+
filename: ({ filename }) => `${filename}.${dictionaryName}.dcb`,
|
|
28
|
+
algorithm: (input) => (0, compress_with_dcb_1.compressWithDcb)(input, dictionaryContent),
|
|
29
|
+
threshold: 10240,
|
|
30
|
+
minRatio: 0.8,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
const prevVersionPlugins = app_configs_1.configs.compressionPreviousVersionPath.map((dictionaryPath) => {
|
|
34
|
+
const dictionaries = fs_1.default.readdirSync(dictionaryPath);
|
|
35
|
+
const parsedDictionaries = dictionaries.reduce((map, current) => {
|
|
36
|
+
const parsed = parseFilename(current);
|
|
37
|
+
return Object.assign(Object.assign({}, map), { [`${parsed.stableName}.${parsed.ext}`]: parsed });
|
|
38
|
+
}, {});
|
|
39
|
+
return new dcb_compression_plugin_1.CustomCompressionPlugin({
|
|
40
|
+
test: /\.js$|\.css$/,
|
|
41
|
+
threshold: 10240,
|
|
42
|
+
minRatio: 0.8,
|
|
43
|
+
filename: (pathData) => {
|
|
44
|
+
const parsedFilename = parseFilename(pathData.filename || '');
|
|
45
|
+
const matchedDictionary = parsedDictionaries[`${parsedFilename.stableName}.${parsedFilename.ext}`];
|
|
46
|
+
if (!matchedDictionary) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
return `${parsedFilename.filename}.${matchedDictionary.hash}.dcb`;
|
|
50
|
+
},
|
|
51
|
+
algorithm: (input_1, _a) => __awaiter(this, [input_1, _a], void 0, function* (input, { filename }) {
|
|
52
|
+
const parsedFilename = parseFilename(filename);
|
|
53
|
+
const matchedDictionary = parsedDictionaries[`${parsedFilename.stableName}.${parsedFilename.ext}`];
|
|
54
|
+
if (!matchedDictionary) {
|
|
55
|
+
return input;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const dictionaryContent = fs_1.default.readFileSync(path_1.default.join(dictionaryPath, matchedDictionary.filename), null);
|
|
59
|
+
return yield (0, compress_with_dcb_1.compressWithDcb)(input, dictionaryContent);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
return input;
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
return [...predefinedPlugins, ...prevVersionPlugins];
|
|
68
|
+
}
|
|
69
|
+
function parseFilename(filename) {
|
|
70
|
+
const parsedName = path_1.default.parse(filename);
|
|
71
|
+
const [stableName, hash] = parsedName.name.split('.');
|
|
72
|
+
return {
|
|
73
|
+
stableName,
|
|
74
|
+
hash,
|
|
75
|
+
ext: parsedName.ext.substring(1),
|
|
76
|
+
filename,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createWatchIgnoreRegex(paths: string[]): RegExp;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWatchIgnoreRegex = createWatchIgnoreRegex;
|
|
4
|
+
function createWatchIgnoreRegex(paths) {
|
|
5
|
+
if (paths.length === 0) {
|
|
6
|
+
return /(?!)/; // никогда не будет матчится
|
|
7
|
+
}
|
|
8
|
+
const patterns = paths.map((p) => {
|
|
9
|
+
const escaped = escapeRegExp(p);
|
|
10
|
+
return `(^|[\\\\/])${escaped}([\\\\/]|$)`;
|
|
11
|
+
});
|
|
12
|
+
return new RegExp(patterns.join('|'));
|
|
13
|
+
}
|
|
14
|
+
function escapeRegExp(str) {
|
|
15
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Assets, type Compilation, type Compiler, type PathData } from '@rspack/core';
|
|
2
|
+
import { type Rules } from 'compression-webpack-plugin';
|
|
3
|
+
type DcbCompressionOptions = {
|
|
4
|
+
test?: Rules;
|
|
5
|
+
include?: Rules;
|
|
6
|
+
exclude?: Rules;
|
|
7
|
+
algorithm: (input: Buffer, options: {
|
|
8
|
+
filename: string;
|
|
9
|
+
}) => Promise<Buffer>;
|
|
10
|
+
filename: (pathdata: PathData) => string;
|
|
11
|
+
threshold: number;
|
|
12
|
+
minRatio: number;
|
|
13
|
+
};
|
|
14
|
+
export declare class CustomCompressionPlugin {
|
|
15
|
+
protected options: DcbCompressionOptions;
|
|
16
|
+
constructor(options: DcbCompressionOptions);
|
|
17
|
+
runCompressionAlgorithm(input: Buffer, filename: string): Promise<Buffer<ArrayBufferLike>>;
|
|
18
|
+
compress(compiler: Compiler, compilation: Compilation, assets: Assets): Promise<void>;
|
|
19
|
+
apply(compiler: Compiler): void;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CustomCompressionPlugin = void 0;
|
|
16
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
17
|
+
const serialize_javascript_1 = __importDefault(require("serialize-javascript"));
|
|
18
|
+
/*
|
|
19
|
+
Based on compression-webpack-plugin, https://github.com/webpack-contrib/compression-webpack-plugin/tree/master
|
|
20
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
21
|
+
Author Tobias Koppers @sokra
|
|
22
|
+
*/
|
|
23
|
+
class CustomCompressionPlugin {
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this.options = options;
|
|
26
|
+
}
|
|
27
|
+
runCompressionAlgorithm(input, filename) {
|
|
28
|
+
return this.options.algorithm(input, { filename });
|
|
29
|
+
}
|
|
30
|
+
compress(compiler, compilation, assets) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const cache = compilation.getCache('BrCompressionWebpackPlugin');
|
|
33
|
+
const assetsForCompression = (yield Promise.all(Object.keys(assets).map((name) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const asset = compilation.getAsset(name);
|
|
35
|
+
if (!asset || asset.info.compressed) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (!compiler.webpack.ModuleFilenameHelpers.matchObject.bind(undefined, this.options)(name)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const relatedName = `compression-function-${crypto_1.default
|
|
42
|
+
.createHash('md5')
|
|
43
|
+
.update((0, serialize_javascript_1.default)(this.options.filename))
|
|
44
|
+
.digest('hex')}`;
|
|
45
|
+
if (asset.info.related &&
|
|
46
|
+
asset.info.related[relatedName]) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const cacheItem = cache.getItemCache((0, serialize_javascript_1.default)({
|
|
50
|
+
name,
|
|
51
|
+
algorithm: this.options.algorithm,
|
|
52
|
+
}), cache.getLazyHashedEtag(asset.source));
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
const output = ((yield cacheItem.getPromise()) || {});
|
|
55
|
+
let buffer;
|
|
56
|
+
// No need original buffer for cached files
|
|
57
|
+
if (!output.source) {
|
|
58
|
+
if (typeof asset.source.buffer === 'function') {
|
|
59
|
+
buffer = asset.source.buffer();
|
|
60
|
+
}
|
|
61
|
+
// Compatibility with webpack plugins which don't use `webpack-sources`
|
|
62
|
+
// See https://github.com/webpack-contrib/compression-webpack-plugin/issues/236
|
|
63
|
+
else {
|
|
64
|
+
buffer = asset.source.source();
|
|
65
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
66
|
+
buffer = Buffer.from(buffer);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (buffer.length < this.options.threshold) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
name,
|
|
75
|
+
source: asset.source,
|
|
76
|
+
info: asset.info,
|
|
77
|
+
buffer,
|
|
78
|
+
output,
|
|
79
|
+
cacheItem,
|
|
80
|
+
relatedName,
|
|
81
|
+
};
|
|
82
|
+
})))).filter(Boolean);
|
|
83
|
+
const { RawSource } = compiler.webpack.sources;
|
|
84
|
+
const scheduledTasks = [];
|
|
85
|
+
for (const asset of assetsForCompression) {
|
|
86
|
+
scheduledTasks.push((() => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
if (!asset || !asset.buffer) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const { name, source, buffer, output, cacheItem, relatedName } = asset;
|
|
91
|
+
if (!output.source) {
|
|
92
|
+
if (!output.compressed) {
|
|
93
|
+
try {
|
|
94
|
+
output.compressed = yield this.runCompressionAlgorithm(buffer, name);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
compilation.errors.push(error);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (output.compressed.length / buffer.length > this.options.minRatio) {
|
|
102
|
+
yield cacheItem.storePromise({ compressed: output.compressed });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
output.source = new RawSource(output.compressed);
|
|
106
|
+
yield cacheItem.storePromise(output);
|
|
107
|
+
}
|
|
108
|
+
const newFilename = compilation.getPath(this.options.filename({ filename: name }));
|
|
109
|
+
const newInfo = { compressed: true };
|
|
110
|
+
compilation.updateAsset(name, source, {
|
|
111
|
+
related: { [relatedName]: newFilename },
|
|
112
|
+
});
|
|
113
|
+
compilation.emitAsset(newFilename, output.source, newInfo);
|
|
114
|
+
}))());
|
|
115
|
+
}
|
|
116
|
+
yield Promise.all(scheduledTasks);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
apply(compiler) {
|
|
120
|
+
const pluginName = this.constructor.name;
|
|
121
|
+
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
|
|
122
|
+
compilation.hooks.processAssets.tapPromise({
|
|
123
|
+
name: pluginName,
|
|
124
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,
|
|
125
|
+
// additionalAssets: true,
|
|
126
|
+
}, (assets) => this.compress(compiler, compilation, assets));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.CustomCompressionPlugin = CustomCompressionPlugin;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findLoader = findLoader;
|
|
4
|
+
function findLoader(config, testRule) {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
for (const rule of (_b = (_a = config.module) === null || _a === void 0 ? void 0 : _a.rules) !== null && _b !== void 0 ? _b : []) {
|
|
7
|
+
if (rule === '...' || !rule) {
|
|
8
|
+
// Webpack имеет странный тип для rules, который позволяет в него положить строку '...'. Успокаиваем TS
|
|
9
|
+
// eslint-disable-next-line no-continue
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (rule.test && rule.test.toString() === testRule) {
|
|
13
|
+
return rule;
|
|
14
|
+
}
|
|
15
|
+
if (rule.oneOf) {
|
|
16
|
+
for (const oneOfRule of rule.oneOf) {
|
|
17
|
+
if (oneOfRule && oneOfRule.test && ((_c = oneOfRule === null || oneOfRule === void 0 ? void 0 : oneOfRule.test) === null || _c === void 0 ? void 0 : _c.toString()) === testRule) {
|
|
18
|
+
return oneOfRule;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type Worker } from 'cluster';
|
|
2
|
+
import { type ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
|
|
3
|
+
import { type BannerPluginArgument, type Configuration, type CssExtractRspackPluginOptions, type DefinePlugin, type NormalModuleReplacementPlugin } from '@rspack/core';
|
|
4
|
+
import type AssetsPlugin from 'assets-webpack-plugin';
|
|
5
|
+
import type CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
|
|
6
|
+
import type CompressionPlugin from 'compression-webpack-plugin';
|
|
7
|
+
import type MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
8
|
+
import { type RunScriptWebpackPlugin } from 'run-script-webpack-plugin';
|
|
9
|
+
import { type TsCheckerRspackPluginOptions } from 'ts-checker-rspack-plugin/lib/plugin-options';
|
|
10
|
+
import { type WebpackDeduplicationPlugin } from 'webpack-deduplication-plugin';
|
|
11
|
+
import { type WebpackManifestPlugin } from 'webpack-manifest-plugin';
|
|
12
|
+
type PluginsListClient = {
|
|
13
|
+
AssetsWebpackPlugin: {
|
|
14
|
+
options: AssetsPlugin.Options;
|
|
15
|
+
};
|
|
16
|
+
DefinePlugin: {
|
|
17
|
+
definitions: ConstructorParameters<typeof DefinePlugin>[number];
|
|
18
|
+
};
|
|
19
|
+
CssExtractRspackPlugin: {
|
|
20
|
+
options: CssExtractRspackPluginOptions;
|
|
21
|
+
};
|
|
22
|
+
MiniCssExtractPlugin: {
|
|
23
|
+
options: MiniCssExtractPlugin.PluginOptions;
|
|
24
|
+
runtimeOptions: MiniCssExtractPlugin.RuntimeOptions;
|
|
25
|
+
};
|
|
26
|
+
ForkTsCheckerWebpackPlugin: {
|
|
27
|
+
options: TsCheckerRspackPluginOptions;
|
|
28
|
+
};
|
|
29
|
+
IgnorePlugin: {
|
|
30
|
+
options: {
|
|
31
|
+
contextRegExp?: RegExp;
|
|
32
|
+
resourceRegExp: RegExp;
|
|
33
|
+
} | {
|
|
34
|
+
checkResource: (resource: string, context: string) => boolean;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
WebpackDeduplicationPlugin: WebpackDeduplicationPlugin;
|
|
38
|
+
ReactRefreshPlugin: {
|
|
39
|
+
options: ReactRefreshPluginOptions;
|
|
40
|
+
};
|
|
41
|
+
CaseSensitivePathsPlugin: {
|
|
42
|
+
options: CaseSensitivePathsPlugin.Options;
|
|
43
|
+
logger: {
|
|
44
|
+
[K in keyof Console]: Console[K];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
WebpackManifestPlugin: {
|
|
48
|
+
options: ConstructorParameters<typeof WebpackManifestPlugin>[number];
|
|
49
|
+
};
|
|
50
|
+
CompressionPlugin: {
|
|
51
|
+
options: ConstructorParameters<typeof CompressionPlugin>[number];
|
|
52
|
+
};
|
|
53
|
+
NormalModuleReplacementPlugin: typeof NormalModuleReplacementPlugin;
|
|
54
|
+
};
|
|
55
|
+
type PluginsListServer = {
|
|
56
|
+
BannerPlugin: {
|
|
57
|
+
options: BannerPluginArgument;
|
|
58
|
+
};
|
|
59
|
+
RunScriptWebpackPlugin: {
|
|
60
|
+
options: ConstructorParameters<typeof RunScriptWebpackPlugin>[number];
|
|
61
|
+
};
|
|
62
|
+
ReloadServerPlugin: {
|
|
63
|
+
done: (...props: unknown[]) => unknown | null;
|
|
64
|
+
workers: Worker[];
|
|
65
|
+
};
|
|
66
|
+
CaseSensitivePathsPlugin: {
|
|
67
|
+
options: CaseSensitivePathsPlugin.Options;
|
|
68
|
+
logger: {
|
|
69
|
+
[K in keyof Console]: Console[K];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
WatchMissingNodeModulesPlugin: {
|
|
73
|
+
nodeModulesPath: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
type SelectedPluginsList<Type extends 'client' | 'server'> = Type extends 'client' ? PluginsListClient : PluginsListServer;
|
|
77
|
+
export declare function createFindPluginFunction<Type extends 'client' | 'server'>(): <PluginName extends keyof SelectedPluginsList<Type>>(config: Configuration, pluginName: PluginName) => SelectedPluginsList<Type>[PluginName][];
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFindPluginFunction = createFindPluginFunction;
|
|
4
|
+
function createFindPluginFunction() {
|
|
5
|
+
/**
|
|
6
|
+
* @param config конфигурация webpack
|
|
7
|
+
* @param pluginName имя плагина
|
|
8
|
+
* @returns плагин или плагины, которые подошли под условие из testRule
|
|
9
|
+
*/
|
|
10
|
+
return (config, pluginName) => {
|
|
11
|
+
if (!config.plugins || !pluginName)
|
|
12
|
+
return [];
|
|
13
|
+
const result = [];
|
|
14
|
+
for (const plugin of config.plugins) {
|
|
15
|
+
if ((plugin === null || plugin === void 0 ? void 0 : plugin.constructor.name) === pluginName) {
|
|
16
|
+
result.push(plugin);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type Entry = string | string[] | Record<string, string | string[]>;
|
|
2
|
+
/**
|
|
3
|
+
* @param {string|string[]|object} entryPoint Строка, массив строк или объект с энтрипоинтами
|
|
4
|
+
* @param {Function} getSingleEntry Функция, возвращающая конфигурацию для одного entryPoint
|
|
5
|
+
* @param args Дополнительные аргументы, которые будут переданы в getSingleEntry функцию
|
|
6
|
+
* @returns {*}
|
|
7
|
+
*/
|
|
8
|
+
export declare function getEntry<AdditionalArgs extends unknown[]>(entryPoint: Entry, getSingleEntry: (entry: string[], ...args: AdditionalArgs) => string[], ...args: AdditionalArgs): string[] | Record<string, string | string[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEntry = getEntry;
|
|
4
|
+
/**
|
|
5
|
+
* @param {string|string[]|object} entryPoint Строка, массив строк или объект с энтрипоинтами
|
|
6
|
+
* @param {Function} getSingleEntry Функция, возвращающая конфигурацию для одного entryPoint
|
|
7
|
+
* @param args Дополнительные аргументы, которые будут переданы в getSingleEntry функцию
|
|
8
|
+
* @returns {*}
|
|
9
|
+
*/
|
|
10
|
+
function getEntry(entryPoint, getSingleEntry, ...args) {
|
|
11
|
+
if (typeof entryPoint === 'string') {
|
|
12
|
+
return getSingleEntry([entryPoint], ...args);
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(entryPoint)) {
|
|
15
|
+
return getSingleEntry(entryPoint, ...args);
|
|
16
|
+
}
|
|
17
|
+
// client entry also can be an object, so we must add hot loader to each entry point
|
|
18
|
+
return Object.keys(entryPoint).reduce((result, entryPointName) => {
|
|
19
|
+
const entry = getEntry(entryPoint[entryPointName], getSingleEntry, ...args);
|
|
20
|
+
return Object.assign(Object.assign({}, result), { [entryPointName]: entry });
|
|
21
|
+
}, {});
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPolyfills = getPolyfills;
|
|
4
|
+
function getPolyfills(config) {
|
|
5
|
+
const polyfills = [];
|
|
6
|
+
if (config.clientPolyfillsEntry && Array.isArray(config.clientPolyfillsEntry)) {
|
|
7
|
+
polyfills.push(...config.clientPolyfillsEntry);
|
|
8
|
+
}
|
|
9
|
+
else if (config.clientPolyfillsEntry) {
|
|
10
|
+
polyfills.push(config.clientPolyfillsEntry);
|
|
11
|
+
}
|
|
12
|
+
return polyfills;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getWebpackCacheDependencies(): Record<string, string[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWebpackCacheDependencies = getWebpackCacheDependencies;
|
|
4
|
+
const app_configs_1 = require("../app-configs");
|
|
5
|
+
const read_config_file_1 = require("../app-configs/read-config-file");
|
|
6
|
+
const update_with_presets_1 = require("../app-configs/update-with-presets");
|
|
7
|
+
function getWebpackCacheDependencies() {
|
|
8
|
+
return {
|
|
9
|
+
overrides: app_configs_1.configs.overridesPath,
|
|
10
|
+
appConfigs: [
|
|
11
|
+
(0, read_config_file_1.getConfigFilePath)(app_configs_1.configs.cwd),
|
|
12
|
+
(0, update_with_presets_1.getPresetsConfigPath)(app_configs_1.configs, app_configs_1.configs.cwd),
|
|
13
|
+
].filter(Boolean),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable global-require */
|
|
3
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
5
|
+
try {
|
|
6
|
+
require('source-map-support').install();
|
|
7
|
+
}
|
|
8
|
+
catch (e) {
|
|
9
|
+
console.error('unable to install source map support. Please add `source-map-support` as a dependency.');
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// ignore attempts to require any types of assets
|
|
4
|
+
(() => {
|
|
5
|
+
// simply ignore css files, it wont cause any damage
|
|
6
|
+
const ignoreExtensions = ['.css'];
|
|
7
|
+
// warn about other requires, because it may lead to unexpected behaviour in production
|
|
8
|
+
const warnExtensions = [
|
|
9
|
+
'.gif',
|
|
10
|
+
'.jpeg',
|
|
11
|
+
'.jpg',
|
|
12
|
+
'.ico',
|
|
13
|
+
'.png',
|
|
14
|
+
'.xml',
|
|
15
|
+
'.svg',
|
|
16
|
+
'.mp4',
|
|
17
|
+
'.webm',
|
|
18
|
+
'.ogv',
|
|
19
|
+
'.aac',
|
|
20
|
+
'.mp3',
|
|
21
|
+
'.wav',
|
|
22
|
+
'.ogg',
|
|
23
|
+
];
|
|
24
|
+
const noop = () => { };
|
|
25
|
+
const warn = (_, path) => console.warn(`\u001B[0;31mWARNING!
|
|
26
|
+
Trying to require ${path} in node.js.
|
|
27
|
+
Non-js files is ignored when required in node_modules\u001B[0m`);
|
|
28
|
+
ignoreExtensions.forEach((e) => {
|
|
29
|
+
require.extensions[e] = noop;
|
|
30
|
+
});
|
|
31
|
+
warnExtensions.forEach((e) => {
|
|
32
|
+
require.extensions[e] = warn;
|
|
33
|
+
});
|
|
34
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
4
|
+
// Мы используем ts-node для работы c конфигами, описаными на ts
|
|
5
|
+
require('ts-node').register({
|
|
6
|
+
transpileOnly: true,
|
|
7
|
+
ignore: [],
|
|
8
|
+
compilerOptions: {
|
|
9
|
+
target: 'esnext',
|
|
10
|
+
module: 'esnext',
|
|
11
|
+
skipLibCheck: true,
|
|
12
|
+
allowJs: false,
|
|
13
|
+
allowSyntheticDefaultImports: true,
|
|
14
|
+
moduleResolution: 'bundler',
|
|
15
|
+
esModuleInterop: true,
|
|
16
|
+
},
|
|
17
|
+
skipProject: true,
|
|
18
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function tryResolve(...args: [id: string, options?: {
|
|
2
|
+
paths?: string[] | undefined;
|
|
3
|
+
}]): string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Возвращает полный путь до модуля из node_modules относительно базового пути.
|
|
6
|
+
* Может быть полезно для определения пути до модуля, когда в проекте установлено сразу несколько модулей.
|
|
7
|
+
* /project
|
|
8
|
+
* --/node_modules
|
|
9
|
+
* ----/module1 // через эту функцию мы получим этот модуль
|
|
10
|
+
* ----/arui-scripts
|
|
11
|
+
* ------/node_modules
|
|
12
|
+
* --------/module1 // через require.resolve мы получим этот модуль
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveNodeModuleRelativeTo(basePath: string, moduleName: string): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
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.tryResolve = tryResolve;
|
|
7
|
+
exports.resolveNodeModuleRelativeTo = resolveNodeModuleRelativeTo;
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function tryResolve(...args) {
|
|
10
|
+
try {
|
|
11
|
+
return require.resolve(...args);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Возвращает полный путь до модуля из node_modules относительно базового пути.
|
|
19
|
+
* Может быть полезно для определения пути до модуля, когда в проекте установлено сразу несколько модулей.
|
|
20
|
+
* /project
|
|
21
|
+
* --/node_modules
|
|
22
|
+
* ----/module1 // через эту функцию мы получим этот модуль
|
|
23
|
+
* ----/arui-scripts
|
|
24
|
+
* ------/node_modules
|
|
25
|
+
* --------/module1 // через require.resolve мы получим этот модуль
|
|
26
|
+
*/
|
|
27
|
+
function resolveNodeModuleRelativeTo(basePath, moduleName) {
|
|
28
|
+
return path_1.default.resolve(basePath, `node_modules/${moduleName}`);
|
|
29
|
+
}
|