Skip to content

Commit

Permalink
fix: resourceQuery could be undefined in webpack 5
Browse files Browse the repository at this point in the history
fixes #1771
  • Loading branch information
sodatea committed Dec 17, 2020
1 parent 0edc4b6 commit a2b89d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -49,7 +49,7 @@ module.exports = function (source) {
sourceMap,
rootContext,
resourcePath,
resourceQuery
resourceQuery = ''
} = loaderContext

const rawQuery = resourceQuery.slice(1)
Expand Down
2 changes: 2 additions & 0 deletions lib/plugin-webpack5.js
Expand Up @@ -120,6 +120,7 @@ class VueLoaderPlugin {
const pitcher = {
loader: require.resolve('./loaders/pitcher'),
resourceQuery: query => {
if (!query) { return false }
const parsed = qs.parse(query.slice(1))
return parsed.vue != null
},
Expand Down Expand Up @@ -172,6 +173,7 @@ function cloneRule (rawRule, refs) {
return true
},
resourceQuery: query => {
if (!query) { return false }
const parsed = qs.parse(query.slice(1))
if (parsed.vue == null) {
return false
Expand Down
15 changes: 15 additions & 0 deletions test/edgeCases.spec.js
@@ -1,5 +1,6 @@
const path = require('path')
const normalizeNewline = require('normalize-newline')
const webpack = require('webpack')
const HTMLPlugin = require('html-webpack-plugin')

const {
Expand Down Expand Up @@ -212,3 +213,17 @@ test('use with postLoader', done => {
}, done)
})
})

// #1711
test('data: URI as entry', done => {
// this feature is only available in webpack 5
if (webpack.version.startsWith('4')) {
return
}

bundle({
entry: {
main: 'data:text/javascript,console.log("hello world")'
}
}, () => done())
})

0 comments on commit a2b89d3

Please sign in to comment.