teambit / bit-angular

Angular support for bit harmony
28 stars 3 forks source link

Cannot read properties of undefined (reading 'aspectPath') when extending angular12 env #49

Closed AntGrisha closed 1 year ago

AntGrisha commented 1 year ago

Hello, I am trying to extend angularV12 env and create my own custom environment. The following code works fine with bit v0.0.748 when running bit start

import * as path from 'path';
import { EnvsMain, EnvsAspect } from '@teambit/envs'
import { AngularV12Aspect, AngularV12Main } from '@teambit/angular-v12'
export class WebEnvExtension {

  static dependencies: any = [EnvsAspect, AngularV12Aspect]

  static async provider([envs, angular]: [EnvsMain, AngularV12Main]) {

    const compilerOptions = angular.overrideCompilerOptions({
      fullTemplateTypeCheck: false,
      strictPropertyInitialization: false
    });

    const angularOptions = angular.overrideAngularOptions({
      styles: [path.resolve('node_modules/@ntmnt/uikit.styles.core/index.scss')]
    });

    const WebEnvEnv = angular.compose([compilerOptions, angularOptions])
    envs.registerEnv(WebEnvEnv)

    return new WebEnvExtension()
  }
}

However it throws the following error with bit v0.0.814 when I run bit start

Screenshot 2022-08-11 at 00 12 46

After some investigation I found out that EnvRuntime created via angular.compose mises envAspectDefinition property.

Please let me know if something has changed and I should extend my env in another way!

Also here is the part of my workspace.jsonc:

{
...,
"teambit.dependencies/dependency-resolver": {
    "packageManager": "teambit.dependencies/yarn",
    "policy": {
      "dependencies": {
        "@teambit/angular-v12": "1.2.4",
        "@angular/cdk": "12.2.13",
        "angular2-text-mask": "9.0.0",
        "text-mask-addons": "3.8.0"
      },
      "peerDependencies": {}
    }
  },
  "teambit.workspace/variants": {
    "*": {
      "ntmnt.uikit/envs/web-env": {}
    }
  },
  "teambit.angular/versions/angular-v12@1.2.4": {},
  "teambit.generator/generator": {
    "aspects": [
      "ntmnt.uikit/envs/web-env"
    ]
  }
}
GiladShoham commented 1 year ago

Hi, I solved this a few days ago. Can you please try with the latest bit version and let me know if it still happens?

AntGrisha commented 1 year ago

@GiladShoham works fine in 0.0.832, thank you for the fix!