@infomaximum/package-cli 2.20.1 → 2.21.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [2.21.0](https://github.com/Infomaximum/package-cli/compare/v2.20.1...v2.21.0) (2025-03-17)
6
+
7
+
8
+ ### Features
9
+
10
+ * добавлен флаг для активации трансформаций ([9518e19](https://github.com/Infomaximum/package-cli/commit/9518e19c36c566497b613fe24a5f3eab310fc31b))
11
+ * преобразование кода интеграции ([539c42d](https://github.com/Infomaximum/package-cli/commit/539c42dbd935d8c746d123c502553fb5d25de611))
12
+
5
13
  ### [2.20.1](https://github.com/Infomaximum/package-cli/compare/v2.20.0...v2.20.1) (2025-03-09)
6
14
 
7
15
 
@@ -8,6 +8,7 @@ export type InputBuildIntegrationOptions = {
8
8
  copy: boolean;
9
9
  fetchToServer: boolean;
10
10
  beautify: boolean;
11
+ experimentalTransform: boolean;
11
12
  } & InputPackageOptions;
12
13
  export type BuildType = "package" | "script";
13
14
  export declare const registerIntegrationBuildCommand: (integrationCommand: Command) => void;
@@ -15,6 +15,7 @@ export const registerIntegrationBuildCommand = (integrationCommand) => {
15
15
  .option("--copy", "копирование скрипта интеграции в буфер обмена", false)
16
16
  .option("--fetchToServer", `отправка изменений на сервер (должен быть настроен файл ${INTEGRATION_CONFIG_RC_FILE_NAME}${INTEGRATION_CONFIG_RC_EXT})`, false)
17
17
  .option("--beautify", `отформатировать код после сборки`, false)
18
+ .option("--experimental-transform", `эксперементальная функция по переносу общего кода в функции executePagination'`, false)
18
19
  .action((options) => {
19
20
  if (options.fetchToServer && typeof (config === null || config === void 0 ? void 0 : config.fetcher) !== "function") {
20
21
  throw new Error("Не настроен конфиг или нет функции fetcher в конфиге");
@@ -0,0 +1,4 @@
1
+ import { type Compiler } from "webpack";
2
+ export declare class ASTIntegrationPreamblePlugin {
3
+ apply(compiler: Compiler): void;
4
+ }
@@ -0,0 +1,38 @@
1
+ import { systemRequire } from "../../../utils.js";
2
+ import { transformSync } from "@babel/core";
3
+ import webpack, {} from "webpack";
4
+ const { Compilation } = webpack;
5
+ export class ASTIntegrationPreamblePlugin {
6
+ apply(compiler) {
7
+ compiler.hooks.compilation.tap("ASTIntegrationPreamblePlugin", (compilation) => {
8
+ compilation.hooks.processAssets.tap({
9
+ name: "ASTIntegrationPreamblePlugin",
10
+ stage: Compilation.PROCESS_ASSETS_STAGE_REPORT,
11
+ }, (assets) => {
12
+ Object.entries(assets).forEach(([filename, source]) => {
13
+ var _a, _b;
14
+ if (!filename.endsWith(".js"))
15
+ return;
16
+ const { RawSource } = compiler.webpack.sources;
17
+ const output = (_b = (_a = transformSync(source.source().toString(), {
18
+ sourceType: "unambiguous",
19
+ babelrc: false,
20
+ configFile: false,
21
+ plugins: [
22
+ [
23
+ systemRequire.resolve("@saneksa/babel-plugin-function-transform"),
24
+ {
25
+ functionName: "executePagination",
26
+ fieldName: "integration",
27
+ },
28
+ ],
29
+ ],
30
+ })) === null || _a === void 0 ? void 0 : _a.code) === null || _b === void 0 ? void 0 : _b.trim();
31
+ if (output) {
32
+ compilation.updateAsset(filename, new RawSource(output));
33
+ }
34
+ });
35
+ });
36
+ });
37
+ }
38
+ }
@@ -1,6 +1,7 @@
1
1
  import TerserPlugin from "terser-webpack-plugin";
2
2
  import { systemRequire } from "../../../utils.js";
3
3
  import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
4
+ import { ASTIntegrationPreamblePlugin } from "./ASTIntegrationPreamblePlugin.js";
4
5
  export const getCommonIntegrationConfig = ({ PATHS, mode, isBeautifyCode, }) => {
5
6
  return {
6
7
  mode,
@@ -1,3 +1,4 @@
1
1
  export declare const INTEGRATION_SDK_LIB_NAME = "@infomaximum/integration-sdk";
2
2
  export declare const INTEGRATION_CONFIG_RC_FILE_NAME = "integrationrc";
3
3
  export declare const INTEGRATION_CONFIG_RC_EXT = ".js";
4
+ export declare const INTEGRATION_OUTPUT_FILE = "integration.js";
@@ -1,3 +1,4 @@
1
1
  export const INTEGRATION_SDK_LIB_NAME = "@infomaximum/integration-sdk";
2
2
  export const INTEGRATION_CONFIG_RC_FILE_NAME = `integrationrc`;
3
3
  export const INTEGRATION_CONFIG_RC_EXT = `.js`;
4
+ export const INTEGRATION_OUTPUT_FILE = `integration.js`;
@@ -1,12 +1,13 @@
1
1
  import { generatePackagePaths } from "../package/packagePaths.js";
2
2
  import { generateIndexPath } from "../paths.js";
3
+ import { INTEGRATION_OUTPUT_FILE } from "./const.js";
3
4
  export function generateIntegrationPaths({ entry, buildDir, packageDir, packageManifest, }) {
4
5
  const packagePaths = generatePackagePaths({
5
6
  buildDir,
6
7
  packageDir,
7
8
  packageManifest,
8
9
  });
9
- return Object.assign(Object.assign({}, packagePaths), { outputFile: "integration.js", get moduleIndex() {
10
+ return Object.assign(Object.assign({}, packagePaths), { outputFile: INTEGRATION_OUTPUT_FILE, get moduleIndex() {
10
11
  return generateIndexPath(entry);
11
12
  } });
12
13
  }
@@ -9,8 +9,9 @@ import path from "path";
9
9
  import { merge } from "webpack-merge";
10
10
  import { CopyToClipboardPlugin } from "../configs/webpack/CopyToClipboardPlugin.js";
11
11
  import { FetchCodeToServerPlugin } from "../configs/webpack/FetchCodeToServerPlugin.js";
12
+ import { ASTIntegrationPreamblePlugin } from "../configs/webpack/ASTIntegrationPreamblePlugin.js";
12
13
  export const runBuildIntegration = (options, rcConfig) => __awaiter(void 0, void 0, void 0, function* () {
13
- const { entry, buildDir, packageDir, packageManifest, type, watch, copy, beautify: isBeautifyCode, } = options;
14
+ const { entry, buildDir, packageDir, packageManifest, type, watch, copy, beautify: isBeautifyCode, experimentalTransform, } = options;
14
15
  const INTEGRATION_PATHS = generateIntegrationPaths({
15
16
  entry,
16
17
  buildDir,
@@ -32,6 +33,7 @@ export const runBuildIntegration = (options, rcConfig) => __awaiter(void 0, void
32
33
  {
33
34
  plugins: [
34
35
  copy && new CopyToClipboardPlugin(),
36
+ experimentalTransform && new ASTIntegrationPreamblePlugin(),
35
37
  options.fetchToServer &&
36
38
  typeof fetcherFromConfig === "function" &&
37
39
  new FetchCodeToServerPlugin({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/package-cli",
3
- "version": "2.20.1",
3
+ "version": "2.21.0",
4
4
  "exports": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -28,6 +28,7 @@
28
28
  "@infomaximum/assert": "^1.1.3",
29
29
  "@infomaximum/json-modify-webpack-plugin": "^1.1.0",
30
30
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
31
+ "@saneksa/babel-plugin-function-transform": "^1.0.0",
31
32
  "@svgr/webpack": "^8.1.0",
32
33
  "autoprefixer": "^10.4.16",
33
34
  "babel-loader": "^9.1.3",
@@ -69,6 +70,7 @@
69
70
  "zip-webpack-plugin": "^4.0.1"
70
71
  },
71
72
  "devDependencies": {
73
+ "@types/babel__core": "^7.20.5",
72
74
  "@types/fs-extra": "^11.0.4",
73
75
  "@types/node": "^20.9.0",
74
76
  "@types/semver": "^7.5.6",