Skip to content

Commit

Permalink
fix(ssr): normalize manifest filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdinando-ferreira committed Jun 18, 2021
1 parent bdcaba6 commit 90fc5e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-vue-jsx/index.js
Expand Up @@ -2,7 +2,7 @@
const babel = require('@babel/core')
const jsx = require('@vue/babel-plugin-jsx')
const importMeta = require('@babel/plugin-syntax-import-meta')
const { createFilter } = require('@rollup/pluginutils')
const { createFilter, normalizePath } = require('@rollup/pluginutils')
const hash = require('hash-sum')
const path = require('path')

Expand Down Expand Up @@ -220,7 +220,7 @@ function vueJsxPlugin(options = {}) {
}

if (ssr) {
const normalizedId = path.relative(root, id)
const normalizedId = normalizePath(path.relative(root, id))
let ssrInjectCode =
`\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"` +
`\nconst __moduleId = ${JSON.stringify(normalizedId)}`
Expand Down
5 changes: 4 additions & 1 deletion packages/plugin-vue/src/main.ts
Expand Up @@ -8,6 +8,7 @@ import {
setDescriptor
} from './utils/descriptorCache'
import { PluginContext, TransformPluginContext } from 'rollup'
import { normalizePath } from '@rollup/pluginutils'
import { resolveScript } from './script'
import { transformTemplateInMain } from './template'
import { isOnlyTemplateChanged, isEqualBlock } from './handleHotUpdate'
Expand Down Expand Up @@ -143,7 +144,9 @@ export async function transformMain(

// SSR module registration by wrapping user setup
if (ssr) {
const normalizedFilename = path.relative(options.root, filename)
const normalizedFilename = normalizePath(
path.relative(options.root, filename)
)
output.push(
`import { useSSRContext as __vite_useSSRContext } from 'vue'`,
`const _sfc_setup = _sfc_main.setup`,
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/node/ssr/ssrManifestPlugin.ts
@@ -1,4 +1,5 @@
import { relative } from 'path'
import { normalizePath } from '@rollup/pluginutils'
import { ResolvedConfig } from '..'
import { Plugin } from '../plugin'
import { chunkToEmittedCssFileMap } from '../plugins/css'
Expand All @@ -22,7 +23,7 @@ export function ssrManifestPlugin(config: ResolvedConfig): Plugin {
: chunkToEmittedCssFileMap.get(chunk)
const assetFiles = chunkToEmittedAssetsMap.get(chunk)
for (const id in chunk.modules) {
const normalizedId = relative(config.root, id)
const normalizedId = normalizePath(relative(config.root, id))
const mappedChunks =
ssrManifest[normalizedId] || (ssrManifest[normalizedId] = [])
if (!chunk.isEntry) {
Expand Down

0 comments on commit 90fc5e2

Please sign in to comment.