Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
fix: fallback assets resolve + bump @vue/component-compiler-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Jul 23, 2020
1 parent ea635d2 commit 0d04c91
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -32,7 +32,7 @@
]
},
"dependencies": {
"@vue/component-compiler-utils": "^3.1.2",
"@vue/component-compiler-utils": "^3.2.0",
"chalk": "^4.1.0",
"debug": "^4.1.1",
"esbuild": "^0.5.19",
Expand Down
24 changes: 4 additions & 20 deletions src/serverPlugin.ts
Expand Up @@ -250,19 +250,6 @@ if (import.meta.hot) {
return code
}

function transformRequireBackToURL(code: string, base: string): string {
return code.replace(
/require\(("(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+')\)/g,
(_, name) => {
if (name.charAt(1) == '.' && name.charAt(2) == '/') {
// it's relative to source file, make it absolute by prepending base path
return name.charAt(0) + base + name.substr(2)
}
return name
}
)
}

function compileSFCTemplate(
block: SFCBlock,
filePath: string,
Expand All @@ -273,9 +260,9 @@ function compileSFCTemplate(
filename: filePath,
compiler: vueTemplateCompiler,
transformAssetUrls: true,
// transformAssetUrlsOptions: {
// base: path.posix.dirname(publicPath),
// },
transformAssetUrlsOptions: {
base: path.posix.dirname(publicPath),
},
isProduction: process.env.NODE_ENV === 'production',
isFunctional: !!block.attrs.functional,
optimizeSSR: false,
Expand All @@ -291,10 +278,7 @@ function compileSFCTemplate(
errors.forEach(console.error)
}

return (
transformRequireBackToURL(code, path.posix.dirname(publicPath)) +
`\nexport { render, staticRenderFns }`
)
return code + `\nexport { render, staticRenderFns }`
}

async function resolveSrcImport(
Expand Down
16 changes: 16 additions & 0 deletions yarn.lock
Expand Up @@ -655,6 +655,22 @@
optionalDependencies:
prettier "^1.18.2"

"@vue/component-compiler-utils@^3.2.0":
version "3.2.0"
resolved "https://registry.npm.taobao.org/@vue/component-compiler-utils/download/@vue/component-compiler-utils-3.2.0.tgz?cache=0&sync_timestamp=1595427694165&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fcomponent-compiler-utils%2Fdownload%2F%40vue%2Fcomponent-compiler-utils-3.2.0.tgz#8f85182ceed28e9b3c75313de669f83166d11e5d"
integrity sha1-j4UYLO7Sjps8dTE95mn4MWbRHl0=
dependencies:
consolidate "^0.15.1"
hash-sum "^1.0.2"
lru-cache "^4.1.2"
merge-source-map "^1.1.0"
postcss "^7.0.14"
postcss-selector-parser "^6.0.2"
source-map "~0.6.1"
vue-template-es2015-compiler "^1.9.0"
optionalDependencies:
prettier "^1.18.2"

"@vue/component-compiler@^4.2.3":
version "4.2.3"
resolved "https://registry.npm.taobao.org/@vue/component-compiler/download/@vue/component-compiler-4.2.3.tgz#052855aea0f9a00eb0eb9786bdf447d29292ae37"
Expand Down

0 comments on commit 0d04c91

Please sign in to comment.