cli icon indicating copy to clipboard operation
cli copied to clipboard

Ошибка Error: Unexpected character '#', если есть приватные методы

Open artemyaz opened this issue 11 months ago • 0 comments

Пытаюсь транслировать код из стандартного Активити:

Версия node -v v20.18.2

bitrix -v @bitrix/cli 3.3.6

import { Tag, Text } from 'main.core';

const ParallelActivity = window.ParallelActivity;

export class ApproveActivity extends ParallelActivity
{
	constructor()
	{
		// eslint-disable-next-line
		super();
		this.Type = 'ApproveActivity';
		// eslint-disable-next-line @bitrix24/bitrix24-rules/no-pseudo-private,no-underscore-dangle
		this.__parallelActivityInitType = 'SequenceActivity';

		// compatibility
		this.DrawParallelActivity = this.Draw;
		this.Draw = this.#draw;
	}

	#draw(wrapper)
	{
		this.activityContent = Tag.render`
			<table style="font-size: 11px; width: 100%" cellpadding="0" cellspacing="0" border="0">
				<tbody>
					<tr>
						<td align="left" valign="center" width="33">
							&nbsp;<span style="color: #007700">${Text.encode(window.BPMESS.APPR_YES)}</span>
						</td>
						<td 
							align="center"
							valign="center"
							style="background: url(${this.Icon}) 2px 2px no-repeat; height: 24px; width: 24px"
						></td>
						<td align="left" valign="center">${Text.encode(this.Properties.Title)}</td>
						<td align="right" valign="center">
							<span style="color: #770000">${Text.encode(window.BPMESS.APPR_NO)}</span>&nbsp;
						</td>
					</tr>
				</tbody>
			</table>
		`;
		this.activityHeight = '30px';
		this.activityWidth = '200px';

		this.DrawParallelActivity(wrapper);
	}
}

В коде есть метод super() и приватный метод #draw. Транслирую для crome => 112, на выходе должен быть файл почти такой же как исходный, потому что все конструкции chrome 112 знает.

Однако bitrix build выдаёт ошибку если в коде встречается приватный метод # Error: Unexpected character '#'

Приходится руками удалять #, делать bitrix build, и возвращать #

Плагин для приватных методов я отключил, потому что для новых браузеров он мне не нужен, слишком захламляет код "/usr/lib/node_modules/@bitrix/cli/node_modules/@babel/plugin-proposal-private-methods"

bundle.config.js

module.exports = {
	input: './src/index.js',
	output: {
		js: './approveactivity.js',
	},
	adjustConfigPhp: false,
	browserslist: true,
	sourceMaps: false,
	plugins: {
		babel: {
			"presets": [
				[
					"/usr/lib/node_modules/@bitrix/cli/node_modules/@babel/preset-env",
					//	"/root/.nvm/versions/node/v8.17.0/lib/node_modules/@bitrix/cli/node_modules/@babel/preset-env",
					{
						"targets": {
							"chrome": "112",
						}
					}
				]
			],
			"plugins": [
				// "@babel/plugin-transform-flow-strip-types",
				// "@babel/plugin-proposal-class-properties",
				// "/usr/lib/node_modules/@bitrix/cli/node_modules/@babel/plugin-proposal-private-methods",
				// "@babel/plugin-transform-runtime",
				// "babel-plugin-rewire"
			],
		}
	},
};

artemyaz avatar Feb 01 '25 22:02 artemyaz