Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import * as path from 'path'
import * as qs from 'querystring'
import * as loaderUtils from 'loader-utils'

import hash = require('hash-sum')

import { parse } from 'vue/compiler-sfc'
import type {
TemplateCompiler,
Expand Down Expand Up @@ -42,6 +40,7 @@ export interface VueLoaderOptions {
}

let errorEmitted = false
let shortFilePathCache: Array<string> = []

const exportHelperPath = JSON.stringify(require.resolve('./exportHelper'))

Expand Down Expand Up @@ -113,12 +112,9 @@ export default function loader(
const rawShortFilePath = path
.relative(rootContext || process.cwd(), filename)
.replace(/^(\.\.[\/\\])+/, '')
const shortFilePath = rawShortFilePath.replace(/\\/g, '/')
const id = hash(
isProduction
? shortFilePath + '\n' + source.replace(/\r\n/g, '\n')
: shortFilePath
)
const shortFilePath = rawShortFilePath.replace(/\\/g, '/');
shortFilePathCache.includes(shortFilePath) || shortFilePathCache.push(shortFilePath);
const id = shortFilePathCache.indexOf(shortFilePath).toString(36);

// if the query has a type field, this is a language block request
// e.g. foo.vue?type=template&id=xxxxx
Expand Down Expand Up @@ -247,7 +243,7 @@ export default function loader(
// from the devtools.
propsToAttach.push([
`__file`,
JSON.stringify(rawShortFilePath.replace(/\\/g, '/')),
JSON.stringify(shortFilePath),
])
} else if (options.exposeFilename) {
// Libraries can opt-in to expose their components' filenames in production builds.
Expand Down