apache / helix

Mirror of Apache Helix
Apache License 2.0
462 stars 224 forks source link

helix-front: js dependencies referenced via git hash install failure in private registry #2150

Closed micahstubbs closed 2 years ago

micahstubbs commented 2 years ago

Describe the bug

In helix-front the current "tsickle": "github:angular/tsickle#8f11720637b7bb1c7b0e271e16bebbcdc8189617" js dependency referenced via git hash causes an install failure in a JFrog Artifactory private package registry.

To Reproduce

Steps to reproduce the behavior.

# use an .npmrc configured to point to a private registry
cd helix
./build

Expected behavior

A clear and concise description of what you expected to happen.

yarn install succeeds even when configured to install from a private JS package registry

Additional context

Add any other context about the problem here.

micahstubbs commented 2 years ago

tickle@0.46.1 should work since it has as a peer dep: "typescript": "~4.6.3", which is to say "4.6.3 or any higher patch version"

https://github.com/angular/tsickle/blame/d841bc0f3de2f7fe94023642d627200adf4b635b/package.json#L3

micahstubbs commented 2 years ago

Uh-oh. The lastest version published to npm is tsickle@0.46.1. Odd.

https://www.npmjs.com/package/tsickle

micahstubbs commented 2 years ago

Maybe we can remove this dependency altogether?

Your Angular project should not depend on tsickle unless you've explicitly chosen to use tsickle (and most people shouldn't). If it does, there's some incorrect setup in your dependencies.

https://github.com/angular/tsickle/issues/1322#issuecomment-1021230189

micahstubbs commented 2 years ago

Let's test removing tsickle as a direct dependency:

micahstubbs commented 2 years ago
yarn build
yarn run v1.22.18
$ rm -rf dist && mkdir dist && ng build --aot --configuration production && tsc -p server
(node:53703) UnhandledPromiseRejectionWarning: Error: Cannot find module 'ajv-formats'
Require stack:
- /helix/apache-helix/helix/helix-front/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/schema/registry.js
- /helix/apache-helix/helix/helix-front/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/schema/index.js
- /helix/apache-helix/helix/helix-front/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/index.js
- /helix/apache-helix/helix/helix-front/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/experimental/jobs/simple-registry.js
- /helix/apache-helix/helix/helix-front/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/experimental/jobs/index.js
- /helix/apache-helix/helix/helix-front/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/experimental.js
- /helix/apache-helix/helix/helix-front/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/index.js
- /helix/apache-helix/helix/helix-front/node_modules/@angular/cli/utilities/config.js
- /helix/apache-helix/helix/helix-front/node_modules/@angular/cli/lib/init.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/helix/apache-helix/helix/helix-front/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/schema/registry.js:38:39)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:53703) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:53703) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨  Done in 2.72s.
micahstubbs commented 2 years ago

https://www.npmjs.com/package/ajv-formats

JSON Schema formats for Ajv

What is Ajv?

https://www.npmjs.com/package/ajv

Ajv JSON schema validator The fastest JSON validator for Node.js and browser.

Supports JSON Schema draft-04/06/07/2019-09/2020-12 (draft-04 support requires ajv-draft-04 package) and JSON Type Definition RFC8927.

micahstubbs commented 2 years ago

Let's try:

yarn add ajv-formats

It seems like it is already installed:

yarn add -D ajv-formats
yarn add v1.22.18
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
warning Pattern ["ajv-formats@^2.1.1"] is trying to unpack in the same destination "/Library/Caches/Yarn/v6/npm-ajv-formats-2.1.1-6e669400659eb74973bbf2e33327180a0996b520-integrity/node_modules/ajv-formats" as pattern ["ajv-formats@2.1.1","ajv-formats@^2.1.1","ajv-formats@2.1.1"]. This could result in non-deterministic behavior, skipping.
[4/5] 🔗  Linking dependencies...
warning " > ngx-vis@3.1.0" has incorrect peer dependency "keycharm@^0.2.0".
warning " > @angular/compiler-cli@13.3.9" has incorrect peer dependency "@angular/compiler@13.3.9".
[5/5] 🔨  Building fresh packages...
success Saved 0 new dependencies.
✨  Done in 4.04s.

