"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/server/webpack-plugin/server.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.

server.js  (vue-2.6.13):server.js  (vue-2.6.14)
import { validate, isJS, onEmit } from './util' import { validate, isJS, getAssetName, onEmit } from './util'
export default class VueSSRServerPlugin { export default class VueSSRServerPlugin {
constructor (options = {}) { constructor (options = {}) {
this.options = Object.assign({ this.options = Object.assign({
filename: 'vue-ssr-server-bundle.json' filename: 'vue-ssr-server-bundle.json'
}, options) }, options)
} }
apply (compiler) { apply (compiler) {
validate(compiler) validate(compiler)
onEmit(compiler, 'vue-server-plugin', (compilation, cb) => { const stage = 'PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER'
onEmit(compiler, 'vue-server-plugin', stage, (compilation, cb) => {
const stats = compilation.getStats().toJson() const stats = compilation.getStats().toJson()
const entryName = Object.keys(stats.entrypoints)[0] const entryName = Object.keys(stats.entrypoints)[0]
const entryInfo = stats.entrypoints[entryName] const entryInfo = stats.entrypoints[entryName]
if (!entryInfo) { if (!entryInfo) {
// #5553 // #5553
return cb() return cb()
} }
const entryAssets = entryInfo.assets.filter(isJS) const entryAssets = entryInfo.assets
.map(getAssetName)
.filter(isJS)
if (entryAssets.length > 1) { if (entryAssets.length > 1) {
throw new Error( throw new Error(
`Server-side bundle should have one single entry file. ` + `Server-side bundle should have one single entry file. ` +
`Avoid using CommonsChunkPlugin in the server config.` `Avoid using CommonsChunkPlugin in the server config.`
) )
} }
const entry = entryAssets[0] const entry = entryAssets[0]
if (!entry || typeof entry !== 'string') { if (!entry || typeof entry !== 'string') {
skipping to change at line 45 skipping to change at line 48
`Entry "${entryName}" not found. Did you specify the correct entry opt ion?` `Entry "${entryName}" not found. Did you specify the correct entry opt ion?`
) )
} }
const bundle = { const bundle = {
entry, entry,
files: {}, files: {},
maps: {} maps: {}
} }
stats.assets.forEach(asset => { Object.keys(compilation.assets).forEach(name => {
if (isJS(asset.name)) { if (isJS(name)) {
bundle.files[asset.name] = compilation.assets[asset.name].source() bundle.files[name] = compilation.assets[name].source()
} else if (asset.name.match(/\.js\.map$/)) { } else if (name.match(/\.js\.map$/)) {
bundle.maps[asset.name.replace(/\.map$/, '')] = JSON.parse(compilation bundle.maps[name.replace(/\.map$/, '')] = JSON.parse(compilation.asset
.assets[asset.name].source()) s[name].source())
} }
// do not emit anything else for server // do not emit anything else for server
delete compilation.assets[asset.name] delete compilation.assets[name]
}) })
const json = JSON.stringify(bundle, null, 2) const json = JSON.stringify(bundle, null, 2)
const filename = this.options.filename const filename = this.options.filename
compilation.assets[filename] = { compilation.assets[filename] = {
source: () => json, source: () => json,
size: () => json.length size: () => json.length
} }
 End of changes. 5 change blocks. 
10 lines changed or deleted 13 lines changed or added

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