Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Обновление зависимостей external-renderer #263

Closed
SlumberyDude opened this issue Aug 25, 2023 · 9 comments · Fixed by #275
Closed

Обновление зависимостей external-renderer #263

SlumberyDude opened this issue Aug 25, 2023 · 9 comments · Fixed by #275
Assignees

Comments

@SlumberyDude
Copy link
Contributor

SlumberyDude commented Aug 25, 2023

С чем связан запрос на фичу?

Обновление зависимостей в модуле external-renderer

Расскажите как вы это себе видите

Обновить и зафиксировать версии пакета @atls/nestjs-external-renderer до максимально возможных таким образом, чтобы ничего не ломалось, а именно проходили команды критерия готовности.

Исключения:

Зависимости typescript, typeorm обновлять не нужно.

Если ломаются тесты и это связанно с переходом NestJs с версии 8 на 10, и проблема не на поверхности (не фиксится заменой в тесте, например, метода .asyncListen на .listen), то пакеты, начинающиеся с @nestjs/... обновлять не выше мажорной 8.

Definition of done (критерий готовности)

Проходят без ошибок команды:

  • yarn install
  • yarn check
  • yarn test unit

Если в пакете есть скрипты build и prepack, то они тоже должны проходить без ошибок.

Приложите пример реализаций

https://classic.yarnpkg.com/lang/en/docs/cli/workspace/
yarn workspace <workspace> add <[email protected]> <keys>

Приложите материалы задачи

Можете посмотреть закрытые PR и issue по теме обновления зависимостей

@RimidalU
Copy link
Contributor

RimidalU commented Sep 12, 2023

Обновлены все зависимости за исключением:

  • get-port: предпологаю, что нужно обноить зависимости из корневого package.json. А потом нашел подтверждение и в прошлых обновлениях этого реппо Обновление grpc-playground #237 (comment)

