nativescript-schematics icon indicating copy to clipboard operation
nativescript-schematics copied to clipboard

Generating web+mobile NgModules doesn't work in some code-sharing apps

Open sis0k0 opened this issue 5 years ago • 1 comments

Environment Provide the content of the package.json file in the project:

{
  "name": "WebMobileProject",
  "license": "SEE LICENSE IN <your-license-filename>",
  "version": "0.0.0",
  "nativescript": {
    "id": "org.nativescript.webmobileproject",
    "tns-android": {
      "version": "5.2.1"
    }
  },
  "scripts": {
    "android": "tns run android --bundle",
    "ios": "tns run ios --bundle",
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/http": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "nativescript-angular": "~7.2.0",
    "nativescript-theme-core": "~1.0.4",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~6.4.0",
    "tns-core-modules": "~5.2.0",
    "zone.js": "~0.8.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.0",
    "@angular/compiler-cli": "~7.2.0",
    "@nativescript/schematics": "^0.5.1",
    "nativescript-dev-webpack": "~0.20.0",
    "typescript": "~3.1.0"
  }
}

Describe the bug When executing the command ng generate module somename in a code-sharing project, the following files should be generated:

  • somename.module.ts - web NgModule
  • somename.module.tns.ts - mobile NgModule
  • somename.common.ts - shared file

However, only the web NgModule is generated. The behaviour is the same even if it's specified explicitly that both modules should be generated:

ng generate module somename --web=true --nativescript=true

To Reproduce

ng generate module somename

or

ng generate module somename --web=true --nativescript=true

Expected behavior All three files should be generated and the command flags should be respected.

Sample project I observed the behaviour in https://github.com/nativescript/web-mobile-project.

sis0k0 avatar Mar 20 '19 08:03 sis0k0

any resolution on this. i'm experiencing the same problem on a new project generated with Sidekick from the drawer template. Help files stated that new projects are automatically code sharing but currently ng generate only creates .ts files and not .tns.ts.

KirilOkun avatar Oct 01 '19 09:10 KirilOkun