"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/server/webpack-plugin/client.js" between
vue-2.6.13.tar.gz and vue-2.6.14.tar.gz

About: Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

client.js  (vue-2.6.13):client.js  (vue-2.6.14)
const hash = require('hash-sum') const hash = require('hash-sum')
const uniq = require('lodash.uniq') const uniq = require('lodash.uniq')
import { isJS, isCSS, onEmit } from './util' import { isJS, isCSS, getAssetName, onEmit, stripModuleIdHash } from './util'
export default class VueSSRClientPlugin { export default class VueSSRClientPlugin {
constructor (options = {}) { constructor (options = {}) {
this.options = Object.assign({ this.options = Object.assign({
filename: 'vue-ssr-client-manifest.json' filename: 'vue-ssr-client-manifest.json'
}, options) }, options)
} }
apply (compiler) { apply (compiler) {
onEmit(compiler, 'vue-client-plugin', (compilation, cb) => { const stage = 'PROCESS_ASSETS_STAGE_ADDITIONAL'
onEmit(compiler, 'vue-client-plugin', stage, (compilation, cb) => {
const stats = compilation.getStats().toJson() const stats = compilation.getStats().toJson()
const allFiles = uniq(stats.assets const allFiles = uniq(stats.assets
.map(a => a.name)) .map(a => a.name))
const initialFiles = uniq(Object.keys(stats.entrypoints) const initialFiles = uniq(Object.keys(stats.entrypoints)
.map(name => stats.entrypoints[name].assets) .map(name => stats.entrypoints[name].assets)
.reduce((assets, all) => all.concat(assets), []) .reduce((assets, all) => all.concat(assets), [])
.map(getAssetName)
.filter((file) => isJS(file) || isCSS(file))) .filter((file) => isJS(file) || isCSS(file)))
const asyncFiles = allFiles const asyncFiles = allFiles
.filter((file) => isJS(file) || isCSS(file)) .filter((file) => isJS(file) || isCSS(file))
.filter(file => initialFiles.indexOf(file) < 0) .filter(file => initialFiles.indexOf(file) < 0)
const manifest = { const manifest = {
publicPath: stats.publicPath, publicPath: stats.publicPath,
all: allFiles, all: allFiles,
initial: initialFiles, initial: initialFiles,
async: asyncFiles, async: asyncFiles,
modules: { /* [identifier: string]: Array<index: number> */ } modules: { /* [identifier: string]: Array<index: number> */ }
} }
const assetModules = stats.modules.filter(m => m.assets.length) const assetModules = stats.modules.filter(m => m.assets.length)
const fileToIndex = file => manifest.all.indexOf(file) const fileToIndex = asset => manifest.all.indexOf(getAssetName(asset))
stats.modules.forEach(m => { stats.modules.forEach(m => {
// ignore modules duplicated in multiple chunks // ignore modules duplicated in multiple chunks
if (m.chunks.length === 1) { if (m.chunks.length === 1) {
const cid = m.chunks[0] const cid = m.chunks[0]
const chunk = stats.chunks.find(c => c.id === cid) const chunk = stats.chunks.find(c => c.id === cid)
if (!chunk || !chunk.files) { if (!chunk || !chunk.files) {
return return
} }
const id = m.identifier.replace(/\s\w+$/, '') // remove appended hash const id = stripModuleIdHash(m.identifier)
const files = manifest.modules[hash(id)] = chunk.files.map(fileToIndex ) const files = manifest.modules[hash(id)] = chunk.files.map(fileToIndex )
// find all asset modules associated with the same chunk // find all asset modules associated with the same chunk
assetModules.forEach(m => { assetModules.forEach(m => {
if (m.chunks.some(id => id === cid)) { if (m.chunks.some(id => id === cid)) {
files.push.apply(files, m.assets.map(fileToIndex)) files.push.apply(files, m.assets.map(fileToIndex))
} }
}) })
} }
}) })
 End of changes. 5 change blocks. 
4 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)