Odd. Let's try building again.

micahstubbs commented 2 years ago
yarn build
yarn run v1.22.18
$ rm -rf dist && mkdir dist && ng build --aot --configuration production && tsc -p server
An unhandled exception occurred: Cannot read property 'code' of undefined
See "/private/var/folders/68/yy6n0fn14l30k9tz8pkjdwvc00115x/T/ng-TwCvQA/angular-errors.log" for further details.
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

which says:

[error] TypeError: Cannot read property 'code' of undefined
    at addFormats (/helix/apache-helix/helix/helix-front/node_modules/ajv-formats/dist/index.js:30:26)
    at formatsPlugin (/helix/apache-helix/helix/helix-front/node_modules/ajv-formats/dist/index.js:15:5)
    at new CoreSchemaRegistry (/helix/apache-helix/helix/helix-front/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/schema/registry.js:96:35)
    at runCommand (/helix/apache-helix/helix/helix-front/node_modules/@angular/cli/models/command-runner.js:118:22)
    at default_1 (/helix/apache-helix/helix/helix-front/node_modules/@angular/cli/lib/cli/index.js:70:69)
micahstubbs commented 2 years ago

a possible solution:

https://github.com/ajv-validator/ajv-formats/issues/12#issuecomment-779965228

yarn add ajv@7.1.0

first, let's see what ajv we have currently:

 npm ls ajv
helix-front@1.2.1 /Users/mstubbs/workspace/helix/apache-helix/helix/helix-front
├─┬ @angular-devkit/build-angular@13.3.7
│ ├─┬ @angular-devkit/architect@0.1303.7
│ │ └─┬ @angular-devkit/core@13.3.7
│ │   └── ajv@8.9.0
│ ├─┬ @angular-devkit/core@13.3.7
│ │ └── ajv@8.9.0
│ ├─┬ babel-loader@8.2.5
│ │ └─┬ schema-utils@2.7.1
│ │   └── ajv@6.12.6  deduped
│ ├─┬ copy-webpack-plugin@10.2.1
│ │ └─┬ schema-utils@4.0.0
│ │   └── ajv@8.11.0
│ └─┬ webpack@5.70.0
│   ├─┬ schema-utils@3.1.1
│   │ └── ajv@6.12.6  deduped
│   └─┬ terser-webpack-plugin@5.3.3
│     └─┬ schema-utils@3.1.1
│       └── ajv@6.12.6  deduped
├─┬ @angular/cli@13.3.6
│ ├─┬ @angular-devkit/core@13.3.6
│ │ └── UNMET DEPENDENCY ajv@8.9.0
│ └─┬ @schematics/angular@13.3.6
│   └─┬ @angular-devkit/core@13.3.6
│     └── ajv@8.9.0
├── ajv@6.12.6
├─┬ ajv-formats@2.1.1
│ └── ajv@8.11.0
├─┬ eslint@8.17.0
│ ├─┬ @eslint/eslintrc@1.3.0
│ │ └── ajv@6.12.6  deduped
│ └── ajv@6.12.6  deduped
└─┬ request@2.88.2
  └─┬ har-validator@5.1.5
    └── ajv@6.12.6
micahstubbs commented 2 years ago

Hooray, this fixes the build 🎉

