jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.59k stars 4.03k forks source link

JIHPSTER with nest js takes too long time to re compile after any change i make to any backend file #20688

Closed Othman2001 closed 1 year ago

Othman2001 commented 1 year ago

i am working on large project with nest js and used jdl and jhipster to generate code, but sometime we need customization and in order to make any custom code in any controller or any service it takes maybe 10 to 15 min in order re compile the project again and nodemon starts again. so anyway to fix that issue maybe in webpack config ?

Othman2001 commented 1 year ago

webpack.server.prod.config.js

const path = require('path');
const webpack = require('webpack');

module.exports = {
  target: 'node',
  entry: {
    app: ['./src/main.ts'],
  },
  resolve: {
    extensions: ['.ts', '.js'],
    alias: {},
  },
  mode: 'production',
  node: {
    __filename: false,
    __dirname: false,
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js',
  },
  module: {
    rules: [
      {
        use: 'ts-loader',
        test: /\.ts?$/,
        exclude: /node_module/,
      },
    ],
  },
  plugins: [
    new webpack.EnvironmentPlugin({
      BACKEND_ENV: 'prod',
    }),
  ],
  externals: {
    '@nestjs/microservices': 'nestjs/microservices',
    'cache-manager': 'cache-manager',
    'fastify-swagger': 'fastify-swagger',
    'aws-sdk': 'aws-sdk',
  },
};
Othman2001 commented 1 year ago

webpack.dev.js

const webpack = require('webpack');
const webpackMerge = require('webpack-merge').merge;
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const path = require('path');
const sass = require('sass');

const utils = require('./utils.js');
const commonConfig = require('./webpack.common.js');

const ENV = 'development';

module.exports = options =>
  webpackMerge(commonConfig({ env: ENV }), {
    devtool: 'cheap-module-source-map', // https://reactjs.org/docs/cross-origin-errors.html
    mode: ENV,
    entry: ['./src/main/webapp/app/index'],
    output: {
      path: utils.root('target/classes/static/'),
      filename: 'app/[name].bundle.js',
      chunkFilename: 'app/[id].chunk.js',
    },
    optimization: {
      moduleIds: 'named',
    },
    module: {
      rules: [
        {
          test: /\.(sa|sc|c)ss$/,
          use: [
            'style-loader',
            'css-loader',
            'postcss-loader',
            {
              loader: 'sass-loader',
              options: { implementation: sass },
            },
          ],
        },
      ],
    },
    devServer: {
      stats: options.stats,
      hot: true,
      contentBase: './target/classes/static/',
      proxy: [
        {
          context: ['/api', '/services', '/management', '/swagger-resources', '/v2/api-docs', '/v3/api-docs', '/h2-console', '/auth'],
          target: `http${options.tls ? 's' : ''}://localhost:8081`,
          secure: false,
          changeOrigin: options.tls,
        },
      ],
      watchOptions: {
        ignore: [/node_modules/, utils.root('src/test')],
      },
      https: options.tls,
      historyApiFallback: true,
    },
    stats: process.env.JHI_DISABLE_WEBPACK_LOGS ? 'none' : options.stats,
    plugins: [
      process.env.JHI_DISABLE_WEBPACK_LOGS
        ? null
        : new SimpleProgressWebpackPlugin({
            format: options.stats === 'minimal' ? 'compact' : 'expanded',
          }),
      new FriendlyErrorsWebpackPlugin(),
      new BrowserSyncPlugin(
        {
          https: options.tls,
          host: 'localhost',
          port: 9000,
          proxy: {
            target: `http${options.tls ? 's' : ''}://localhost:9060`,
            proxyOptions: {
              changeOrigin: false, //pass the Host header to the backend unchanged  https://github.com/Browsersync/browser-sync/issues/430
            },
          },
          socket: {
            clients: {
              heartbeatTimeout: 60000,
            },
          },
          /*
      ,ghostMode: { // uncomment this part to disable BrowserSync ghostMode; https://github.com/jhipster/generator-jhipster/issues/11116
        clicks: false,
        location: false,
        forms: false,
        scroll: false
      } */
        },
        {
          reload: false,
        }
      ),
      new webpack.HotModuleReplacementPlugin(),
      new WebpackNotifierPlugin({
        title: 'Noboogh',
        contentImage: path.join(__dirname, 'logo-jhipster.png'),
      }),
    ].filter(Boolean),
  });
gmarziou commented 1 year ago

@Othman2001 Please paste output of jhipster info in your project folder as explained in issue guidelines because for now we have absolutely no idea about your project configuration and dev environment.

Othman2001 commented 1 year ago

@gmarziou

+-- generator-jhipster@7.0.1 -- generator-jhipster-nodejs@2.0.0 -- generator-jhipster@7.0.1 deduped

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "blueprints": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "2.0.0"
      }
    ],
    "otherModules": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "2.0.0"
      }
    ],
    "applicationType": "monolith",
    "baseName": "Noboogh",
    "jhipsterVersion": "7.0.1",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": [],
    "pages": [],
    "creationTimestamp": 1664297054112,
    "serverPort": "8081",
    "packageName": "com.jhipster.node",
    "databaseType": "sql",
    "devDatabaseType": "sqlite",
    "prodDatabaseType": "postgresql",
    "authenticationType": "jwt",
    "clientFramework": "react",
    "withAdminUi": true,
    "clientTheme": "none",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "packageFolder": "com/jhipster/node",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",    "serviceDiscoveryType": false,
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "clientPackageManager": "npm",
    "clientThemeVariant": "",
    "languages": ["en", "ar-ly"],
    "cacheProvider": "ehcache",
    "buildTool": "maven",
    "enableHibernateCache": true,
    "reactive": false,
    "entities": [
      "HomeData",
      "SocialLink",
      "FAQ",
      "HomeSlider",
      "Pages",
      "NobValue",
      "AgeRange",
      "Fields",
      "Indicators",
      "TestimonialsContent",
      "Activities",
      "ActivityAttachments",
      "Questions",
      "Answers",
      "Badges",
      "Acceptance",
      "UserSetting",
      "AccountClosing",
      "UserAnswer",
      "UserResult",
      "Kid",
      "KidActivity",
      "KidPracticeQuestionAnswers",
      "KidPracticeAttachments",
      "CloseUserAccount",
      "Events",
      "Articles",
      "Tickets",
      "TicketAttachments",
      "Notifications",
      "AgeRangeIndicatorFields",
      "UserNotifications",
      "TicketsComments",
      "TicketsCommentsAttachments",
      "Discussions",
      "DiscussionsComments",
      "SystemNotifications",
      "ActivityLibrary",
      "ActivityLibraryAttachments"
    ],
    "lastLiquibaseTimestamp": 1672056152000
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity HomeData {
  title String required
  key String required
  value String required
}
entity SocialLink {
  title String required
  href String required
  isActive Boolean
}
entity FAQ {
  title String required
  answer String required
  isActive Boolean required
  order Integer
}
entity HomeSlider {
  title String required
  description String required
  image String required
  order Integer
  isActive Boolean
}
entity Pages {
  title String required
  content String required
  isActive Boolean
}
entity NobValue {
  title String required
  description String required
  imageUrl String
}
entity TestimonialsContent {
  motherName String required
  imageUrl String required
  opinions String required
  opinionOrder Integer
  isActive Boolean required
}
entity AgeRange {
  name String required
  ageFrom Float required
  ageTo Float required
  isActive Boolean
}
entity Fields {
  name String required
  isActive Boolean
}
entity Indicators {
  name String required
  isActive Boolean
}
entity Activities {
  name String required
  grade Float required
  idea String required
  tools String required
  procedure String required
  image String required
  isActive Boolean required
  manualCorrect Boolean required
  needAttachment Boolean required
  questionsInGrade Boolean required
}
entity ActivityAttachments {
  link String required
}
entity Questions {
  title String required
}
entity Answers {
  title String required
  answer Boolean required
}
entity Badges {
  name String required
  image String required
  badgeCase BadgeCase required
  grade Float
  isActive Boolean required
}
entity Acceptance {
  title String required
  acceptanceType AcceptanceType required
  noOfTrails Integer
  successPercentage Float
  isActive Boolean required
}
entity UserSetting {
  communication Boolean required
  secret Boolean required
}
entity AccountClosing {
  reason String required
  isActive Boolean required
}
entity UserAnswer
entity UserResult {
  numberOfTrials Integer
  grade Integer
  result ResultEnum
}
entity Kid {
  firstName String required
  lastName String
  birthDate LocalDate required
  gender Gender required
  image String
  status AccountType required
}
entity KidActivity {
  score String required
  noOfTrails String required
  isPassed PracticeStatus required
}
entity KidPracticeQuestionAnswers {
  correct Boolean required
}
entity KidPracticeAttachments {
  link String required
}
entity CloseUserAccount {
  otherReason String
}
entity Events {
  name String required
  imageUrl String
  eventDate String required
  descriptions String required
  link String required
  isActive Boolean
}
entity Articles {
  name String required
  imageUrl String
  publishDate LocalDate required
  author String required
  keywords String required
  content String required
  isActive Boolean
}
entity Tickets {
  title String required
  descriptions String required
  type TicketType required
  status TicketStatus required
  isActive Boolean
}
entity TicketAttachments {
  link String required
}
entity Notifications {
  title String required
  description String
  imageUrl String
  link String
  date String required
}
entity AgeRangeIndicatorFields
entity UserNotifications {
  status NotificationStatus
}
entity TicketsComments {
  content String required
}
entity TicketsCommentsAttachments {
  link String required
}
entity Discussions {
  title String required
  imageUrl String
  startDate String required
  description String required
  isActive Boolean
}
entity DiscussionsComments {
  content String required
}
entity SystemNotifications {
  title String required
  childMinderDescription String required
  childDescription String
  systemNotificationCase SystemNotificationsStatus required
  isActive Boolean
}
entity ActivityLibrary {
  kidGrade String required
}
entity ActivityLibraryAttachments {
  link String required
}
enum BadgeCase {
  GRADE,
  ACHIEVMENT,
  BOTH
}
enum AcceptanceType {
  SURVEY,
  TEST
}
enum ResultEnum {
  FAIL,
  PASS
}
enum Gender {
  BOY,
  GIRL
}
enum AccountType {
  ACTIVE,
  DELETED
}
enum PracticeStatus {
  NEEDCORRECT,
  PASSED,
  FAILD
}
enum TicketType {
  SUGGESTION,
  SELECTION_ITEMS,
  INQUIREY,
  COMPLAINT
}
enum TicketStatus {
  OPEN,
  RE_OPENED,
  CLOSED
}
enum NotificationStatus {
  READ,
  UNREAD
}
enum SystemNotificationsStatus {
  NEW_ACTIVITY_PUBLISHING,
  ACHEIVMENT_LIBRARY,
  NEW_ARTICLE,
  MOTHER_BOARD,
  NEW_DISCUSSION,
  NEW_EVENT,
  TICKET_RESOLVED
}

relationship OneToOne {
  UserSetting{user} to User
  Kid{account(login)} to User
  CloseUserAccount{user} to User
  TicketsCommentsAttachments{comment(content)} to TicketsComments
}
relationship OneToMany {
  Activities{attachments(link) required} to ActivityAttachments{activities(name) required}
  Activities{questions(title)} to Questions{activities(name)}
  Acceptance{questions(title)} to Questions{acceptance(title)}
  Questions{answers(title)} to Answers{question(title) required}
  Questions{userAnswer} to UserAnswer{questions(title)}
  Answers{userAnswer} to UserAnswer{answerId(title)}
  UserResult{userAnswer} to UserAnswer{userResult}
  Acceptance{userResult} to UserResult{acceptance(title)}
  KidActivity{questionAnswers} to KidPracticeQuestionAnswers{kidActivity}
  KidActivity{attachments(link) required} to KidPracticeAttachments{kidActivity}
  AccountClosing{closeUserAccount} to CloseUserAccount{reasons(reason)}
  Tickets{attachments(link) required} to TicketAttachments{tickets(name) required}
  DiscussionsComments{discussionsComments} to DiscussionsComments{parent(content)}
  Activities{library(name)} to ActivityLibrary{activity(name)}
  ActivityLibrary{attachments(link) required} to ActivityLibraryAttachments{library(name) required}
}
relationship ManyToOne {
  Activities{ageRange(name) required} to AgeRange
  Activities{fields(name) required} to Fields
  Activities{indicators(name) required} to Indicators
  Badges{ageRange(name) required} to AgeRange
  UserResult{user(email)} to User
  Kid{childMinder(login)} to User
  KidActivity{kids(firstName)} to Kid
  KidActivity{activities(name)} to Activities
  KidPracticeQuestionAnswers{question(title)} to Questions
  KidPracticeQuestionAnswers{answer(title)} to Answers
  AgeRangeIndicatorFields{ageRange(name)} to AgeRange
  AgeRangeIndicatorFields{indicators(name)} to Indicators
  AgeRangeIndicatorFields{fields(name)} to Fields
  UserNotifications{notifications(title)} to Notifications
  UserNotifications{user(login)} to User
  TicketsComments{ticket(title)} to Tickets
  TicketsComments{user(login)} to User
  DiscussionsComments{discussion(title)} to Discussions
  DiscussionsComments{user(login)} to User
  ActivityLibrary{kid(firstName)} to Kid
}
relationship ManyToMany {
  Fields{ageRange(name) required} to AgeRange{fields}
  Badges{activities(name)} to Activities{badges}
  Kid{badges(name)} to Badges{kid}
  Events{ageRange(name)} to AgeRange{events}
  Articles{ageRange(name)} to AgeRange{articles}
  Discussions{ageRange(name)} to AgeRange{discussions}
  Discussions{like(login)} to User
  DiscussionsComments{like(login)} to User
  SystemNotifications{ageRange(name)} to AgeRange{systemNotifications}
}

paginate HomeData, SocialLink, FAQ, HomeSlider, Pages, NobValue, TestimonialsContent, AgeRange, Fields, Indicators, Activities, ActivityAttachments, Questions, Answers, Badges, Acceptance, Kid, KidActivity, KidPracticeQuestionAnswers, KidPracticeAttachments, Events, Articles, Tickets, TicketAttachments, Notifications, TicketsComments, TicketsCommentsAttachments, Discussions, DiscussionsComments, SystemNotifications, ActivityLibrary, ActivityLibraryAttachments with pager

Environment and Tools

git version 2.39.0.windows.1

node: v14.16.0

npm: 6.14.11

Docker version 20.10.21, build baeda1f

Docker Compose version v2.13.0

No change to package.json was detected. No package manager install will be executed. Congratulations, JHipster execution is complete! Sponsored with ❤️ by @oktadev.

gmarziou commented 1 year ago

@Othman2001 thanks, so you have opened an issue against wrong project.

You should open it against https://github.com/jhipster/generator-jhipster-nodejs