"Fossies" - the Fresh Open Source Software Archive  

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

util.js  (vue-2.6.13):util.js  (vue-2.6.14)
const { red, yellow } = require('chalk') const { red, yellow } = require('chalk')
const webpack = require('webpack')
const prefix = `[vue-server-renderer-webpack-plugin]` const prefix = `[vue-server-renderer-webpack-plugin]`
const warn = exports.warn = msg => console.error(red(`${prefix} ${msg}\n`)) const warn = exports.warn = msg => console.error(red(`${prefix} ${msg}\n`))
const tip = exports.tip = msg => console.log(yellow(`${prefix} ${msg}\n`)) const tip = exports.tip = msg => console.log(yellow(`${prefix} ${msg}\n`))
const isWebpack5 = !!(webpack.version && webpack.version[0] > 4)
export const validate = compiler => { export const validate = compiler => {
if (compiler.options.target !== 'node') { if (compiler.options.target !== 'node') {
warn('webpack config `target` should be "node".') warn('webpack config `target` should be "node".')
} }
if (compiler.options.output && compiler.options.output.libraryTarget !== 'comm if (compiler.options.output) {
onjs2') { if (compiler.options.output.library) {
warn('webpack config `output.libraryTarget` should be "commonjs2".') // Webpack >= 5.0.0
if (compiler.options.output.library.type !== 'commonjs2') {
warn('webpack config `output.library.type` should be "commonjs2".')
}
} else if (compiler.options.output.libraryTarget !== 'commonjs2') {
// Webpack < 5.0.0
warn('webpack config `output.libraryTarget` should be "commonjs2".')
}
} }
if (!compiler.options.externals) { if (!compiler.options.externals) {
tip( tip(
'It is recommended to externalize dependencies in the server build for ' + 'It is recommended to externalize dependencies in the server build for ' +
'better build performance.' 'better build performance.'
) )
} }
} }
export const onEmit = (compiler, name, hook) => { export const onEmit = (compiler, name, stageName, hook) => {
if (compiler.hooks) { if (isWebpack5) {
// Webpack >= 5.0.0
compiler.hooks.compilation.tap(name, compilation => {
if (compilation.compiler !== compiler) {
// Ignore child compilers
return
}
const stage = webpack.Compilation[stageName]
compilation.hooks.processAssets.tapAsync({ name, stage }, (assets, cb) =>
{
hook(compilation, cb)
})
})
} else if (compiler.hooks) {
// Webpack >= 4.0.0 // Webpack >= 4.0.0
compiler.hooks.emit.tapAsync(name, hook) compiler.hooks.emit.tapAsync(name, hook)
} else { } else {
// Webpack < 4.0.0 // Webpack < 4.0.0
compiler.plugin('emit', hook) compiler.plugin('emit', hook)
} }
} }
export const stripModuleIdHash = id => {
if (isWebpack5) {
// Webpack >= 5.0.0
return id.replace(/\|\w+$/, '')
}
// Webpack < 5.0.0
return id.replace(/\s\w+$/, '')
}
export const getAssetName = asset => {
if (typeof asset === 'string') {
return asset
}
return asset.name
}
export { isJS, isCSS } from '../util' export { isJS, isCSS } from '../util'
 End of changes. 5 change blocks. 
5 lines changed or deleted 44 lines changed or added

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