Skip to content

Commit f9a58ae

Browse files
author
baitu.huang
committed
remove hot-reload hack code because of vuejs/vue-loader#1569
1 parent 0546611 commit f9a58ae

File tree

5 files changed

+5
-21
lines changed

5 files changed

+5
-21
lines changed

Diff for: lib/ignore-module-loader.js

-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ module.exports.pitch = function ignoreLoaderPitch () {
2424
const matched = pluginOptions.ignoreFiles.find(v => v.test(this.resourcePath))
2525
if (matched) {
2626
const rawRequest = getRequestRes(this._module.rawRequest || this.request)
27-
// const vueComponent = pluginOptions.watch && this.hot && /\.vue(\.html)?$/.test(this.resourcePath)
2827
const logMsg = JSON.stringify(
2928
`${PLUGIN_NAME} warning: ` +
3029
`This module ${rawRequest} was ignored due to flag ${JSON.stringify(matched.__flag_name__)}`
3130
)
3231
return `process.env.NODE_ENV === 'development' && console.warn(${logMsg})\n` +
33-
// (vueComponent ? `module.hot && module.hot.dispose(function(data) {data.__vue_component_hot__ = true})\n` : '') +
3432
'module.exports = undefined'
3533
}
3634
}

Diff for: lib/plugin.js

-4
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ module.exports = class VueFlagsWebpackPlugin {
9797
loader: require.resolve('./template-loader')
9898
})
9999
}
100-
// vueUses.splice(index, 0, {
101-
// loader: require.resolve('./template-loader'),
102-
// options: { watch: this.pluginOptions.watch }
103-
// })
104100
}
105101
// prepend ignore module pitch loader
106102
if (this.pluginOptions.ignoreFiles) {

Diff for: lib/resolve-options.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ function setOptions ({ flags, ignoreFiles, namespace, watch }, context, watchOpt
128128
if (typeof flags === 'string') {
129129
if (!path.isAbsolute(flags)) {
130130
flags = path.resolve(context, flags)
131-
flags = require.resolve(flags)
132131
}
133-
const stats = fs.statSync(flags)
134-
if (!stats.isFile()) {
135-
throw genError(`flags: ${flags} is not a file`)
132+
try {
133+
flags = require.resolve(flags)
134+
} catch (err) {
135+
throw genError(`Options: "flags" cannot be resolved, ${err.message}`)
136136
}
137137
}
138138
if (watch) {

Diff for: lib/template-loader.js

-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
const loaderUtils = require('loader-utils')
22
const { RESOLVED_FLAGS_PATH, IF_FLAG } = require('./constants')
33
const ifDirReg = new RegExp(`\\s${IF_FLAG}(?:\\s*(=)\\s*(?:"([^"]+)"+|'([^']+)'+|([^\\s"'=<>\`]+)))`)
4-
// const hotReloadRegs = [/module\.hot\.accept\(/, /module\.hot\.data/, /vue/]
54

65
module.exports = function vueFlagsTemplateLoader (source, map) {
7-
// let vue, type
8-
// const { watch } = loaderUtils.getOptions(this)
9-
// if (!watch) {
10-
// return this.callback(null, source, map)
11-
// }
126
if (this.resourceQuery) {
137
const { vue, type } = loaderUtils.parseQuery(this.resourceQuery)
148
if (vue && type === 'template' && ifDirReg.test(source)) {
159
this.addDependency(RESOLVED_FLAGS_PATH)
1610
}
1711
}
18-
// if (!type && this.hot && hotReloadRegs.every(r => r.test(source))) {
19-
// // create component hot reload record by removing `module.hot.data`, see `vue-hot-reload-api`
20-
// source = 'module.hot && module.hot.data && module.hot.data.__vue_component_hot__ && (module.hot.data = undefined);\n' + source
21-
// }
2212
this.callback(null, source, map)
2313
}

Diff for: test/options.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ test(chalk.cyan('options test:invalid'), t => {
9595
}, {
9696
flags: 'aaaaaaaa',
9797
namespace: 'F',
98-
msg: /no such file or directory.+a{5,}/
98+
msg: /Options: "flags" cannot be resolved, .+a{5,}/
9999
}].forEach(option => {
100100
const msg = option.msg
101101
delete option.msg

0 commit comments

Comments
 (0)