Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Conversation

OldSkyTree
Copy link
Contributor

@OldSkyTree OldSkyTree commented Feb 12, 2022

Что сделано

Переписал пакет на typescript. Из нюансов:

  • положил в пакет два tsconfig.json. Первый в корень, второй – в lib/browser/client-scripts. Это нужно, так как клиентские скрипты нужно собирать для ES3.
  • не стал переписывать на TS lib/browser/client-scripts/polyfills.
  • код написан с учетом того, что пакеты configparser, png-img, glob-extra также переписаны на TS. А также с учетом исправлений в пакете looks-same. (по ссылкам располагаются соответствующие пулл-реквесты)
  • поменял порядок аргументов у метода transform пакета browserify (ссылка на текущий код, ссылка на новый). Пакет поддерживает оба варианта передачи аргументов, но тайпинги из пакета @types/browserify позволяют использовать лишь один вариант. Предпочел сменить порядок аргументов, чем делать пулл-реквест в тайпинги.
  • тесты не переписывал на jest.
  • линтер для TS не завозил.

@OldSkyTree
Copy link
Contributor Author

Запушил вариант с переименование файлов, теперь если смотреть ПР по коммитам, то можно смотреть на изменения, а не проверять файл целиком.

@OldSkyTree
Copy link
Contributor Author

Запушил для запуска проверок

"proxyquire": "^1.7.3",
"sinon": "^2.2.0"
"sinon": "^2.2.0",
"typescript": "^4.5.5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to pin exact versions (even in devDeps).

"prepare-calibrate-script": "uglifyjs ./lib/browser/client-scripts/calibrate.js -m > ./lib/browser/client-scripts/calibrate.min.js --support-ie8",
"build": "tsc -p tsconfig.json",
"postbuild": "npm run prepare-calibrate-script",
"prepare-calibrate-script": "uglifyjs ./build/lib/browser/client-scripts/calibrate.js -m > ./build/lib/browser/client-scripts/calibrate.min.js --support-ie8",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of prepare-calibrate-script and place it's script to postbuild?

"test-unit": "mocha test",
"test": "npm run lint && npm run test-unit",
"pretest": "npm run build",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we must always build project before run tests?

"test-unit": "mocha test",
"test": "npm run lint && npm run test-unit",
"pretest": "npm run build",
"test": "run-s lint test-unit",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: add command for run unit tests only.

Comment on lines +4 to +5
import options from "./lib/config/options";
export const config = { options };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такая махинация нужна, чтобы сохранить API, но понял, что можно сделать лучше так:

  • добавить файл ./lib/config/index.ts с содержимым export * as options from "./options";
  • здесь оставить лишь export * as config from "./lib/config";

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants