<commit_before>const fs = require('fs')
const { sources } = require('webpack')

const appPaths = require('../../app-paths')
const getFixedDeps = require('../../helpers/get-fixed-deps')
const { getIndexHtml } = require('../../ssr/html-template')

module.exports = class WebserverAssetsPlugin {
  constructor (cfg = {}) {
    this.cfg = cfg
    this.initPackageJson()
    this.initHtmlTemplate()
  }

  apply (compiler) {
    compiler.hooks.thisCompilation.tap('package.json', compilation => {
      compilation.emitAsset('package.json', new sources.RawSource(this.pkg))
      compilation.emitAsset('render-template.js', new sources.RawSource(this.htmlTemplate))
    })
  }

  initPackageJson () {
    const appPkg = require(appPaths.resolve.app('package.json'))
    const cliPkg = require(appPaths.resolve.cli('package.json'))

    if (appPkg.dependencies !== void 0) {
      delete appPkg.dependencies['@quasar/extras']
    }

    const appDeps = getFixedDeps(appPkg.dependencies || {})
    const cliDeps = cliPkg.dependencies

    let pkg = {
      name: appPkg.name,
      version: appPkg.version,
      description: appPkg.description,
      author: appPkg.author,
      private: true,
      scripts: {
        start: 'node index.js'
      },
      dependencies: Object.assign(
        appDeps,
        {
          'compression': '^1.0.0',
          'express': '^4.0.0',
          'vue': cliDeps.vue,
          '@vue/server-renderer': cliDeps['@vue/server-renderer'],
          '@vue/compiler-sfc': cliDeps['@vue/compiler-sfc'],
          '@quasar/ssr-helpers': cliDeps['@quasar/ssr-helpers'],
          'vue-router': cliDeps['vue-router']
        },
        this.cfg.build.transpile === true
          ? { '@quasar/babel-preset-app': cliDeps['@quasar/babel-preset-app'] }
          : {}
      ),
      engines: appPkg.engines,
      browserslist: appPkg.browserslist,
      quasar: { ssr: true }
    }

    if (this.cfg.store) {
      pkg.dependencies.vuex = cliDeps.vuex
    }

    if (this.cfg.ssr.extendPackageJson) {
      this.cfg.ssr.extendPackageJson(pkg)
    }

    this.pkg = JSON.stringify(pkg, null, 2)
  }

  initHtmlTemplate () {
    const htmlFile = appPaths.resolve.app(this.cfg.sourceFiles.indexHtmlTemplate)
    const renderTemplate = getIndexHtml(fs.readFileSync(htmlFile, 'utf-8'), this.cfg)
    this.htmlTemplate = `module.exports=${renderTemplate.source}`
  }
}
<commit_msg>fix(app): removed vuex from ssr package.json (#9700)<commit_after>const fs = require('fs')
const { sources } = require('webpack')

const appPaths = require('../../app-paths')
const getFixedDeps = require('../../helpers/get-fixed-deps')
const { getIndexHtml } = require('../../ssr/html-template')

module.exports = class WebserverAssetsPlugin {
  constructor (cfg = {}) {
    this.cfg = cfg
    this.initPackageJson()
    this.initHtmlTemplate()
  }

  apply (compiler) {
    compiler.hooks.thisCompilation.tap('package.json', compilation => {
      compilation.emitAsset('package.json', new sources.RawSource(this.pkg))
      compilation.emitAsset('render-template.js', new sources.RawSource(this.htmlTemplate))
    })
  }

  initPackageJson () {
    const appPkg = require(appPaths.resolve.app('package.json'))
    const cliPkg = require(appPaths.resolve.cli('package.json'))

    if (appPkg.dependencies !== void 0) {
      delete appPkg.dependencies['@quasar/extras']
    }

    const appDeps = getFixedDeps(appPkg.dependencies || {})
    const cliDeps = cliPkg.dependencies

    let pkg = {
      name: appPkg.name,
      version: appPkg.version,
      description: appPkg.description,
      author: appPkg.author,
      private: true,
      scripts: {
        start: 'node index.js'
      },
      dependencies: Object.assign(
        appDeps,
        {
          'compression': '^1.0.0',
          'express': '^4.0.0',
          'vue': cliDeps.vue,
          '@vue/server-renderer': cliDeps['@vue/server-renderer'],
          '@vue/compiler-sfc': cliDeps['@vue/compiler-sfc'],
          '@quasar/ssr-helpers': cliDeps['@quasar/ssr-helpers'],
          'vue-router': cliDeps['vue-router']
        },
        this.cfg.build.transpile === true
          ? { '@quasar/babel-preset-app': cliDeps['@quasar/babel-preset-app'] }
          : {}
      ),
      engines: appPkg.engines,
      browserslist: appPkg.browserslist,
      quasar: { ssr: true }
    }

    if (this.cfg.ssr.extendPackageJson) {
      this.cfg.ssr.extendPackageJson(pkg)
    }

    this.pkg = JSON.stringify(pkg, null, 2)
  }

  initHtmlTemplate () {
    const htmlFile = appPaths.resolve.app(this.cfg.sourceFiles.indexHtmlTemplate)
    const renderTemplate = getIndexHtml(fs.readFileSync(htmlFile, 'utf-8'), this.cfg)
    this.htmlTemplate = `module.exports=${renderTemplate.source}`
  }
}

{'fraction_non_alphanumeric': 0.15563957151858854, 'fraction_numerical': 0.004620877966813695, 'mean_word_length': 2.8004788507581804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5554929', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1596, 'n_words': 240}