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

--prod is no longer needed for library modules #2

Closed
xmlking opened this issue Sep 7, 2019 · 2 comments · Fixed by #3
Closed

--prod is no longer needed for library modules #2

xmlking opened this issue Sep 7, 2019 · 2 comments · Fixed by #3
Labels
good first issue Good for newcomers

Comments

@xmlking
Copy link

xmlking commented Sep 7, 2019

my repo: https://github.com/xmlking/ngx-starter-kit
when I run

ng deploy ngx-utils --dry-run

I am getting error.

according to angular/angular-cli#12290

the --prod is no longer needed as the library is always build in AOT mode and without the --prod it does clean the previous files as well.

Error

Error when trying to deploy:
Error: Configuration 'production' is not set in the workspace.
    at WorkspaceNodeModulesArchitectHost.getOptionsForTarget (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:72:19)
    at ArchitectTargetJobRegistry.get (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/architect/src/architect.js:155:24)
    at MergeMapSubscriber.project (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/core/src/experimental/jobs/fallback-registry.js:23:81)
    at MergeMapSubscriber._tryNext (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
    at MergeMapSubscriber._next (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:66:18)
    at Observable._subscribe (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/core/node_modules/rxjs/internal/util/subscribeToArray.js:5:20)
    at Observable._trySubscribe (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Observable.js:44:25)
    at Observable.subscribe (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Observable.js:30:22)
    at MergeMapOperator.call (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:39:23)

my lib module in angular.json

    "ngx-utils": {
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-ng-packagr:build",
          "options": {
            "project": "libs/ngx-utils/ng-package.json",
            "tsConfig": "libs/ngx-utils/tsconfig.lib.json"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "exclude": ["**/node_modules/**", "!libs/ngx-utils/**"],
            "tsConfig": ["libs/ngx-utils/tsconfig.lib.json", "libs/ngx-utils/tsconfig.spec.json"]
          }
        },
        "test": {
          "builder": "@nrwl/jest:jest",
          "options": {
            "jestConfig": "libs/ngx-utils/jest.config.js",
            "setupFile": "libs/ngx-utils/src/test-setup.ts",
            "tsConfig": "libs/ngx-utils/tsconfig.spec.json"
          }
        },
        "deploy": {
          "builder": "ngx-deploy-npm:deploy",
          "options": {
            "access": "public"
          }
        }
      },
      "prefix": "ngx",
      "projectType": "library",
      "root": "libs/ngx-utils",
      "sourceRoot": "libs/ngx-utils/src"
    },

How to reproduce

ng new my-project --create-application false
ng generate library my-lib
ng generate application my-app
ng add ngx-deploy-npm
ng deploy my-lib --dry-run 
@dianjuar dianjuar added the good first issue Good for newcomers label Sep 8, 2019
@dianjuar
Copy link
Member

dianjuar commented Sep 8, 2019

Yeah, your are right, we do not need to compile on production an angular package, there is no such thing on building a package in production mode.

The reasons what I set that:

  • I use Nx to build packages and when you run affected:build --prod (I use it a lot on the CI to check PR's) if you don't have the production environment your build is going to fail
  • The deployer starter is compiling by default in production

But thank you for reporting me this issue... I'm going to fix it right now...


For a quick fix until the path is done, just add a production environment in your angular.json

"build": {
  "configurations": {
    "production": {}
  }
}

@dianjuar
Copy link
Member

dianjuar commented Sep 8, 2019

A new version was published on NPM @xmlking

Thank you so much for provide your feedback 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants