Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9bbb82b

Browse filesBrowse files
authored
feat: allow manually specifying whether server-rendering is targeted (vuejs#1764)
This option provides a solution for vuejs#1734 When testing with mocha + mochapack, even though the target environment is `node`, the compiled component is expected to be run with `jsdom` rather than with a Node.js server, so it should still be a client bundle.
1 parent 388e030 commit 9bbb82b
Copy full SHA for 9bbb82b

File tree

Expand file treeCollapse file tree

3 files changed

+5
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+5
-3
lines changed

‎src/index.ts

Copy file name to clipboardExpand all lines: src/index.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export interface VueLoaderOptions {
4343
hotReload?: boolean
4444
exposeFilename?: boolean
4545
appendExtension?: boolean
46+
47+
isServerBuild?: boolean
4648
}
4749

4850
let errorEmitted = false
@@ -85,7 +87,7 @@ export default function loader(
8587
const options = (loaderUtils.getOptions(loaderContext) ||
8688
{}) as VueLoaderOptions
8789

88-
const isServer = target === 'node'
90+
const isServer = options.isServerBuild ?? target === 'node'
8991
const isProduction = mode === 'production'
9092

9193
const { descriptor, errors } = parse(source, {

‎src/resolveScript.ts

Copy file name to clipboardExpand all lines: src/resolveScript.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function resolveScript(
3333
}
3434

3535
const isProd = loaderContext.mode === 'production'
36-
const isServer = loaderContext.target === 'node'
36+
const isServer = options.isServerBuild ?? loaderContext.target === 'node'
3737
const enableInline = canInlineTemplate(descriptor, isProd)
3838

3939
const cacheToUse = isServer ? serverCache : clientCache

‎src/templateLoader.ts

Copy file name to clipboardExpand all lines: src/templateLoader.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const TemplateLoader: webpack.loader.Loader = function (source, inMap) {
2020
const options = (loaderUtils.getOptions(loaderContext) ||
2121
{}) as VueLoaderOptions
2222

23-
const isServer = loaderContext.target === 'node'
23+
const isServer = options.isServerBuild ?? loaderContext.target === 'node'
2424
const isProd = loaderContext.mode === 'production'
2525
const query = qs.parse(loaderContext.resourceQuery.slice(1))
2626
const scopeId = query.id as string

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.