123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // this module is a runtime utility for cleaner component module output and will
- // be included in the final webpack user bundle
- module.exports = function normalizeComponent (
- rawScriptExports,
- compiledTemplate,
- scopeId,
- cssModules
- ) {
- var esModule
- var scriptExports = rawScriptExports = rawScriptExports || {}
- // ES6 modules interop
- var type = typeof rawScriptExports.default
- if (type === 'object' || type === 'function') {
- esModule = rawScriptExports
- scriptExports = rawScriptExports.default
- }
- // Vue.extend constructor export interop
- var options = typeof scriptExports === 'function'
- ? scriptExports.options
- : scriptExports
- // render functions
- if (compiledTemplate) {
- options.render = compiledTemplate.render
- options.staticRenderFns = compiledTemplate.staticRenderFns
- }
- // scopedId
- if (scopeId) {
- options._scopeId = scopeId
- }
- // inject cssModules
- if (cssModules) {
- var computed = Object.create(options.computed || null)
- Object.keys(cssModules).forEach(function (key) {
- var module = cssModules[key]
- computed[key] = function () { return module }
- })
- options.computed = computed
- }
- return {
- esModule: esModule,
- exports: scriptExports,
- options: options
- }
- }
|