diff --git a/src/index.ts b/src/index.ts index d7d43700e..f46e4f809 100644 --- a/src/index.ts +++ b/src/index.ts @@ -113,11 +113,10 @@ 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 + ? resourcePath + '\n' + source.replace(/\r\n/g, '\n') + : resourcePath ) // if the query has a type field, this is a language block request diff --git a/test/utils.ts b/test/utils.ts index 13261b4c2..b59267383 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -163,9 +163,9 @@ export function normalizeNewline(input: string): string { } // see the logic at src/index.ts -// in non-production environment, shortFilePath is used to generate scope id +// in non-production environment, resourcePath is used to generate scope id export function genId(fixtureName: string): string { - return hash(path.join('test', 'fixtures', fixtureName).replace(/\\/g, '/')) + return hash(path.join(__dirname, 'fixtures', fixtureName).replace(/\\/g, '/')) } export { mfs }