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 6a1ee76

Browse filesBrowse files
committed
fix: resourceQuery could be undefined in webpack 5
fixes vuejs#1771
1 parent 05cbb20 commit 6a1ee76
Copy full SHA for 6a1ee76

File tree

3 files changed

+29
-4
lines changed
Filter options

3 files changed

+29
-4
lines changed

‎src/index.ts

Copy file name to clipboardExpand all lines: src/index.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default function loader(
7979
sourceMap,
8080
rootContext,
8181
resourcePath,
82-
resourceQuery,
82+
resourceQuery = '',
8383
} = loaderContext
8484

8585
const rawQuery = resourceQuery.slice(1)

‎src/pluginWebpack5.ts

Copy file name to clipboardExpand all lines: src/pluginWebpack5.ts
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ class VueLoaderPlugin implements Plugin {
169169
// rule for template compiler
170170
const templateCompilerRule = {
171171
loader: require.resolve('./templateLoader'),
172-
resourceQuery: (query: string) => {
172+
resourceQuery: (query?: string) => {
173+
if (!query) {
174+
return false
175+
}
173176
const parsed = qs.parse(query.slice(1))
174177
return parsed.vue != null && parsed.type === 'template'
175178
},
@@ -188,7 +191,10 @@ class VueLoaderPlugin implements Plugin {
188191
// post loader)
189192
const pitcher = {
190193
loader: require.resolve('./pitcher'),
191-
resourceQuery: (query: string) => {
194+
resourceQuery: (query?: string) => {
195+
if (!query) {
196+
return false
197+
}
192198
const parsed = qs.parse(query.slice(1))
193199
return parsed.vue != null
194200
},
@@ -276,7 +282,11 @@ function cloneRule(
276282
currentResource = resources
277283
return true
278284
},
279-
resourceQuery: (query: string) => {
285+
resourceQuery: (query?: string) => {
286+
if (!query) {
287+
return false
288+
}
289+
280290
const parsed = qs.parse(query.slice(1))
281291
if (parsed.vue == null) {
282292
return false

‎test/edgeCases.spec.ts

Copy file name to clipboardExpand all lines: test/edgeCases.spec.ts
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as path from 'path'
2+
import webpack = require('webpack')
23
import HTMLPlugin = require('html-webpack-plugin')
34
import { mfs, bundle, mockBundleAndRun, normalizeNewline } from './utils'
45

@@ -181,3 +182,17 @@ test('use with postLoader', async () => {
181182
})
182183
assertComponent(Object.assign({ expectedMsg: 'Changed!' }, result))
183184
})
185+
186+
// #1771
187+
test('data: URI as entry', async () => {
188+
// this feature is only available in webpack 5
189+
if (webpack.version!.startsWith('4')) {
190+
return
191+
}
192+
193+
await bundle({
194+
entry: {
195+
main: 'data:text/javascript,console.log("hello world")',
196+
},
197+
})
198+
})

0 commit comments

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