Skip to content

Commit

Permalink
fix: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Jul 20, 2020
1 parent 9129145 commit 74819fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/node/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export function createResolver(

// example id: "@babel/runtime/helpers/esm/slicedToArray"
// see the test case: /playground/TestNormalizePublicPath.vue
const id = publicPath.replace(moduleRE, '')
const id = cleanPublicPath.replace(moduleRE, '')
const { scope, name, inPkgPath } = parseNodeModuleId(id)
if (!inPkgPath) return publicPath
let filePathPostFix = ''
Expand Down
12 changes: 10 additions & 2 deletions src/node/server/serverPluginModuleRewrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ import {
hmrDirtyFilesMap,
latestVersionsMap
} from './serverPluginHmr'
import { readBody, cleanUrl, isExternalUrl, bareImportRE } from '../utils'
import {
readBody,
cleanUrl,
isExternalUrl,
bareImportRE,
removeQueryTimestamp
} from '../utils'
import chalk from 'chalk'
import { isCSSRequest } from '../utils/cssUtils'
import { envPublicPath } from './serverPluginEnv'
Expand Down Expand Up @@ -76,7 +82,9 @@ export const moduleRewritePlugin: ServerPlugin = ({
// before we perform hmr analysis.
// on the other hand, static import is guaranteed to have extension
// because they must all have gone through module rewrite.
const importer = resolver.normalizePublicPath(ctx.path)
const importer = removeQueryTimestamp(
resolver.normalizePublicPath(ctx.url)
)
ctx.body = rewriteImports(
root,
content!,
Expand Down
9 changes: 9 additions & 0 deletions src/node/utils/pathUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,12 @@ export function parseNodeModuleId(id: string) {
inPkgPath
}
}

export function removeQueryTimestamp(url: string) {
if (url.includes('t=')) {
const { path, query } = parseWithQuery(url)
delete query.t
return path + qs.stringify(query)
}
return url
}

0 comments on commit 74819fb

Please sign in to comment.