Skip to content

Commit 621a9ca

Browse files
author
yansen.lei
committed
fix: get unique module-id by the hash resourcePath
1 parent 6a293df commit 621a9ca

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@ export default function loader(
113113
const rawShortFilePath = path
114114
.relative(rootContext || process.cwd(), filename)
115115
.replace(/^(\.\.[\/\\])+/, '')
116-
const shortFilePath = rawShortFilePath.replace(/\\/g, '/')
117116
const id = hash(
118117
isProduction
119-
? shortFilePath + '\n' + source.replace(/\r\n/g, '\n')
120-
: shortFilePath
118+
? resourcePath + '\n' + source.replace(/\r\n/g, '\n')
119+
: resourcePath
121120
)
122121

123122
// if the query has a type field, this is a language block request

test/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function normalizeNewline(input: string): string {
163163
}
164164

165165
// see the logic at src/index.ts
166-
// in non-production environment, shortFilePath is used to generate scope id
166+
// in non-production environment, resourcePath is used to generate scope id
167167
export function genId(fixtureName: string): string {
168168
return hash(path.join('test', 'fixtures', fixtureName).replace(/\\/g, '/'))
169169
}

0 commit comments

Comments
 (0)