teambit / bit.envs

DEPRECATED - Bit compilers and testers were moved to https://github.com/teambit/envs
https://bit.dev/bit/envs
Other
23 stars 9 forks source link

Wrong link to dependencies component in Angular compiler #44

Closed JoshK2 closed 4 years ago

JoshK2 commented 4 years ago

I tried to export this project to bit: https://github.com/swimlane/ngx-charts And I get an error that the files do not exist.

Steps to Reproduce

  1. clone the project
  2. run checkout git checkout tags/12.0.1
  3. run npm i
  4. change the following:
    in file src/common/axes/y-axis-ticks.component.ts change import roundedReact to `import { roundedRect } from '../shape.helper';`
    in file src/utils/types.ts change return in isDate to `return Object.prototype.toString.call(value) === '[object Date]';`
  5. run bit add commands:
    
    bit add src/*/ -e 'src/{PARENT}/*.spec.ts,src/common,src/models,src/utils' -m 'src/{PARENT}/index.ts'
    bit add src/utils/* -n utils 
    bit add src/models/* -n models
    bit add src/events.ts -n internal

bit add src/common// -n common -e 'src/common//*.spec.ts' bit add src/common/area.component.ts -n common bit add src/common/base-chart.component.ts src/common/base-chart.component.scss -m 'base-chart.component.ts' -i common/base-chart bit add src/common/chart-common.module.ts -n common bit add src/common/circle-series.component.ts -n common bit add src/common/circle.component.ts -n common bit add src/common/color.helper.ts -n common bit add src/common/domain.helper.ts -n common bit add src/common/grid-layout.helper.ts -n common bit add src/common/grid-panel-series.component.ts -n common bit add src/common/grid-panel.component.ts -n common bit add src/common/label.helper.ts -n common bit add src/common/shape.helper.ts -n common bit add src/common/svg-linear-gradient.component.ts -n common bit add src/common/svg-radial-gradient.component.ts -n common bit add src/common/tick-format.helper.ts -n common
bit add src/common/tooltip-area.component.ts -n common bit add src/common/trim-label.helper.ts -n common bit add src/common/view-dimensions.helper.ts -n common

6. bit status should be ok.
7. fork the angular compiler and set this config in bit object in package.json file.
```json
"bit": {
    "env": {
      "compiler": {
        "bit.envs/compilers/angular@0.2.0": {
          "options": {
            "file": "{PATH TO THE COMPILER}/components/compilers/angular/dist/angular.js"
          }
        }
      }
    },
    "componentsDefaultDirectory": "components/{name}",
    "packageManager": "npm",
    "overrides": {
      "*": {
        "dependencies": {

        },
        "peerDependencies": {
          "d3": "^4.10.2",
          "@types/d3": "^5.7.2"
        }
      }
    }
  }
  1. change the tsconfig.json of the compiler to this:
    {
    "angularCompilerOptions": {
        "annotateForClosureCompiler": false,
        "skipTemplateCodegen": true,
        "strictMetadataEmit": false,
        "fullTemplateTypeCheck": false,
        "enableResourceInlining": true
    },
    "buildOnSave": false,
    "compileOnSave": false,
    "compilerOptions": {
        "baseUrl": "./",
        "target": "es2015",
        "module": "es2015",
        "moduleResolution": "node",
        "outDir": "dist",
        "declaration": true,
        "inlineSourceMap": true,
        "inlineSources": true,
        "skipLibCheck": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "importHelpers": false,
        "preserveSymlinks": true,
        "lib": [
            "dom",
            "es2018"
        ]
    },
    "exclude": [
        "node_modules",
        "dist",
        "**/*.ngfactory.ts",
        "**/*.shim.ts",
        "**/*.spec.ts"
    ]
    }
  2. run this build command to see the error: NG_DEBUG=true bit build area-chart

screenshot of wrong path: image (2)

screenshot after I change manually the path to the component: image (1) (1)

qballer commented 4 years ago

The internal component uses a custom made build process for the styles:

  1. the compile with node-sass.
  2. they use the replace package to replace all mentions of .scss to .css.

If you place the broken style in it's own component, ng-packagr will be able to inline the styles by himself.