Skip to content

Commit

Permalink
feat(transform): expose notModified flag in transform context (vitejs…
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikg authored Jul 16, 2020
1 parent 8ae073e commit 2da41f1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/node/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ interface TransformTestContext {
*/
isImport: boolean
isBuild: boolean
/**
* Indicates that the file for this request was not modified since last call.
*/
notModified?: true
}

export interface TransformContext extends TransformTestContext {
Expand Down Expand Up @@ -62,7 +66,7 @@ export function createServerTransformPlugin(
return
}

const { url, path, query } = ctx
const { url, path, query, __notModified } = ctx
const isImport = isImportRequest(ctx)
const isBuild = false
let code: string = ''
Expand All @@ -75,6 +79,10 @@ export function createServerTransformPlugin(
isImport,
isBuild
}
if (__notModified) {
transformContext.notModified = true
}

if (t.test(transformContext)) {
code = code || (await readBody(ctx.body))!
const result = await t.transform({
Expand Down

0 comments on commit 2da41f1

Please sign in to comment.