-node-fetch (https://www.npmjs.com/package/node-fetch) При обновлении до 2.7.0 всё норм, а если 3.3.2 то test unit ругается и с этим я пока что завис(( .
Склоняюсь к мысли, что это не относящаяся к проекту проблемма, т.к. видел, что в другом issues эту зависимость обновили до максимальной.
Как исправить пока что не нашёл путь, если кто подскажет - буду благодарен.

yarn test unit (node:130696) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. (Use `node --trace-deprecation ...` to show where the warning was created) FAIL packages/external-renderer/src/renderer/express-external-renderer.view.test.ts ● Test suite failed to run
Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

/home/uladzimir/.yarn/berry/cache/node-fetch-npm-3.3.2-5267e015f2-9.zip/node_modules/node-fetch/src/index.js:9
import http from 'node:http';
^^^^^^

SyntaxError: Cannot use import statement outside a module

   6 | import { Response }                    from 'node-fetch'
   7 |
>  8 | import { ExpressExternalRendererView } from './express-external-renderer.view'
     |                                      ^
   9 |
  10 | const mockedFetch = jest.mocked(fetch, true)
  11 |

  at Runtime.createScriptFromCode (../../../../../.yarn/berry/cache/jest-runtime-npm-27.5.1-c106eea3ba-9.zip/node_modules/jest-runtime/build/index.js:1728:14)
  at Object.<anonymous> (packages/external-renderer/src/renderer/express-external-renderer.view.test.ts:8:38)

PASS packages/typesense/src/decorators/field.decorator.test.ts
PASS packages/typesense/src/metadata/typesense.metadata-explorer.test.ts
PASS packages/kratos/src/interceptors/kratos-redirect.interceptor.test.ts
PASS packages/hydra/src/module/hydra.module.test.ts
PASS packages/kratos/src/filters/kratos-exception.filter.test.ts
PASS packages/kratos/src/module/kratos.module.test.ts
FAIL packages/external-renderer/src/module/external-renderer.module.test.ts
● Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

/home/uladzimir/.yarn/berry/cache/node-fetch-npm-3.3.2-5267e015f2-9.zip/node_modules/node-fetch/src/index.js:9
import http from 'node:http';
^^^^^^

SyntaxError: Cannot use import statement outside a module

   5 |   query?: object
   6 |   headers?: object
>  7 | }
     |  ^
   8 |
   9 | export class ExpressExternalRendererView {
  10 |   path: string

  at Runtime.createScriptFromCode (../../../../../.yarn/berry/cache/jest-runtime-npm-27.5.1-c106eea3ba-9.zip/node_modules/jest-runtime/build/index.js:1728:14)
  at Object.<anonymous> (packages/external-renderer/src/renderer/express-external-renderer.view.ts:7:38)

PASS packages/typesense/src/module/typesense.module.test.ts
PASS packages/signed-url/src/tests/generate-url.test.ts
PASS packages/typeorm-seeding/src/module/typeorm-seeding.module.test.ts

➤ YN0000: Done in 5s 905ms
Test Suites: 2 failed, 9 passed, 11 total
Tests: 27 passed, 27 total
Snapshots: 0 total
Time: 4.861 s
Ran all test suites.

@SlumberyDude
Copy link
Contributor Author

@RimidalU У меня была похожая ошибка в другом проекте, знаю что надо копать в репозиторий tools и смотреть как ярн делает тесты, но у меня до этого пока руки не дошли. А может у тебя и другой случай

@RimidalU
Copy link
Contributor

@TorinAsakura , остановиться на версии 2.7 или копать дальше? И, подскажи, плиз, в каком напралении?

@TorinAsakura
Copy link
Member

Подборка версий это нормально, как и решение проблем связанных с этим

@SlumberyDude
Copy link
Contributor Author

@RimidalU Можешь сделать пулл реквест со своей веткой. Он будет висеть пока вопрос не решится, а потом когда все согласуем и апрувнем то смержим.

@RimidalU RimidalU linked a pull request Sep 12, 2023 that will close this issue
@RimidalU
Copy link
Contributor

@TorinAsakura

1. get-port обновлён до 6.1.2 (latest 7.0.0) при использовании версии 7.0 возникает ошибка:

➤ YN0000: ┌ Typecheck
➤ YN0000: │ ../../../../../.yarn/berry/cache/get-port-npm-7.0.0-72b8a92f99-9.zip/node_modules/get-port/index.d.ts
➤ YN0000: │
➤ YN0000: │ Error: Module '"node:net"' has no exported member 'type'.
➤ YN0000: │
➤ YN0000: │
➤ YN0000: │ ../../../../../.yarn/berry/cache/get-port-npm-7.0.0-72b8a92f99-9.zip/node_modules/get-port/index.d.ts
➤ YN0000: │
➤ YN0000: │ Error: ',' expected.

возникает она потому что в либе сменили interface на type (sindresorhus/get-port@v6.1.2...v7.0.0)

![image](https://github.com/atls/nestjs/assets/81852394/6a1579a5-12b2-4d33-8715-d80d11ee8ab0)

а при проверке yarn check typecheck пробегается typescript: '^4.5.3', который не занет о type.

![image](https://github.com/atls/nestjs/assets/81852394/ec4abe94-d86c-414f-9990-b6e489bdad28)

Отсюда и вторая ошибка про зарятую - ему не понятно почему два значение не разделили запятой

Поэтому после поднятия версии ts можно будет поднять и эту.

2. node-fetch обновлён до 2.7.0 (latest 3.3.2) при использовании версии 3.3.2 возникает ошибка:

/home/uladzimir/.yarn/berry/cache/node-fetch-npm-3.3.2-5267e015f2-9.zip/node_modules/node-fetch/src/index.js:9 import http from 'node:http'; ^^^^^^
SyntaxError: Cannot use import statement outside a module

   5 | export class ExpressExternalRendererView {
   6 |   path: string
>  7 |
     | ^
   8 |   baseUrl: string
   9 |
  10 |   constructor(name, options) {

  at Runtime.createScriptFromCode (../../../../../.yarn/berry/cache/jest-runtime-npm-27.5.1-c106eea3ba-9.zip/node_modules/jest-runtime/build/index.js:1728:14)
  at Object.<anonymous> (packages/external-renderer/src/renderer/express-external-renderer.view.ts:7:38)

Варианты, которые я вижу поднять версию ноды (node-fetch/node-fetch#1588) (совет автора либы) или понизить на предыдущую версию, что я и сделал.

@TorinAsakura
Copy link
Member

TorinAsakura commented Sep 13, 2023

@RimidalU

  • используй packageExtension для решения проблем совместимости типов в зависимостях (пример можешь подсмотреть в .yarnrc.yml)
  • версия ноды у нас 18, ниже опускать не рекомендую, не будут работать ярн утилиты
  • фиксируй версии, включая версию ТС, нужно подобрать подходящую

@RimidalU
Copy link
Contributor

@TorinAsakura

1. get-port обновлён до 6.1.2 (latest 7.0.0) при использовании версии 7.0 возникает ошибка: решено

  1. node-fetch обновлён до 2.7.0 (latest 3.3.2) при использовании версии 3.3.2 возникает ошибка:
FAIL packages/external-renderer/src/module/external-renderer.module.test.ts ● Test suite failed to run
Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation

Details:

/home/uladzimir/.yarn/berry/cache/node-fetch-npm-3.3.2-5267e015f2-9.zip/node_modules/node-fetch/src/index.js:9
import http from 'node:http';
^^^^^^

SyntaxError: Cannot use import statement outside a module

   5 |   query?: object
   6 |   headers?: object
>  7 | }
     |  ^
   8 |
   9 | export class ExpressExternalRendererView {
  10 |   path: string

  at Runtime.createScriptFromCode (../../../../../.yarn/berry/cache/jest-runtime-npm-27.5.1-c106eea3ba-9.zip/node_modules/jest-runtime/build/index.js:1728:14)
  at Object.<anonymous> (packages/external-renderer/src/renderer/express-external-renderer.view.ts:7:38)

Варианты, которые я вижу: использовать нативный нодовский fetch (node-fetch/node-fetch#1588) (совет автора либы) или понизить на предыдущую версию, что я и сделал.

@TorinAsakura
Copy link
Member

Приемлемо

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

Successfully merging a pull request may close this issue.

3 participants