Commit a2b89d3c authored by Haoqun Jiang's avatar Haoqun Jiang

fix: resourceQuery could be undefined in webpack 5

fixes #1771
parent 0edc4b6b
...@@ -49,7 +49,7 @@ module.exports = function (source) { ...@@ -49,7 +49,7 @@ module.exports = function (source) {
sourceMap, sourceMap,
rootContext, rootContext,
resourcePath, resourcePath,
resourceQuery resourceQuery = ''
} = loaderContext } = loaderContext
const rawQuery = resourceQuery.slice(1) const rawQuery = resourceQuery.slice(1)
......
...@@ -120,6 +120,7 @@ class VueLoaderPlugin { ...@@ -120,6 +120,7 @@ class VueLoaderPlugin {
const pitcher = { const pitcher = {
loader: require.resolve('./loaders/pitcher'), loader: require.resolve('./loaders/pitcher'),
resourceQuery: query => { resourceQuery: query => {
if (!query) { return false }
const parsed = qs.parse(query.slice(1)) const parsed = qs.parse(query.slice(1))
return parsed.vue != null return parsed.vue != null
}, },
...@@ -172,6 +173,7 @@ function cloneRule (rawRule, refs) { ...@@ -172,6 +173,7 @@ function cloneRule (rawRule, refs) {
return true return true
}, },
resourceQuery: query => { resourceQuery: query => {
if (!query) { return false }
const parsed = qs.parse(query.slice(1)) const parsed = qs.parse(query.slice(1))
if (parsed.vue == null) { if (parsed.vue == null) {
return false return false
......
const path = require('path') const path = require('path')
const normalizeNewline = require('normalize-newline') const normalizeNewline = require('normalize-newline')
const webpack = require('webpack')
const HTMLPlugin = require('html-webpack-plugin') const HTMLPlugin = require('html-webpack-plugin')
const { const {
...@@ -212,3 +213,17 @@ test('use with postLoader', done => { ...@@ -212,3 +213,17 @@ test('use with postLoader', done => {
}, 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())
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment