Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

vue文件id 算法修改 #1991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from
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 14 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.