Skip to content

Commit 84b294f

Browse files
moyusQingWei-Li
authored andcommitted
Replace deprecated context properties and support webpack 4.x (QingWei-Li#40)
* upgrade loader-utils * webpack 4.x support
1 parent cc92746 commit 84b294f

File tree

4 files changed

+68
-24
lines changed

4 files changed

+68
-24
lines changed

lib/core.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ var markdownCompilerPath = path.resolve(__dirname, 'markdown-compiler.js');
66
module.exports = function(source) {
77
this.cacheable();
88

9-
this.options.__vueMarkdownOptions__ =
10-
this.query || this.vueMarkdown || this.options.vueMarkdown || {};
9+
var options = loaderUtils.getOptions(this) || {};
10+
Object.defineProperty(this._compilation, '__vueMarkdownOptions__', {
11+
value: options,
12+
enumerable: false,
13+
configurable: true
14+
})
1115

1216
var filePath = this.resourcePath;
1317

lib/markdown-compiler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ var renderVueTemplate = function(html, wrapper) {
6363
module.exports = function(source) {
6464
this.cacheable && this.cacheable();
6565
var parser, preprocess;
66-
var params = loaderUtils.parseQuery(this.query) || {};
67-
var vueMarkdownOptions = this.options.__vueMarkdownOptions__;
66+
var params = loaderUtils.getOptions(this) || {};
67+
var vueMarkdownOptions = this._compilation.__vueMarkdownOptions__;
6868
var opts = Object.create(vueMarkdownOptions.__proto__); // inherit prototype
6969
var preventExtract = false;
7070

package-lock.json

Lines changed: 59 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"dependencies": {
2626
"cheerio": "^0.20.0",
2727
"highlight.js": "^9.4.0",
28-
"loader-utils": "^0.2.15",
28+
"loader-utils": "^1.1.0",
2929
"markdown-it": "^8.4.0"
3030
},
3131
"peerDependencies": {

0 commit comments

Comments
 (0)