yarn build
yarn run v1.22.18
$ rm -rf dist && mkdir dist && ng build --aot --configuration production && tsc -p server
⠙ Generating browser application bundles (phase: setup)...Processing legacy "View Engine" libraries:
- ngx-window-token [es2015/esm2015] (https://github.com/maxisam/ngx-window-token)
- ngx-vis [es2015/esm2015] (git+https://github.com/visjs/ngx-vis.git)
- @swimlane/ngx-datatable [es2015/esm2015] (git+https://github.com/swimlane/ngx-datatable.git)
- ngx-json-viewer [es2015/esm2015] (git+https://github.com/hivivo/ngx-json-viewer.git)
- ngx-clipboard [es2015/esm2015] (https://github.com/maxisam/ngx-clipboard)
- @swimlane/ngx-charts [es2015/esm2015] (git+https://github.com/swimlane/ngx-charts.git)
Encourage the library authors to publish an Ivy distribution.
✔ Browser application bundle generation complete.
✔ Copying assets complete.
✔ Index html generation complete.

Initial Chunk Files           | Names         |  Raw Size | Estimated Transfer Size
main.5842a830071c3192.js      | main          |   3.10 MB |               557.65 kB
styles.cb978aee76fa1bd8.css   | styles        | 303.52 kB |                36.67 kB
polyfills.ff4780c306116b22.js | polyfills     |  73.55 kB |                23.23 kB
runtime.93d35a893ab74671.js   | runtime       |   1.30 kB |               694 bytes

                              | Initial Total |   3.47 MB |               618.24 kB

Build at: 2022-06-15T04:45:06.444Z - Hash: 0cf901e62f73928b - Time: 50606ms

Warning: /helix/apache-helix/helix/helix-front/node_modules/@swimlane/ngx-graph/fesm2015/swimlane-ngx-graph.mjs depends on 'dagre'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /helix/apache-helix/helix/helix-front/node_modules/@swimlane/ngx-graph/fesm2015/swimlane-ngx-graph.mjs depends on 'webcola'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /helix/apache-helix/helix/helix-front/node_modules/ngx-vis/__ivy_ngcc__/fesm2015/ngxvis.js depends on 'vis-network'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /helix/apache-helix/helix/helix-front/node_modules/ngx-vis/__ivy_ngcc__/fesm2015/ngxvis.js depends on 'vis-timeline'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: bundle initial exceeded maximum budget. Budget 3.44 MB was not met by 26.10 kB with a total of 3.47 MB.

✨  Done in 55.62s.
micahstubbs commented 2 years ago

Let's increase the maxWarning for the build budget while we are here to 3.47MB which is 3554kb.

yarn build
yarn run v1.22.18
$ rm -rf dist && mkdir dist && ng build --aot --configuration production && tsc -p server
✔ Browser application bundle generation complete.
✔ Copying assets complete.
✔ Index html generation complete.

Initial Chunk Files           | Names         |  Raw Size | Estimated Transfer Size
main.5842a830071c3192.js      | main          |   3.10 MB |               557.65 kB
styles.cb978aee76fa1bd8.css   | styles        | 303.52 kB |                36.67 kB
polyfills.ff4780c306116b22.js | polyfills     |  73.55 kB |                23.23 kB
runtime.93d35a893ab74671.js   | runtime       |   1.30 kB |               694 bytes

                              | Initial Total |   3.47 MB |               618.24 kB

Build at: 2022-06-15T04:48:23.461Z - Hash: 0cf901e62f73928b - Time: 45420ms

Warning: /helix/apache-helix/helix/helix-front/node_modules/@swimlane/ngx-graph/fesm2015/swimlane-ngx-graph.mjs depends on 'dagre'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /helix/apache-helix/helix/helix-front/node_modules/@swimlane/ngx-graph/fesm2015/swimlane-ngx-graph.mjs depends on 'webcola'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /helix/apache-helix/helix/helix-front/node_modules/ngx-vis/__ivy_ngcc__/fesm2015/ngxvis.js depends on 'vis-network'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /helix/apache-helix/helix/helix-front/node_modules/ngx-vis/__ivy_ngcc__/fesm2015/ngxvis.js depends on 'vis-timeline'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

✨  Done in 50.44s.
micahstubbs commented 2 years ago

Let's test removing tsickle as a direct dependency:

yarn start works as expected, and recognizes our proxy config in proxy.conf.json. The Helix UI renders with 0 errors in the browser console.

Screen Shot 2022-06-14 at 9 50 52 PM

yarn test results

Screen Shot 2022-06-14 at 9 53 17 PM