Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Building with '--prod' fails #198

Closed
subotic opened this issue Mar 8, 2018 · 10 comments · Fixed by #291
Closed

Building with '--prod' fails #198

subotic opened this issue Mar 8, 2018 · 10 comments · Fixed by #291
Assignees
Labels

Comments

@subotic
Copy link
Member

subotic commented Mar 8, 2018

Building Salsah2 for production

$ ng build --prod --env=prod

fails with the following error:

ERROR in : Unexpected value 'MatJDNConvertibleCalendarDateAdapterModule in /Users/subotic/_github.com/Salsah/node_modules/jdnconvertiblecalendardateadapter/dist/index.d.ts' imported by the module 'AppModule in /Users/subotic/_github.com/Salsah/src/app/app.module.ts'. Please add a @NgModule annotation.
@subotic subotic added the bug label Mar 8, 2018
@subotic subotic added this to the v2.0.0-alpha.13 milestone Mar 8, 2018
@subotic
Copy link
Member Author

subotic commented Mar 8, 2018

@tobiasschweizer this sounds like JDN. Do you maybe know what the problem could be?

@kilchenmann
Copy link
Member

Why you're using the --prod flag? It works with

$ ng build --env=prod

The production flag is already set in environment.prod.ts.

I know there are some issues with the --prod flag in angular-cli. But your command should be the same as mine. It's described here: https://www.npmjs.com/package/angular-cli#creating-a-build
So, it's strange that one case is running and the other one isn't.

@subotic
Copy link
Member Author

subotic commented Mar 8, 2018

Why you're using the --prod flag?

Because this is what should be used when building for production. Please see https://github.com/angular/angular-cli/wiki/build#--dev-vs---prod-builds

I know it works without the --prod flag. But then it is the same as running with --dev.

@subotic
Copy link
Member Author

subotic commented Mar 8, 2018

The production flag is already set in environment.prod.ts.

I don't think that this does anything. It's simply for easy checking of the environment during runtime, e.g.:

if (environment.production) {
  ...
}

or

if (isDevMode()) {
      console.log('👋 Development!');
} else {
      console.log('💪 Production!');
}

@subotic
Copy link
Member Author

subotic commented Mar 8, 2018

I think that this is related to angular/angular#15763. Apparently, defining "@angular/core": "^5.1.0" in package.json of JDNConvertibleCalendarDateAdapter, can cause problems with Salsah2 which uses "@angular/core": "^5.2.2". The solution is to set it like this "@angular/core": ">=5.1.0".

@subotic
Copy link
Member Author

subotic commented Mar 12, 2018

@tobiasschweizer
Copy link
Contributor

tobiasschweizer commented Mar 14, 2018

/Users/tobi/gitreps/salsah_github/node_modules/jdnconvertiblecalendardateadapter/dist/index.d.ts

import {NgModule} from '@angular/core';
import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MAT_DATE_LOCALE_PROVIDER} from '@angular/material';
import {MAT_JDN_DATE_FORMATS} from 'jdnconvertiblecalendardateadapter/dist/JDNConvertibleCalendar-date-formats';
import {JDNConvertibleCalendarDateAdapter} from 'jdnconvertiblecalendardateadapter';

@NgModule({
    providers: [
        MAT_DATE_LOCALE_PROVIDER,
        {provide: DateAdapter, useClass: JDNConvertibleCalendarDateAdapter, deps: [MAT_DATE_LOCALE]}
    ]
})
export declare class JDNConvertibleCalendarDateAdapterModule {
}

@NgModule({
    imports: [JDNConvertibleCalendarDateAdapterModule],
    providers: [{provide: MAT_DATE_FORMATS, useValue: MAT_JDN_DATE_FORMATS}],
})
export declare class MatJDNConvertibleCalendarDateAdapterModule {
}
export { JDNConvertibleCalendarDateAdapter } from './JDNConvertibleCalendarDateAdapter';

to be fixed by dhlab-basel/JDNConvertibleCalendarDateAdapter#5

@subotic
Copy link
Member Author

subotic commented Mar 14, 2018

final build command: ng build --prod --env=prod --build-optimizer

@subotic
Copy link
Member Author

subotic commented Mar 15, 2018

interesting view:

screenshot 2018-03-15 11 48 39

This is a screenshot of a clickable map which you can generate with the following steps:

$ ng build --prod --sourcemaps
$ node_modules/.bin/source-map-explorer dist/main.*.bundle.js

The source-map-explorer package needs to be installed. I have added it to devDependencies in the wip/fix-prod-build.

@kilchenmann
Copy link
Member

btw. --env doesn't exist anymore in Angular 6 cli. It's now --configuration or -c
I will document this in the PR #292

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants