util.ts — vue Source File
Architecture documentation for util.ts, a typescript file in the vue codebase. 0 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR a4aaa23d_d810_1245_8cde_5c37b4bd3875["util.ts"] 061cdd3c_2a4a_f420_388b_683da0ed2615["client.ts"] 061cdd3c_2a4a_f420_388b_683da0ed2615 --> a4aaa23d_d810_1245_8cde_5c37b4bd3875 cd8987ca_a5b9_5c1b_a002_527ecdd456bf["server.ts"] cd8987ca_a5b9_5c1b_a002_527ecdd456bf --> a4aaa23d_d810_1245_8cde_5c37b4bd3875 style a4aaa23d_d810_1245_8cde_5c37b4bd3875 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
const { red, yellow } = require('chalk')
const webpack = require('webpack')
const prefix = `[vue-server-renderer-webpack-plugin]`
const warn = (exports.warn = msg => console.error(red(`${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 => {
if (compiler.options.target !== 'node') {
warn('webpack config `target` should be "node".')
}
if (compiler.options.output) {
if (compiler.options.output.library) {
// 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) {
tip(
'It is recommended to externalize dependencies in the server build for ' +
'better build performance.'
)
}
}
export const onEmit = (compiler, name, stageName, hook) => {
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
compiler.hooks.emit.tapAsync(name, hook)
} else {
// Webpack < 4.0.0
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'
Domain
Subdomains
Imported By
Source
Frequently Asked Questions
What does util.ts do?
util.ts is a source file in the vue codebase, written in typescript. It belongs to the ServerRenderer domain, BundleRenderer subdomain.
What functions are defined in util.ts?
util.ts defines 5 function(s): exports, getAssetName, onEmit, stripModuleIdHash, validate.
What files import util.ts?
util.ts is imported by 2 file(s): client.ts, server.ts.
Where is util.ts in the architecture?
util.ts is located at packages/server-renderer/src/webpack-plugin/util.ts (domain: ServerRenderer, subdomain: BundleRenderer, directory: packages/server-renderer/src/webpack-plugin).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free