Commit be2384c2 authored by Evan You's avatar Evan You

fix: support usage with other loaders with enforce: post

fix #1351
parent 791999a2
......@@ -14,14 +14,16 @@ module.exports.pitch = function (remainingRequest) {
const { cacheDirectory, cacheIdentifier } = options
const query = qs.parse(this.resourceQuery.slice(1))
let loaders = this.loaders
// if this is a language block request, remove eslint-loader to avoid
// duplicate linting.
const loaders = query.type
? this.loaders.filter(l => !/(\/|\\|@)eslint-loader/.test(l.path))
: this.loaders
if (query.type) {
loaders = loaders.filter(l => !/(\/|\\|@)eslint-loader/.test(l.path))
}
// remove self
loaders.shift()
loaders = loaders.filter(l => l.path !== __filename)
// do not inject if user uses null-loader to void the type (#1239)
if (loaders.some(l => /(\/|\\|@)null-loader/.test(l.path))) {
......
......@@ -9,7 +9,11 @@ const {
mockBundleAndRun
} = require('./utils')
const assertComponent = ({ window, module }, done) => {
const assertComponent = ({
window,
module,
expectedMsg = 'Hello from Component A!'
}, done) => {
if (typeof module === 'function') {
module = module.options
}
......@@ -23,7 +27,7 @@ const assertComponent = ({ window, module }, done) => {
expect(vnode.data.staticClass).toBe('red')
expect(vnode.children[0].text).toBe('hi')
expect(module.data().msg).toContain('Hello from Component A!')
expect(module.data().msg).toContain(expectedMsg)
let style = window.document.querySelector('style').textContent
style = normalizeNewline(style)
expect(style).toContain('comp-a h2 {\n color: #f00;\n}')
......@@ -184,3 +188,27 @@ test('proper dedupe on src-imports with options', done => {
}
}, res => assertComponent(res, done))
})
// #1351
test('use with postLoader', done => {
mockBundleAndRun({
entry: 'basic.vue',
module: {
rules: [
{
test: /\.js$/,
use: {
loader: require.resolve('./mock-loaders/js')
},
enforce: 'post'
}
]
}
}, ({ window, module }) => {
assertComponent({
window,
module,
expectedMsg: 'Changed!'
}, 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